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);
}

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to write a multi-statement macro?

711


Can the “if” function be used in comparing strings?

687


Write a C program in Fibonacci series.

730


List a few unconditional control statement in c.

652


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

787






what are the facialities provided by you after the selection of the student.

1774


What does void main return?

712


What is logical error?

715


How can you read a directory in a C program?

739


How to declare a variable?

677


What should malloc(0) do?

712


What is pointer in c?

848


List some of the static data structures in C?

855


What is difference between class and structure?

680


What is the difference between #include

and #include “header file”?

640