i think you have a general idea of how to write the program but alittle bit stuck about using the keywords.
1. the format of an if and else statement is shown below (yours is wrong- you can't place the while statement in between the } and else)
Code:
if (condition) {
statements;
}
else {
statements;
}
2. might want to use a for statement (similar to while) to output your square roots and so on. general form shown below.
Code:
for(initiation; condition; increment) {
statement;
}
here is what i would come up with using some of your code (if you input something that is not a number error will occur)
Code:
#include <stdio.h>
#include <math.h>
int main(void){
int n;
//get your integer
printf("Enter an Integer: ");
scanf("%d", &n);
if (n>0) {
// prints the table of squares, cube and square root
printf("number\tsquare\tcube\tsquareroot\n");
for (n; n >0; --n) {
printf("%d \t%d \t%d \t%.2f\n", n, n*n, n*n*n, sqrt(n));
}
}
else {
printf("Sorry, try inputting a positive number next time.\n");
}
return 0;
}