Square number program and flowchart

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:


Flowchart of square number C program
Figure : Flowchart for square number C program

Related programs:

  1. What is Algorithm and Flowchart
  2. Basic of Algorithm
  3. Flowchart for search prime number
  4. Factorial C program, Algorithm and Flowchart
  5. Flowchart for check a number is Armstrong number or not

Comments