for(i=0;i=printf("Hello");i++);
printf("Hello");
how many times how will be printed?????????

Answers were Sorted based on User's Feedback



for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be pr..

Answer / ruchi

Infinite times
i =printf("Hello");
here printf("hello") will return 5 i.e i=5 which will always
remain true that's why hello will be printed infinate times.

Is This Answer Correct ?    23 Yes 6 No

for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be pr..

Answer / vignesh1988i

here the basic thing we must understand is that :

printf(); is a function. this printf() always returns the
number of character it processes inside " ".......here it
will return 4 according to me... this will will be assigned
to i and everytime 'i' will be a non zero value always and
also a semicolon is placed after for statement , so compiler
takes that has the next line and PRINTS "HELLO" INFINITELY
since 'i' value is always non zero or always TRUE...

and there is no way for the second printf() to get printed
according to me.........



thank u

Is This Answer Correct ?    18 Yes 5 No

for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be pr..

Answer / navdeep

"Hello" will be printed infinite times

Is This Answer Correct ?    6 Yes 0 No

for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be pr..

Answer / anandi

"Hello" will be printed infinite time.......

Is This Answer Correct ?    6 Yes 2 No

for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be pr..

Answer / shashikanth

Hello wil be printed infinite times

Is This Answer Correct ?    2 Yes 1 No

for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be pr..

Answer / kalyan chukka

Here in the loop it given as i=0;i=printf("Hello");
So Printf function returns how many no of charecters it
printed so it takes 5 so loop is

for (i=0;i=5;i++) so loop will be this
in the above loop first i=0 and then we assign i=5 so loop
will become for(i=5;i++) it becomes infinite loop hello
printed infineite loop.

Is This Answer Correct ?    1 Yes 1 No

for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be pr..

Answer / m.manivel

Hello will be printed infinite times and if u want to print
10 times for put i=10;(or)print for 100 times put i=100;for
user choice

Is This Answer Correct ?    0 Yes 0 No

for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be pr..

Answer / asit mahato

for(i=0;i=printf("Hello");i++);
means
for(i=0;i=printf("Hello");i++)
{

}
thats why it will print Hello only one time.

Is This Answer Correct ?    2 Yes 14 No

Post New Answer

More C Interview Questions

Write a program to swap two numbers without using the third variable?

0 Answers  


What are variables and it what way is it different from constants?

0 Answers  


Main must be written as a.the first function in the program b.Second function in the program c.Last function in the program d.any where in the program

19 Answers   CTS, HCL, TCS,


Read two numbers from keyboard and find maximum of them?

1 Answers  


main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); }

4 Answers   CitiGroup,






What is gets() function?

0 Answers  


Average of a couple 10 years ago was 25. The average remains same after having a child and twins after 3 years. What is the present age of the first child

10 Answers   IBM, Infosys,


Hi Every one...........I have been selected for the SBI Clerk. But i m one month Pregnanat. So anyone please suggest me, is they take any objection on my joining .

4 Answers   State Bank Of India SBI,


Is there any demerits of using pointer?

0 Answers  


how to find anagram without using string functions using only loops in c programming

0 Answers  


will u give me old quesrion papers for aptitude for L & t info tech?

1 Answers   Hindustan, L&T,


write a recursive program in'c'to find whether a given five digit number is a palindrome or not

2 Answers  


Categories