ProAnswers.org

Write a C program to display the Number and its Square?

 #include<stdio.h>

#include<conio.h>

void main()

{

int n,i;

clrscr();

printf(“enter the value of n\n”);

scanf(“%d”,&n);

for(i=1;i<=n;i++)

printf(“the number is %d and its square is %d\n”,i,i*i);

getch();

}

Output:

enter the value of n

3

the number is 1 and its square is 1

the number is 2 and its square is 4

the number is 3 and its square is 9