[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Hi ! I'm new to c++ and whole programming stuff.. I've
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 15
Thread images: 3
File: whythishappentome.png (16 KB, 633x620) Image search: [Google]
whythishappentome.png
16 KB, 633x620
Hi ! I'm new to c++ and whole programming stuff.. I've created small program with loop while. Could you explain me why does this program work but the loop doesnt ? And how can i repair it ?
>>
your return statement is in your while loop.
So your while loop is executed once und then it ends because of the return 0;

Please get better style for braces, then you would have seen your mistake by yourself
>>
Thanks, i will try to
>>
Why are there so many third world shitters on this site now?
>>
As a note you probably want to test your expression AFTER your loop (do while) since the user will always give at least one number.
>>
>>53913278
>var names in shit language
stop that shit right now
>>
>>53913278
The while loop is missing a closing brace. How does Code Blocks not catch this?
>>
>>53913278
>not returning 5 because you are so random
>I shiggy diggy
>>
its my second program actually.
- Var only in english
what else should i remember ?
>>
>>53913396
It's not. Grow some eyes.

>>53913278
Pretty-print your code better, fagtron.

It's people like you that cause Python to be used in introductory classes.

Fags that can't keep their code stylistically clean are why stupid people have so much trouble keeping track of scope.
>>
>>53913427
Programm in english and get a standard stlye for braces
>>
When you test
while(strzal!=liczba)

strzal isn't initialized, like the other anon said you need to use a do while, so you can get a number in and then test it, otherwise it can be any random crap before being initialized
>>
The program terminates inside the while loop, in c++ you don't actually have to explicitly return 0 in the main function
>>
>>53913458
i've tested the do...while and it worked.
but once i've taken out the "return" out of the loop it worked
>>
File: 1459376254336.png (7 KB, 350x305) Image search: [Google]
1459376254336.png
7 KB, 350x305
Indent your code properly.
Thread replies: 15
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.