- #1
MathematicalPhysicist
Gold Member
- 4,699
- 372
my assignment is as follows:
write a programme printing a reasonably sized table of powers, in a nice format. using %nd in printf will write an integer in at least n charcaters. this facilitates printing tables with aligned columns.
here's my code:
now i want to align them in a table, so I am not sure how to use here %nd, any help would be appreciated.
write a programme printing a reasonably sized table of powers, in a nice format. using %nd in printf will write an integer in at least n charcaters. this facilitates printing tables with aligned columns.
here's my code:
Code:
#include <stdio.h>
#define STOP 10
int base()
{
int input1;
printf("enter the power to which you want to raise the base \n");
printf("enter %d to stop \n", STOP);
scanf("%d", &input1);
return(input1);
}
main()
{
int c,m=1,p=1,b=base();
while (b<STOP){
while(m<STOP){
p=p*b;
printf("\n %d", p);
m+=1;
}
p=1;
m=1;
b+=1;
}
}