Tuesday, 12 April 2016

area and radius of circle using function12-04-16

#include<stdio.h>
main()
{
float circle(int);     //function declaration
int square(int);       //function declaration   

int rad, side;


printf("Enter the length of side of square  ");
scanf("%d",&side);
                         
printf("area of square is %d\n",square(side));  //call of function

printf("Enter the rad of circle  ");
scanf("%d",&rad);
                          
printf("area of circle is %f\n",circle(rad));  //call of function
}

int square(int a)          //definition
{
int area;
area = a*a;
return(area);
}

float circle(int b)       //definition
{
float area;
area = 3.14*b*b;
return(area);
}

#include<stdio.h>
main()
{
int fact(int);

int c,z;
printf("factorial of a number is %d",fact(c));
}

int fact(int ft)
{
int i,a;
ft=1;
printf("Enter a number to print factorial of ");
scanf("%d",&a);
for(i=1; i<=a; i++)
ft = ft*i;
return(ft);
}

No comments:

Post a Comment