A C program to find square of a number using function


NO PARAMETER AND NO RETURN VALUE

#include<stdio.h>
void main()
{
square();
return;
}
void square()
{
int a,s;
printf("\nenter a number\n");
scanf("%d",&a);
s=a*a;
printf("\nsquare of a number is= %d",s);
return;
}



WITH PARAMETER AND NO RETURN VALUE

#include<stdio.h>
void square(int a);
void main()
{
int m;
printf("\nenter number to square\n");
scanf("%d",&m);
square(m);
return;
}
void square(int a)
{
int s;
s=(a*a)
return;
}


WITH NO PARAMETER AND WITH RETURN VALUE


#include<stdio.h>
int square();
void main()
{
int s;
s=square();
printf("\nsquare is %d",s);
return;
}
int square()
{
int a,s;
printf("\nenter the value of a");
scanf("%d",&a);
s=a*a;
return s;
}


WITH PARAMETER AND WITH RETURN VALUE

#include<stdio.h>
int square(int a)
{
int s;
s=a*a;
return s;
}
void main()
{
int x,y;
printf("\nenter a number ");
scanf("%d",&x);
y=square(x);
printf("the square of the number is %d",y);
}

Comments

Popular posts from this blog

Visti Cloud Service (VCS)

Being a DARK SKINNED is not a PROBLEM