Hello,
How can i draw a Multiplication Table using 'Arrays' in C language ?
Thank you,
Jessy
How to Draw a Multiplication Table using Arrays in C language ?
I'm writing in C++ (u can convert it in C also, just use 'printf' instead of 'cout' %26amp; use 'scanf' instead of 'cin' , but one thing, u can't include iomanip header file in C to use setw function. Use of setw function'll give u better i.e. formatted output)
//print a table of N from 1 to M
#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
#include%26lt;iomanip.h%26gt;
void main()
{
int n,m,i ;
char cho ;
clrscr() ;
do{
cout%26lt;%26lt;"Enter n %26amp; m" ;
cin%26gt;%26gt;n%26gt;%26gt;m ;
cout%26lt;%26lt;"Table of "%26lt;%26lt;n ;
for(i=1;i%26lt;=m;i++)
cout%26lt;%26lt;endl%26lt;%26lt;setw(3)%26lt;%26lt;n%26lt;%26lt;" x "%26lt;%26lt;setw(3)%26lt;%26lt;i%26lt;%26lt;" = "%26lt;%26lt;setw(3)%26lt;%26lt;n*i ;
cout%26lt;%26lt;"\nContinue? Y/N" ;
cin%26gt;%26gt;cho ;
}while(cho=='Y'||cho=='y') ;
getch() ;
}
Reply:I don't know C...but if you use nested for loops that should work
for (int i = 1; i %26lt;= 10; i++){
for (int j = 1; j %26lt;=10; j++){
array[i][j] = i * j;
}
}
That will create a 10 by 10 block for multiplication table. You'll just need to display it however you need to display it.
Just change the syntax for C.
yu gi oh cards
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment