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 line in c preprocessor?

1053


What is c language and why we use it?

1069


What is the difference between text and binary i/o?

1047


What is the use of clrscr?

1103


What is meant by realloc()?

1138


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1945


When should volatile modifier be used?

1010


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2543


c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above

1256


What is modeling?

1047


What is the right type to use for boolean values in c?

1030


What is variable declaration and definition in c?

898


The difference between printf and fprintf is ?

1281


How can I find the modification date of a file?

1279


What's the best way of making my program efficient?

1101