0

Why this code prints "Hello" 4 times ?

#include <iostream> using namespace std; int main() { int i; for(i==1;i<=3;i++) { cout<<"Hello"<<endl; } return 0; } /* I know how to print hello 3 times. But I just want to know why the above one prints "Hello" 4 times ??? */

29th Dec 2021, 11:31 AM
Jainil Raval
Jainil Raval - avatar
2 odpowiedzi
+ 3
because of i==1 so it takes i=0 by default
29th Dec 2021, 11:33 AM
Ratnapal Shende
Ratnapal Shende - avatar
+ 1
Ratnapal Shende Thanks for telling 🙏
29th Dec 2021, 11:41 AM
Jainil Raval
Jainil Raval - avatar