FY_Functions_Solved
FY_Functions_Solved
SOLVED PROGRAMS
Write a Function in C++ … 2
1. To find area of circle. [ float area(float) ]
2. to find greatest of three numbers. [ int max(int,int,int)]
3. to find greatest of four numbers. [ int max(int,int,int,int)]
4. to find square and cube of a number.
[ int sqr(int) and int cube(int)]
5. to find factorial of a number. [ int fact(int) ]
6. to print Fibonacci sequence. [ void fib(int) ]
7. to find g.c.d. of two integers. [ int gcd(int,int) ]
Write a function in C++ … 3
8. to read set of numbers and find sum of all numbers.
[ int sum_of_set(int) ]
9. to find sum of the digits of a number. [ int
sum_of_digit(int) ]
(e.g. : 125 = 1 + 2+ 5 = 8 )
10. to find reverse the digits of a number. [ int reverse(int) ]
(e.g. : 125 => 521 )
11. to check whether a number is palindrome or not. (e.g. :
121)
12. to check whether a number is prime or not.
[ int IsPrime(int) ]
To find area of circle. [ float area(float) ]
#include<iostream.h>
#include<conio.h>
float area(float);
const float PI = 3.14f;
void main()
{
clrscr();
float a,r;
cout << "Enter radius :";
cin>>r;
a = area(r);
cout<< "Area of circle = " << a;
getch();
}
float area(float r)
{
return 3.14*r*r;
}
to find greatest of three numbers. [ int max(int,int,int)]