write a while loop that adds 5 to n for as long as n is smal

write a while loop that adds 5 to n for as long as n is smaller than 15
what would be the value of n at the end of loop if n=3 end of loop
and what would be if n=21

c++ problem

Solution

Answer:

C++ Program :

#include <iostream>

using namespace std;

int main () {

int n;
cout<<\"Enter value of n:\";
cin>>n;


while( n < 15) {

n=n+5;
  
}
cout << \"value of n after operations is : \" << n<< endl;
return 0;
}

Output :

Enter value of n : 3

value of n after operations is : 18

Enter value of n : 21

value of n after operations is : 21

write a while loop that adds 5 to n for as long as n is smaller than 15 what would be the value of n at the end of loop if n=3 end of loop and what would be if

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site