Can someone help me make this work pls??. Thanks! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone help me make this work pls??. Thanks!

I would need an answer for all 3 integers.

11th Jan 2017, 2:00 PM
Dan Hernandez
Dan Hernandez - avatar
9 Answers
+ 7
Can you post your code that you're having trouble with? Thanks!
11th Jan 2017, 2:09 PM
Caleb Jore
Caleb Jore - avatar
+ 7
I hate to say this, but I really don't know. 2686816 shouldn't be the correct answer... This is a really interesting code! Post another question. Say that the first person to explain what is happening will get all their codes upvoted by you.
11th Jan 2017, 2:38 PM
Caleb Jore
Caleb Jore - avatar
+ 6
@Dan, you never declared a value for int c. Is that your problem? Or, is your problem getting it to print?
11th Jan 2017, 2:17 PM
Caleb Jore
Caleb Jore - avatar
+ 6
Well let's see... To start with int i and int x were never defined. if you write c++ instead of i++, you get 2686816 as the value of int c. I could probably help more if you tell me what you're trying to accomplish. Are you making an actual program, or are you just testing things?
11th Jan 2017, 2:30 PM
Caleb Jore
Caleb Jore - avatar
0
#include <iostream> using namespace std; int main() { int a = 0; int b = 0; int c; while(a<3){ b = b+5; a++;} return 0; }
11th Jan 2017, 2:14 PM
Dan Hernandez
Dan Hernandez - avatar
0
lol of course
11th Jan 2017, 2:14 PM
Dan Hernandez
Dan Hernandez - avatar
0
@caleb. well that was the question. to find the proper answer for a,b,c. and when I write cout for all of them I get some type of answer. I just want to know if someone knows a different way to get an answer . this is how I tried to solve it. #include <iostream> using namespace std; int main() { int a = 0; int b = 0; int c; while(i<3){ x = x+5; i++;} cout << a << endl; cout << b << endl; cout << c << endl; return 0; }
11th Jan 2017, 2:24 PM
Dan Hernandez
Dan Hernandez - avatar
0
I'm just testing things. I had originally write them with i and x and i forgot to change them to abc . 2686816 is also what I get. so, that result would be correct? (I corrected the code)
11th Jan 2017, 2:35 PM
Dan Hernandez
Dan Hernandez - avatar
0
thanks will do!
11th Jan 2017, 2:40 PM
Dan Hernandez
Dan Hernandez - avatar