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...

main()
{
int i = 1;
int num[] = {1,2,3,4};
num[i] = i++;
printf("%d", num[i]);
}

what will be the output?
}

Answer Posted / james holdcroft

The output will be 1 or 3, depending on the compiler.

Quoting from "The C Programming Language, Second Edition"
by Kernighan and Ritchie:

C, like most languages, does not specify the order in which
operands of an operator are evaluated. (The exceptions are
&&, ||, ?:, and ','.)
...
One unhappy situation is typified by the statement
a[i] = i++;
The question is whether the subscript is the old value of i
or the new. Compilers can interpret this in different
ways, and generate different answers depending on their
interpretation.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is memcpy() function?

1126


Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.

2079


What is the use of linkage in c language?

1067


can any one tel me wt is the question pattern for NIC exam

1990


Explain what is wrong in this statement?

1125


What is quick sort in c?

1094


What are types of preprocessor in c?

1076


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

1418


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

1073


What is the difference between NULL and NUL?

1297


Is malloc memset faster than calloc?

1075


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1590


How can you access memory located at a certain address?

1121


Explain pointers in c programming?

1121


How can I prevent another program from modifying part of a file that I am modifying?

1061