|
| annelisse (3) | |
| please help my lab practical... enter 10 integers and display only odd number in a row. use for loop. | |
| Grey Wolf (1609) | |
| 1 Post what you have so far and you may get some help. 2 Only post your question in one forum | |
| chrisname (2545) | |
| Perhaps I shouldn't tell him/her how... Just a hint then, odd numbers can't be divided by 2. I would have thought that was quite easy... | |
Last edited on | |
| loveless (55) | |
| ....you can use % to do it~~~~~ just like chrisname said~~~~~~ odd numbers cannot be divided by 2~~~~~ use % to do it~~~ if the number is even what will be the answers?? if the number is odd what will be the answers?? | |
| ashwani (15) | |
| heres the code #include<iostream.h> void main() { int a[12]; int i; cout<<"enter the numbers"; for(i=0;i<=10;i++) { cin>>a[i]; } for(i=0;i<=10;i++) { if(a[i]%2!==0) cout<<a[i]; } } | |
Last edited on | |
| Grey Wolf (1609) | |||
ashwani,
fail. | |||
| loveless (55) | |||
| =.=''' ashwani~~~~ there is no " !== " ~~~~~~ and it should be
| |||
| helios (6064) | ||
| ||
| loveless (55) | |
| =.=''' ok | |
| Grey Wolf (1609) | |
| That and the fact that the OP want ten numbers and ashwani's code is set to hold 12, takes 11 as input, then works on the first 10. | |
| loveless (55) | |
| ya should declare int a[10] enough | |
| annelisse (3) | |
| ok girls/guys tq very much....thank god next sem i dont take programming. | |
| annelisse (3) | |
| to chrisname i just learn c++ in 2 week so its not easy for me | |
| Aakanaar (166) | |
scratch all of that. My mind isn't fully awake yet this morning. | |
Last edited on | |
| Grey Wolf (1609) | ||
Aakanaar Wrote:
| ||
| Aakanaar (166) | |
| bah.. too early in the morning.. I'm not thinking. a[10] is correct. sorry. | |
This topic is archived - New replies not allowed.
