Answer to Question #185805 in C++ for Chathu

Question #185805

The loop shown below has been written by a c++ programmer

int =1; //A

while (n>=1){

if(condition){ //B

//C

}

n--;

}


1)Update the value of the variable n to repeat the loop 10 times.

2)Write the condition Statement to select only odd numbers

3)Rewrite the code with the statement n++ (You can only add or modify statement A,B,C)


1
Expert's answer
2021-04-26T07:48:04-0400
1) int n = 10


2) if(n%2 == 1)


3) int n = 1; //A
    while (n>=1){
      if(n > 1){ //B
      break;//C
      }
    n++;
    }

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