New course! Every coder should learn Generative AI!
Try a free lesson+ 1
How and what is the output is this?
long i=0; for(i;i<10;i++) i+=5; cout<<i;
7 Answers
+ 3
#include <iostream>
using namespace std;
int main() {
//How and what is the output is this?
long i;
for(i=0;i<10;i++){
i+=5;//i=0+5=5 ,i=5+1=6(i++),i=6+5=11
//11+1(i++)=12 it will not enter the condition
cout<<i<<" ";}
return 0;
}
+ 1
As you have initialised f=0.01 and you have not initialised 0.01 in if so it is implicitly converting it to double and answer is 0
+ 1
Yes
0
Atul
And for this?
float f=0.01;
if(f==0.01) printf("1");
else printf("0");
0
Atul
int x=3;
while(x++<10)
x+=2;
Printf(x);
0
Atul
U mean if double f=.01 and f==0.01 would have printed 1?
- 1
For Loop is coded wrongly..
I should have integer data type