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

When c language was developed?

1011


How do you search data in a data file using random access method?

1258


Explain what is wrong in this statement?

1070


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

2205


What is a macro in c preprocessor?

1056


Why is c used in embedded systems?

1065


In a switch statement, explain what will happen if a break statement is omitted?

999


Explain how can you tell whether two strings are the same?

973


Can i use “int” data type to store the value 32768? Why?

1146


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

1050


How to get string length of given string in c?

1014


How do you initialize pointer variables?

1034


What is the function of multilevel pointer in c?

1031


Distinguish between actual and formal arguments.

1014


When should a type cast not be used?

1008