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
What is ambagious result in C? explain with an example.
What is strcmp in c?
Can we use any name in place of argv and argc as command line arguments?
What are the ways to a null pointer can use in c programming language?
What is the purpose of the preprocessor directive error?
What is the use of ?: Operator?
Explain c preprocessor?
how should functions be apportioned among source files?
Explain how can you tell whether two strings are the same?
What do mean by network ?
Is it acceptable to declare/define a variable in a c header?
Why c is called free form language?
In which language linux is written?
How can I write a function that takes a format string and a variable number of arguments?
What happens if you free a pointer twice?