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 |
What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }
how to swap 3 nos without using temporary variable
4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }
Printf can be implemented by using __________ list.
Write a program to print a square of size 5 by using the character S.
What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }
main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }
main() { extern int i; i=20; printf("%d",i); }
void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }
Finding a number which was log of base 2