+ 2
If n value is 5 ,the output should be 1 2 3 4 5 ,n value should be given by the users only, use any condition loops.
2 odpowiedzi
+ 2
Try this(while loop)
#include <iostream>
using namespace std;
int main(){
int i = 1;
int n = 5;
while( i<=n){
cout<<"Value of variable i is: "<<i<<endl;
i++;
}
return 0;
}
+ 1
Try this
#include <iostream>
using namespace std;
int main(){
for(int i=1; i<=6; i++){
cout<<"Value of variable i is: "<<i<<endl;
}
return 0;
}