Answer to Question #1496 in C++ for idaira

Question #1496
Write a C++ program that prompts the user to enter 10 positive integers and your program will display only all the odd numbers in a row. Use for loop(s) for the repetitive processes.
1
Expert's answer
2011-02-07T09:31:39-0500
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
int numbers[10];
cout << "Input 10 integer values:" << endl;
for(int i = 0; i < 10; i++)
{
cin >> *(numbers + i);
}
cout << "Odd input values:" << endl;
for(int i = 0; i < 10; i++)
{
if(*(numbers + i) & 1)
{
cout << *(numbers + i) << " ";
}
}
cout << endl;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS