| View previous topic :: View next topic |
| Author |
Message |
Coldie ;] Guest
|
Posted: Fri Feb 12, 2016 12:54 am Post subject: Help would be desired! |
|
|
I've decided to teach myself how to code, despite disliking it.. and sucking at it.
I'm just following an online text book, I'm curious why this is not staying open when I compile it. I know I'm missing a line of code somewhere, just unsure where.
| Code: | #include <stdio.h>
int main () {
int n = 0;
int s = n * n;
int c = n * n * n;
int t = n + s + c;
printf("n s c t\n");
while ( n <= 100 ) {
s = n * n; //square
c = (n * n) * n; // cube
t = n + s + c; // sum of all
printf("%d %d %d %d\n", n, s, c, t);
n++;
}
return 0;
} |
edit: I'm an idiot, I forgot scanf.
Leaving it here to show disgrace to my family.
edit2:
Actually the correct answer was..
cin.get();
I've got a long way to go.
edit3:
Actually the problem was with the compiler I was using.
|
|
| Back to top |
|
 |
deleted19776 I post too much
Reputation: 11
Joined: 29 Apr 2007 Posts: 3838
|
Posted: Fri Feb 12, 2016 7:06 am Post subject: |
|
|
| Well, glad you found out your problem.
|
|
| Back to top |
|
 |
AverageAzn247 Grandmaster Cheater
Reputation: 34
Joined: 01 Oct 2007 Posts: 909 Location: Austin,TX with 72 virgins
|
Posted: Fri Feb 12, 2016 7:03 pm Post subject: |
|
|
what kind of book are you using? I have never seen a while loop written like that most while loops r written
| Code: | | while (initialize var; how long the var runs till; and var ++) |
_________________
| Waxxup wrote: | What are Night Elves?
A girl group? |
|
|
| Back to top |
|
 |
|