Mid 2
Mid 2
C Program to print the average of 1 to n numbers using functions without return type
2. Write a program in C to find the square of any number using the function
For example:
1 20 The square of 20 is :
400.00
2 5 The square of 5 is :
25.00
3. Write a C program through a pointer to compare three numbers and display a small
number
For example:
1 2 5 9 2
2 26 98 12 12
4. Write a c program to call a function without arguments and with return values from
other user-defined functions, to calculate whether the number is prime or not
For example:
1 3 prime
2 9 not
prime
1 5 8 sum=1
3
2 3 4 sum=7
10. Write a program to print even and odd numbers in a given range using functions.
For example:
1 13 15 15 13
1 4 factorial of
number=24
2 6 factorial of
number=720
1 4 6 LCM of 4 and 6
is:12
2 1 7 LCM of 1 and 7
is:7
14. check given number is prime number or not using with argument without return type?
For example:
Tes Input Result
t
1 5 prime number
2 10 Not prime
number
1 3 3 27
2 5 2 25
1 5 sum of
numbers=15
2 0 Invalid Number
1 2 4 16
2 3 3 27
18. Write a program to find the product of two numbers using recursion.
For example:
19. Write a program to find the GCD of two numbers using Recursions.
For example:
1 36 60 12
2 12 18 6
20. Write a program in C to find the maximum number between two numbers using a
pointer.
21. Write a C program to solve the following equation.
f(n)=f(n-2)+f(n-1), for all n>=2,
f(n)=1 for all n<2
Note : Use recursion with call by value passing method and function should return an
integer value.
22. Using recursion write a C program to display values of n, m when the m crosses n
or n crosses m. Here m, n are two integers . One number will cross other after
successively incrementing or decrementing.
Example : m=1 , n=5 , cross each other when n=2 , m=4
m=-6 , n=-10 , cross each other when n=-7, m=-9
m=5 , n=1 , cross each other when n=4 , m=2
23. Write a function that returns value of m*2n
m>0 and n>0
Note: 1 .Use call by reference parameter passing method
2 . Function should return integer value
3. Use bitwise operators to compute m*2n
4 . Do not use any predefined functions to compute m*2n
24. c program to find perfect numbers between 10 and to a given number using a
function with arguments and with return type
For example:
1 500 28 496
2 9000 28 496
8128
25. Write a C program to print strong numbers between two given numbers using
recursion. (Note: And pass values to the function to its address to perform the
operation)
For example:
1 20 650 145
2 220 40585
65412
27. Write a program in C to check whether a number is a prime number or not using the
function.
For example:
28. C program to find the area of a circle and the area of a triangle using two functions
with arguments and call these two functions from the third function and pass values
to those two functions through this third function. And call the third function from
the main function (Note: take the first two parameters to calculate the area of a
triangle and the third parameter to calculate the area of the circle)
For example:
29. Write a C program "to store 5 numbers in dynamically created memory and a
function that returns biggest of the numbers stored in that memory".
Note : 1. Use call by reference parameter passing method.
2. Function should return a integer value.
30. Write a function ( c program ) to count all perfect numbers in between m,n.
(n>m , m>1 , n>1)
In number theory, a perfect number is a positive integer that is equal to the sum of its
positive divisors, excluding the number itself. The smallest perfect number is 6, which is
the sum of 1, 2, and 3.
Note 1. Use call by reference parameter passing method
2. Your function should return a pointer.
31. Using recursion write a c program to computer mm
(m>0)
Note : 1.Use call by value method to pass parameters and
2.function should return an integer
3.Do not use any predefined functions
32. Write a program to generate the Fibonacci series using recursion.
For example:
1 12 144
2 8 21
33. Write a program to generate the Fibonacci series using any function category.
For example:
1 7 0 1 1 2 3 5
8
4 0 1 1
2
34. check given number is armstrong number or not using without argument without
return type
For example:
Tes Input Result
t
35. Write a C program to print all strong numbers between given intervals using
functions.
For example:
1 1 1000 1 2
145
2 67 145
1000
36. Write a c program to find the GCD of two numbers using with arguments and with
return type.
For example:
1 24 30 6
2 6 18 6
For example:
Tes Input Result
t
1 2 3 8
2 3 4 81
38. Write a program in C to find the sum of digits of a number using recursion.
For example:
2 enter any number to find sum of digits: The Sum of digits of 105
105 = 6