C program to find table of any number by using while loop.

In this article we learn how to print table of any number by using while loop.

 

Let’s write a program to print table of any number.

 

Step 1: Let’s open turbo C and write the following code:

 

Code:

 

// Add preprocessor

#include<stdio.h>

#include<conio.h>

void main()

{

 

// Declare variable

long int i=1,result,n;

 

// Clear screen

clrscr();

printf(“enter any number : “);

scanf(“%li”,&n);

 

// Using loop

while(i<=10)

{

result=n*i;

printf(“\n %li”,result);

i++;

}

getch();

}

 

 

Step 2: Now save it by pressing F2 and name it TABLE.CPP .

 

 

Step 3: Compile it by pressing ALT+F9 ,to check errors and correct them.

 

 

Step 4: Now Run the program and see output.

 

 

//Output

 

output

 

Happy coding.

 

 

 

 

 

 

Tags: , , ,