Answer to Question #269500 in C++ for ujoo

Question #269500

write a program that counts from zero up to a user-specified number. For example, if the user enters the number 5, your program should display the numbers: 0, 1, 2, 3, 4, 5. You cannot use an if-statement for this part! 


1
Expert's answer
2021-11-21T04:49:22-0500
#include <iostream>
using namespace std;
int main(){
    int input;
    cout<<"Input the specified number: ";
    cin>>input;
    
    for(int i = 0; i <= input;){
        cout<<i++<<" ";
    }
    cout<<endl;
    
    return 0;
}

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