1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C programming

Discussion in 'C' started by ROBAODOM, Nov 26, 2011.

  1. ROBAODOM

    ROBAODOM New Member

    Joined:
    Nov 26, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Write a C program to output the following multiplication table of a number,when the inputs are keyed in from the keyboard.

    5x1=5
    5x2=10
    5x3=15
    -------
    -------
    5x10=50
     
  2. pravinkandala

    pravinkandala New Member

    Joined:
    Nov 25, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    yet student!!
    Location:
    Hyderabad, India
    Home Page:
    Code:
    #include<conio.h>
    #include<stdio.h>
    main()
    {
        float a,b,c;
        clrscr();
        printf("enter a and b values\n");
        scanf("%f%f",&a,&b);
        c=a*b;
        printf("Multiplication of a and b is:%f",c);
        getch();
    }
     
  3. pravinkandala

    pravinkandala New Member

    Joined:
    Nov 25, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    yet student!!
    Location:
    Hyderabad, India
    Home Page:
    Output:

    enter a and b values
    5
    1
    Multiplication of a and b is: 5

    //i.e., the number and multiplier , we asume it as a and b
     
  4. newone

    newone New Member

    Joined:
    Jan 12, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int a,b;
    printf("enter value");
    scanf("%d", &a);
    printf("enter value again");
    scanf("%d", &b);
    printf("%d + %d = %d\n", a, b, a*b);
    getch();
    }


    output
    enter value
    5
    enter another value
    1
    5*1=5
     
  5. newone

    newone New Member

    Joined:
    Jan 12, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    For multiplication table of a number,when the inputs are keyed in from the keyboard:

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int a,b;
    printf("enter the values");
    scanf("%d", &a);
    scanf("%2d", &b);
    while(b<=10)
    {
    printf("%d * %2d = %2d\n", a, b, a*b);
    b=b+1;
    }
    getch();
    }

    output
    enter the values
    5
    1
    5*1=5
    5*2=10
    5*3=15
    5*4=20
    5*5=25
    ...........
    ...........
    5*10=50
     
  6. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <limits.h>
    
    int main(void) {
    
       char buf[10] = { 0 };
       int i, num;
    
       do {
    
          /* wait for valid numerical input */
    
          printf("Enter table multiplier: ");
          fgets(buf, sizeof buf, stdin);
    
       } while((sscanf(buf, "%d", &num)) != 1);
    
       for(i=1; (i * num) < INT_MAX; ++i) {
    
          if(i % 10 == 0) {
    	     puts("\npress enter");
    	     getchar(); // pause output
          }
    
          printf("%3d %2c %3d = %3d\n", num, 'X', i, i * num);
       }
    
       return 0;
    }
    :P
     

Share This Page