Write a Program to print multiplication table of a number. Given an input number, we have to print the multiplication table of a number.
In this tutorial we cover following topics.
C, C++ Interview Questions
Program to count number of vowels in a string
Let's write a c code to generate multiplication table of a number. In this program, we take an input number and print it's table.
Output:
Enter a number to print table 5
Programming question on strings
Sorting algorithms and their time complexity
In this tutorial we cover following topics.
- C program to print multiplication table of a number.
- C++ program to print multiplication table of a number.
C, C++ Interview Questions
Program to count number of vowels in a string
C Program to Print Multiplication Table of a Number
Let's write a c code to generate multiplication table of a number. In this program, we take an input number and print it's table.
#include <stdio.h>
int main() {
int num,i;
/* Taking input number */
printf("Enter a number to print table \n");
scanf("%d",&num);
/* Run a loop from 1 to 10 */
for(i=1; i <= 10; i++){
printf("%d * %d = %d \n",num,i,i*num);
}
return 0;
}
Output:
Enter a number to print table 5
5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25 5 * 6 = 30 5 * 7 = 35 5 * 8 = 40 5 * 9 = 45 5 * 10 = 50
C++ Program to Print Multiplication Table of a Number
#include <iostream>
using namespace std;
int main() {
int num,i;
/* Taking input number */
cout<< "Enter number to print table \n";
cin >> num;
/* Run a loop from 1 to 10 */
for(i=1; i<=10; i++){
cout << num << "*" << i << " = " << i*num<<"\n";
}
return 0;
}
Programming question on strings
Sorting algorithms and their time complexity

No comments:
Post a Comment