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

What is ambagious result in C? explain with an example.

2045


What is strcmp in c?

589


Can we use any name in place of argv and argc as command line arguments?

602


What are the ways to a null pointer can use in c programming language?

581


What is the purpose of the preprocessor directive error?

670






What is the use of ?: Operator?

658


Explain c preprocessor?

673


how should functions be apportioned among source files?

616


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

578


What do mean by network ?

646


Is it acceptable to declare/define a variable in a c header?

675


Why c is called free form language?

558


In which language linux is written?

592


How can I write a function that takes a format string and a variable number of arguments?

597


What happens if you free a pointer twice?

594