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 / viswanath
Ans: 15.
Exp: a[++i] means i = 1; so 10 + 2 +3
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / nandkishor
Ans: 19.
Explanation: First expression (++i) execute. Hence i=1;
Than a[++i]=a[2]=15.
And than ++i=3.
Hence evaluation will be 15+3+1=19.
Note that expression closed in braces have high precedence.
| Is This Answer Correct ? | 0 Yes | 0 No |
how to swap 3 nos without using temporary variable
main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }
Write a function to find the depth of a binary tree.
13 Answers Adobe, Amazon, EFI, Imagination Technologies,
void main() { int *i = 0x400; // i points to the address 400 *i = 0; // set the value of memory location pointed by i; }
Design an implement of the inputs functions for event mode
#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }
main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }
Develop a routine to reflect an object about an arbitrarily selected plane
How to read a directory in a C program?
main() { struct date; struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }
main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }