Write a short code using c++ to print out all odd number from 1 to 100 using a for loop



Write a short code using c++ to print out all odd number from 1 to 100 using a for loop..

Answer / Krishan Kumar

Here is a simple C++ code snippet that prints all odd numbers from 1 to 100 using a for loop:nn```cppnfor(int i = 1; i <= 100; ++i) {n if(i % 2 != 0) {n std::cout << i << ' ';n }n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is class invariant?

1 Answers  


What is an incomplete type in c++?

1 Answers  


What are virtual functions in c++?

1 Answers  


What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00

1 Answers  


#include<iostream.h> void main() { class x { public: int func(int) { cout<<"cool"; return 1; } } }

1 Answers   Infosys,


What is the output of the following program? Why?

1 Answers  


What happens when the extern "c" char func (char*,waste) executes?

1 Answers  


What is the prototype of printf function?

1 Answers  


write a program that takes 5 digit no and calculate 2 power that no and print it.

3 Answers  


Incase of a function declaration, what is extern means?

1 Answers  


What is a template in c++?

4 Answers  


Can member functions be private?

1 Answers  


Categories