How do I print an even number from C++ for loop?

     How can I print an even number program from C++ Using For loop?


  •  C++ is a general-purpose programming language.
  • C++ is a cross-platform language that can be used to create high-performance applications.
  • It was developed by Bjarne Stroustrup.

  1. #include<iostream> 
  2. using namespace std; 
  3. int main() 
  4. { 
  5. int i , num; 
  6. cout<<”Enter a number:\n”; 
  7. cin>>num; 
  8. for(i=1; i<mum; i++) 
  9. { 
  10. if(i%2==0) 
  11. { 
  12. cout<< i << “ ” ;  
  13. } 
  14. } 
  15. return 0; 
  16. } 

The output of the following code is:

Enter a number:

10

expected output: 2 4 6 8

Comments

Popular posts from this blog

proassignment help backlink data index 41

programming shark backink data index 31

Programming shark backlink data index 67