Computer Science, asked by ravibiwalkar, 11 months ago

write a c++ program regarding to given problem
write the program to do following using for and do while loop 1+3+5+7+.....+n the value of n should be accepted from user.

Answers

Answered by sruthikumar2003002
2

Answer:

#include <iostream>

using namespace std;

int main()

{

int num=1;

do{

cout<<"Value of num: "<<num<<endl;

num++;

}while(num<=6);

return 0;

}

Output:

Value of num: 1

Value of num: 2

Value of num: 3

Value of num: 4

Value of num: 5

Value of num: 6

Similar questions