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

