+ 1
Can i use the if statement to
print a number from 1 to 9.. how plis help
5 Answers
+ 4
for(int i=1;i<=9;i++){
cout<<i<<endl;
}
+ 2
int main(){
static int i=1;
if(i<=9){
cout<<i<<endl;
i++;
main();
}
return 0;
}
0
for(int i=1;i<10;i++)
{cout<<i<<endl;
}
0
yes. using recursion.
void foo(int n){
if(n<10){
cout<<n<<" ";
foo(n+1);
}
else return;
}
call it as foo(1) from main()
- 4
dumbass not using the for statement