Monday 14 March 2016

Multiplication Table


Write a C program to print the multiplication table of an integer n upto m rows using a for loop.

Input Format:
Input consists of 2 integers. The first integer corresponds to n. The second integer corresponds to m.

Output Format: 
Refer Sample Input and Output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to output]

Sample Input and Output: 
Enter n
5
Enter m
4
The multiplication table of 5 is
1*5=5
2*5=10
3*5=15
4*5=20

Code:
  #include<stdio.h>
int main(){
  int n, m,i;
  printf("Enter n\n");
  scanf("%d",&n);
  printf("Enter m\n");
  scanf("%d",&m);
  printf("The multiplication table of %d is\n",n);
  for (i=1;i<=m;i++)
  {
    printf("%d*%d=%d\n",i,n,(i*n));
  }
  
  
  return 0;
}

No comments:

Post a Comment