what will be the output of this program?
void main()
{
int a[]={5,10,15};
int i=0,num;
num=a[++i] + ++i +(++i);
printf("%d",num);
}
Answers were Sorted based on User's Feedback
Answer / apekshit jotwani
Answer will be 15.
Consider a[++i]=x
++i=y
++i=z
so v have to evaluate x+y+z
Compiler converts this to postfix as "xy+z+"
so x is put in the stack 1st i=1,x=a[1]=10
Then i=2, 2 is put in the stack
Then x+y is operated = 12
12 is put in the stack.
Then i=3, 3 is put in the stack.
Then 12+3=15,
only 15 is put in the stack. That is the final answer
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / ricky
Garbage Value
num=a[++i] + ++i +(++i);
in this line the last i will be incremented first
so the last ++i will return 1 after that the middle ++i will return 2 now the value of i will change every where in the program now the first ++i will return 3 since the array starts with a[0] and ends at a[2] there is no a[3] and hence it will print garbage value
Is This Answer Correct ? | 5 Yes | 3 No |
Answer / abc
initially i=0;
num=a[++i]+ ++i + ++i;
num=a[1]+2+3
num=10+2+3=15
Is This Answer Correct ? | 1 Yes | 0 No |
Tell me the use of bit field in c language?
atoi, which takes a string and converts it to an integer. write a program that reads lines(using getline), converts each line to an integer using atoi and computes the average of all the numbers read. also compute the standard deviation
matrix multiplication fails introspect the causes for its failure and write down the possible reasons for its failurein c language.
Compare interpreters and compilers.
What is wrong with this declaration?
what does static variable mean?
helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.
What are the standard predefined macros?
What is the output of the following program main();{printf ("chennai""superkings"}; a. Chennai b. superkings c. error d. Chennai superkings
Why do we use int main instead of void main in c?
What is a function in c?
Why is extern used in c?