Q:

C program to read an integer and print its multiplication table

0

C program to read an integer and print its multiplication table

Using while or do while loop: wap to read any integer number and print its multiplication table

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Complete program using while loop

#include <stdio.h>
int main()
{
	int num; 	/*to store number*/
	int i;	/*loop counter*/
	
	/*Reading the number*/
	printf("Enter an integer number: ");
	scanf("%d",&num);
	
	/*Initialising loop counter*/
	i=1;
	
	/*loop from 1 to 10*/
	while(i<=10){
		printf("%d\n",(num*i));
		i++; /*Increase loop counter*/
	}
	
	return 0;
}

Output

Enter an integer number: 12 
12
24
36
48
60
72
84
96
108
120 

Code using do while loop

/*Initialising loop counter*/
i=1;

/*loop from 1 to 10*/
do{
	printf("%d\n",(num*i));
	i++; /*Increase loop counter*/
}while(i<=10);

Code using for loop

for(i=1;i<=10;i++){
	printf("%d\n",(num*i));
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C program to print table of numbers from 1 to 20... >>
<< C program to print numbers from 1 to 10 using whil...