Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



What is the program to print table of given number?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 27-11-2009
Member
 
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..

Reply With Quote
  #2  
Old 27-11-2009
Member
 
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:

Quote:

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();
}
Reply With Quote
  #3  
Old 27-11-2009
Member
 
Join Date: May 2008
Posts: 2,007
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:

Quote:
]

# 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();

}
Reply With Quote
  #4  
Old 27-11-2009
Member
 
Join Date: Apr 2008
Posts: 2,000
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:
Quote:

#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();

}
Reply With Quote
  #5  
Old 27-11-2009
Member
 
Join Date: May 2008
Posts: 2,291
Re: What is the program to print table of given number?

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

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

{

d=number*l

}
I hope it will solve your porplem..
Reply With Quote
  #6  
Old 04-09-2011
Member
 
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();
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 02:34 AM.