[prog] Re: more C++
wolf
wolf at wolfrising.net
Sat Dec 13 19:35:30 EST 2003
all suggestions are welcome : ) any bad habits I can straighten out
from the get go
are a good thing : )
thank you! : )
On Dec 13, 2003, at 6:30 PM, Akkana Peck wrote:
> wolf writes:
>> Well this works but I got the answer via trial and error : )
>> Could anyone help explain very fundamentally why it works when I
>> comment out the one line? : )
>
> Other people have already answered, but can I add one suggestion?
>
> I notice you're not using any indentation anywhere in your program.
> That makes it really hard to see the logic flow (things like which
> clauses should be inside the "if", which should be inside the "else"
> and so forth.
>
> Using an editor which understands C/C++ indentation (emacs does, vim
> can be made to with the right combination of options, perhaps there
> are others) or running the source code through an indentation program
> like "indent" would have shown the problem right away.
>
> I know it's somewhat daunting to learn a whole new editor (especially
> a fairly full-featured one like emacs or vim) and you might not want
> to do that right now; but using "indent" is fairly easy, and getting
> in the habit of indenting your code is something you'll need later if
> you ever want to collaborate with other programmers.
>
> ...Akkana
>
>> #include <iostream>
>>
>>
>> int main()
>>
>>
>> {
>>
>> int integer1;
>>
>> std::cout << "Enter a whole number\n";
>> std::cin >> integer1;
>>
>>
>>
>> if(integer1 % 2 == 0)
>>
>> std::cout << "Your number is even." << std::endl;
>>
>>
>> else //(integer1 % 2 !=0)
>>
>>
>> std::cout << "Your number is odd." << std::endl;
>>
>>
>>
>> return 0;
>> }
>>
>> _______________________________________________
>> Programming mailing list
>> Programming at linuxchix.org
>> http://mailman.linuxchix.org/mailman/listinfo/programming
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
>
More information about the Programming
mailing list