C Program To Print Table Of n And Square Of n Using pow()

How To Write a C Program To Print Table Of n And Square Of n Using pow() in C Programming Language ?

Solution For C Program To Print Table of n and Square of n:
#include<stdio.h>
#include<conio.h>
void main()
{
      int n;
      printf("Not Square");
      printf("-----------------n");
      for(n=1;n <=10;n++)
          printf("%d\t%d\n",n,n*n);
      getch();
}
Output :
 No Square
 -------------
  1 1
  2 4
  3 9
  4 16
  5 25
  6 36
  7 49
  8 64
  9 81
 10 100

We can alternately write above program like this -
printf("%d\t%d\n",n,pow(n,2));
In order to use above line in the code we need to include math.h header file inside C program.
#include<math.h>

Solution For C Program To Print Table Of n And Square Of n Using pow():
#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
      int n;
      printf("Not Square\n");
      printf("-----------------n");
      for(n=1;n <=10;n++)
          printf("%d\t%d\n",n,pow(n,2));
      getch();
}

Tags: C Program to print table of n and square of n using pow(), C program to find power of a number using pow() Function, C Program to print table of n and square of n using pow().


Learn More :