function in c
#include <stdio.h>
int Area_Square(int side); // prototype
int main()
{
int c;
c = Area_Square(45);
printf("Area of Square is %d", c);
return 0;
}
int Area_Square(int side)
{
int c;
c = side * side;
return c;
}
# include<stdio.h>
void display();
int main(){
int a ;
printf("initial statement \n ");
display();
printf("final ending function \n ");
return 0;
}
void display(){
printf("Display can be seen ! \n ");
}
#include <stdio.h>
void good_morning();
void good_afternoon();
void good_night();
int main()
{
good_morning();
good_afternoon();
good_night();
return 0;
}
void good_morning()
{
printf("Hello buddy Good Morning! \n");
}
void good_afternoon()
{
printf("Hello buddy Good Afternoon! \n");
}
void good_night()
{
printf("Hello buddy Good Night! \n");
}
#include <stdio.h>
int sum(int a); // function prototype
int main()
{
int number, c;
printf("enter the number to sum");
scanf("%d", &number);
c = sum(number);
printf("sum is %d", c);
return 0;
}
int sum(int a)
{
if (a != 0)
{
return a + sum(a - 1);
}
else
{
return a;
}
}
#include <stdio.h>
int factorial(int a); // prototype
int main()
{
int a = 10;
printf("the value of fac %d is %d", a, factorial(a));
return 0;
}
int factorial(int a)
{
printf("calling function %d \n", a);
if (a == 1 || a == 0)
{
return 1;
}
else
{
return a * factorial(a - 1);
}
}
# include<stdio.h>
# include<math.h>
int main(){
int side;
printf("enter the side \n");
scanf("%d",&side);
printf("The area of square is %f \n",pow(side,2));
return 0;
}
No comments:
Post a Comment