Answer to Question #284200 in C++ for Soumen

Question #284200

Design an algorithm which gets a natural value, n, as its input and calculates odd numbers 

equal or less than n. Then write them in the standard output.


1
Expert's answer
2022-01-02T02:20:25-0500
#include<iostream>

using namespace std;

int main()
{
	int num;
	cout << "Please, enter a value: ";
	cin >> n;
	cout << "All odd numbers are\n";
	for (int i = 0; i <= n; i++)
	{
		if (i % 2 == 1)
			cout << i << endl;
	}
}

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