Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


#include<stdio.h>
int fun();
int i;
int main()
{
while(i)
{
fun();
main();
}
printf("hello \n");
return 0;
}
int fun()
{
printf("hi");
}
answer is hello.how??wat is tat while(i) mean?

Answers were Sorted based on User's Feedback



#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf(..

Answer / vignesh1988i

see first of all variable 'i' is declared as a global
storage class variable .. so according to that storage class
whenever we define an variable i before the main function
and explicatily we haven't initilized that variable means it
will defaultly variable i will have 0....
so when this while is compiled i has 0 which makes the loop
false.. so it will compile the very first statement after
that loop... so it prints hello...........


thank u

Is This Answer Correct ?    18 Yes 0 No

#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf(..

Answer / who cares

I am not an expert but you can try one thing that I did.

Remove the while loop and put the follow

if (i)
printf ( "hi\n" );


The result is that printf statement never gets any print
out! My guess would be because the value of 'i' is NOT
defined so, that while loop doesn't get assess at all! So,
the result is only "hello"

Is This Answer Correct ?    5 Yes 2 No

#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf(..

Answer / parul_kul

As "int i" is not defined/declared inside any function, by
default it is declared as external variable not as auto.
Thats why, it takes the 0 as its default value.

Is This Answer Correct ?    1 Yes 0 No

#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf(..

Answer / agita

in response to the previous answer...

there is no storage class specification for i..so by default
it
is auto..if an auto variable is not initiallized it would
give a garbage value..then how come while(0)....?

Is This Answer Correct ?    1 Yes 1 No

#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf(..

Answer / sudhir kumar sharma

if we try this program in case of above program we will come
to a conclusion that all the variable declared before main
are global and assigned a value by default to zero that's
why the while loop will not executed in the above program :)
#include<stdio.h>
#include<conio.h>
int a;
float b;
double c;
char d;
static int e;

int main()
{
clrscr();
printf("%d\n %f\n %d\n %c\n %d\n",a,b,c,d,e);
getch();
return 0;

Is This Answer Correct ?    0 Yes 0 No

#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf(..

Answer / tatukula

in above program variable 'i' is declared as global integer ..so i=0...thats why while() condition gets failed and
prints 'hello'

Is This Answer Correct ?    0 Yes 0 No

#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf(..

Answer / tanveer ahmed abbasi

hi hello

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

Why does notstrcat(string, "!");Work?

0 Answers  


Should I learn data structures in c or python?

0 Answers  


What is the OOPs concept?

3 Answers  


What is ambagious result in C? explain with an example.

0 Answers   Infosys,


What is an auto variable in c?

0 Answers  


Write a Program to accept different goods with the number, price and date of purchase and display them

0 Answers   HDFC,


write a programming in c language, 1 3 5 7 9 11

2 Answers   NIIT,


Explain can you assign a different address to an array tag?

0 Answers  


What does struct node * mean?

0 Answers  


What is the difference between big endian form and little endian form? write a code to convert big endian form to little endian and vice versa..

5 Answers   Aricent, TCS,


how to make a scientific calculater ?

0 Answers  


What is null in c?

0 Answers  


Categories