write a program in c that counts from 1 to any given numberS

write a program in c++ that counts from 1 to any given number

Solution

#include <iostream>

using namespace std;

int main(){
int n;
cout<<\"Enter a number: \";
cin >> n;
for(int i=1; i<=n; i++){
cout<<i<<\" \";
}

return 0;
}

Output:

Enter a number: 5

1 2 3 4 5

write a program in c++ that counts from 1 to any given numberSolution#include <iostream> using namespace std; int main(){ int n; cout<<\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site