Computer Science, asked by hemacharanbathina, 8 months ago

write a program to accept a number and print it's square with output
(c programming)

Answers

Answered by MrVikrant
2

Explanation:

#include <stdio.h>

#include <conio.h>

void main()

{

   int i, result;

   printf("Enter a number : ");

   scanf("%d",&i);

   

   result = i*i;

   

   printf("Square of given number : %d", result);

  getch();

}

If it helps, please mark brainliest.

Answered by anjalin
0

#include <stdio.h>

#include <conio.h>

void main()

{

  int a, ans;

  printf("Please Input number : ");

  scanf("%d",&a);

 ans =a*a;

 printf("Square of given number : %d", ans);

}

Explanation:

  • Given C program computes the square of the integer given as input.
  • Firstly it includes all the necessary libraries.
  • Then the main functions start with declaring two variables i.e. a and ans.
  • Then the number whose square is to be calculated is taken as input and stored in the variable a.
  • Then to compute the square, variable a is multiplied with itself and the result is stored in the variable ans.
  • Then, the variable ans is finally displayed as the final result.

Thus, the given C program helps compute the given number's square.

Similar questions