Tuesday, 9 December 2014

C Program to find square and cube of a number

Program to find square and cube of a number
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int sum(int a,int b)
{
int sum1;
sum1=a+b;
return sum1;
}
int squ(int c)
{
int square;
square=(c*c);
return square;
}
int cube(int s)
{
int cube;
cube=(s*s*s);
return cube;
}
main()
{
int s,c;
int a=10,b=20,cu=cube(s=squ(c=sum(a,b)));
printf("sum=%d square=%d cube=%d ",c,s,cu);
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ ./a.out
sum=30 square=900 cube=729000000