Write C++ program that prints all the values of a variable called i that are multiple of 2 and less than 40. Set i =1
//Program to prints all the values of a variable called i
//that are multiple of 2 and less than 40. Set i =1
Â
// the preprocessing directives
#include <iostream>
using namespace std;
Â
int main() {
// declare and initialize variable
  int i=1;
 Â
  // loop i=1 and less than 40
  for(i=1; i<40; i++)Â
        if(i%2==0)         // if multiple of 2
           cout<<i<<' ';   // print i
Â
  cout<<endl;
   return 0;
}
Comments
Leave a comment