Results 1 to 6 of 6

Thread: What is the program to print table of given number?

  1. #1
    Join Date
    Nov 2009
    Posts
    1,118

    What is the program to print table of given number?

    Hi Friends,

    Please help me to sort out my problem regarding program code. I have to write the program which will display the table of the given number. I have tried this but my program code is giving unexpected output.

    For example while the execution of the program if I pass five then it should print the table of five.

    Your help will be appreciable..

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: What is the program to print table of given number?

    Hi,

    I recommend you to use "While" loop in your program to print table of given number. Because "While" loop is much easier than "for" loop. For your convenience see the below program code:

    Program:


    void main()
    {
    int p,a,k,x;
    cout<<"provide the number to generate its table";
    cin>>x;
    cout<<"provide the number (table)";
    cin>>m;
    k=1;
    while(k<=a)
    {
    p=x*k;
    cout<<<"*"<<<"="<
    k++;
    }
    getch();
    }

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: What is the program to print table of given number?

    Dear friend,

    Have you tried below logic to print table of given number?

    Following program code is running successfully on my machine. I hope it will also works for you also.

    Please try to run the below code:

    ]

    # include <conio.h>

    void main()
    {

    clrscr ();
    int p;

    count << “ enter the number of which you want to print the table: “ ;
    cin >> p;
    count << p << “ * 1 = “ << p* 1 <
    count << p << “ * 2 = “ << p* 2 <
    count << p<< “ * 3 = “ << p* 3 <
    count << p<< “ * 4 = “ << p* 4 <
    count << p<< “ * 5 = “ << p* 5 <
    count << p<< “ * 6 = “ << p* 6 <
    count << p<< “ * 7 = “ << p* 7 <
    count << p<< “ * 8 = “ << p* 8 <
    count << p<< “ * 9 = “ << p* 9 <
    count << p<< “ * 10 = “<< p*10 <
    getch();

    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: What is the program to print table of given number?

    Hi friend,

    To solution for your problem is very easy. I have C program which displays the table of given number.

    In this program first I accepted the number , then I used "For" loop to check condition, then I applied formula to calculate the table.

    program:

    #include<conio.h>

    #include<stdio.h>


    void main()


    {


    int a,num1;



    printf("Enter number");

    scanf("%d",&num1);

    for(a=1;a<=num1;a++)


    printf("%d*%d=%d",num1,a,num1*a);

    getch();

    }

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: What is the program to print table of given number?

    Please use below logic in your program of printing table of given number:

    for(int l=1;l<=10;l++)

    {

    d=number*l

    }
    I hope it will solve your porplem..

  6. #6
    Join Date
    Sep 2011
    Posts
    1

    Re: What is the program to print table of given number?

    void main()
    {

    int a,b,i=0;

    printf("Enter the number: ");
    scanf("%d",&a);

    while(i<11)
    {
    b=a*i;
    printf("\n%d",b);
    i++;
    }
    getch();
    }

Similar Threads

  1. What is the way to sum up number of column in Pivot Table
    By Dvimida in forum MS Office Support
    Replies: 2
    Last Post: 09-02-2012, 07:31 PM
  2. Need C program to print triangle of character or number
    By Khan Baba in forum Software Development
    Replies: 5
    Last Post: 17-09-2011, 04:40 PM
  3. Print multiplication table
    By MaryJ in forum Software Development
    Replies: 1
    Last Post: 19-11-2010, 10:26 PM
  4. Print Nx2 square table
    By MaryJ in forum Software Development
    Replies: 1
    Last Post: 19-11-2010, 10:16 PM
  5. program to print prime factor of given number
    By teena_pansare in forum Software Development
    Replies: 4
    Last Post: 27-11-2009, 10:21 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,644,769.91857 seconds with 17 queries