Q. Write a C program to accept a number from user and print the square of number. Also draw the flowchart of program.
Ans.
/*c program to calculate the square of number*/
#include<stdio.h>
int main()
{
double n,z;
printf("Enter any number : ");
scanf("%lf", &n);
z = n * n;
printf("Square of number %lf*%lf = %lf",n,n,z);
return 0;
}
The output of above program would be:
Enter any number : 25
Square of number 25*25 = 625
Flowchart of above C square number program:
Related programs:
Ans.
/*c program to calculate the square of number*/
#include<stdio.h>
int main()
{
double n,z;
printf("Enter any number : ");
scanf("%lf", &n);
z = n * n;
printf("Square of number %lf*%lf = %lf",n,n,z);
return 0;
}
The output of above program would be:
Enter any number : 25
Square of number 25*25 = 625
Flowchart of above C square number program:
Figure : Flowchart for square number C program |
Related programs:
Comments
Post a Comment