Skip to main content

C Program to Generate Multiplication Table according to User Choice.

 C Program to Generate Multiplication Table according to User Choice.

    In this program, we will learn how to print a multiplication table according to any positive number entered by the user. This program uses for loop to solve this problem. 


C PROGRAM TO GENERATE MULTIPLICATION TABLE:


#include<stdio.h>
#include<conio.h>
int main()
{
    int i,num,res=0;
    printf("\nEnter the multplication table you want : ");
    scanf("%d",&num);
    printf("\n\n\n\tMULTIPLICATION TABLE OF %d\t",num);
    printf("\n--------------------------------------------------\n");
    for(i=1;i<=10;i++)
    {
        res=num*i;
        printf("\t%d  x %d = %d\n",num,i,res);
    }
    printf("\n\n");
    return 0;
}


OUTPUT:



NOTE: You Can Comment Your Code if you have solved differently and we will pin it in the comment section.  Let's Learn together. 


MOTTO: 

You Learn, I Learn together We Learn.



Comments

Popular posts from this blog

C program to calculate area of a circle using function.

C program to calculate area of a circle. In this example we will learn to calculate the area of a circle. Here in this program we will use 3.14 as the value of pi.  The formula to calculate the area of a circle is:                                                         area=   π  r² Flowchart To Calculate the Area of a Circle: PROGRAM: #include <conio.h> #include <stdio.h> int   main () {      float   radius , area ;      printf ( "Enter the radius of the circle : " );      scanf ( "%f" ,& radius );      area = 3.14 * radius * radius ;          printf ( "Area of the circle is : %.2f" , area );  ...

C Program to Swap the values of two variables using function.

C Program to Swap the values of two variables using function.     In this example, we swap the values of two variables using function. We have declared a function swap. PROGRAM #include <stdio.h> #include <conio.h> void   swap ( int *, int  *); int   main () {      int   a , b ;      printf ( "Enter the values of a and b : " );      scanf ( " %d%d " ,& a ,& b );      printf ( "Before swapping the values in main a= %d  , b= %d \n " , a , b );      swap (& a ,& b );      printf ( "After swapping the values in main a= %d  , b= %d \n " , a , b );      getch (); } void   swap ( int  * a , int  * b ) {      int   temp ;    ...

C Program to Calculate the Factorial of a number using Function

  C Program to Calculate the Factorial of a number using Function.     In this example, we will calculate the factorial of a number using function. Here we have used functions with Arguments and return value to perform this operation. We have declared a user-defined function fact which is called in the main function when printing the result. What is a Factorial of  a Number?      The factorial of a number is the product of all positive integers less than, equal to n. Factorial is denoted by the symbol '!'. Formula of factorial is n!=n x (n-1)! For example: 6!= 6 x 5 x 4 x 3 x 2 x1    = 720 PROGRAM TO CALCULATE THE FACTORIAL OF A NUMBER USING FUNCTION #include <stdio.h> #include <conio.h> int   fact ( int ); void   main () {      int   n ;      printf ( "Enter the number : " );      scanf ( " %d " ,& n );   ...

C program to display the upper triangle and lower triangle of the given square Matrix using function

 C program to display the upper triangle and lower triangle of the given square Matrix using function     In this example, we will display the upper triangle and lower triangle of a given square matrix using function. Here in the output section we have taken a 3x3 matrix whose values are entered as shown in the output. After entering the elements of the square matrix it will display the upper triangle and lower triangle of the matrix entered. PROGRAM TO DISPLAY THE UPPER TRIANGLE AND LOWER TRIANGLE OF THE GIVEN SQUARE MATRIX USING FUNCTION #include <stdio.h> #include <conio.h> void  uppert( int , int , int  [100][100]); void  lowert( int , int , int  [100][100]); void  main() {      int  i,j,c,d,a[100][100];     printf( "Enter the size of the given square matrix : " );     scanf( "%d" ,&c);     d=c; ...

C Program to find the sum of the series 1^2+2^2+3^2+…..+n^2

C Program to find the sum of the series  1 2 +2 2 +3 2 +…..+n 2 Enter the end limit at the runtime.       In this example, we calculate the sum of the above mentioned series till the end-limit entered by the user. We have used built-in function pow(x,y) to find the power of the given number.     Here in the output we have entered the value of end-limit as number 7 which gives a sum of 140.    PROGRAM #include <stdio.h> #include <math.h> #include <conio.h> void   main () {      int  n,sum= 0 ,i;      printf ( "Enter the end limit :" );      scanf ( " %d " ,&n);      for (i= 1 ;i<=n;i++)     {         sum=sum+ pow (i, 2 );     }      printf ( "Sum of the series is :  %d " ,sum);  ...