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



what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

Answer / viswanath

Ans: 15.
Exp: a[++i] means i = 1; so 10 + 2 +3

Is This Answer Correct ?    7 Yes 1 No

what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

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 will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

Answer / soni narula

6

Is This Answer Correct ?    4 Yes 7 No

Post New Answer

More C Code Interview Questions

typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }

1 Answers  


main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcpy(a,b)); } a. “Hello” b. “Hello World” c. “HelloWorld” d. None of the above

4 Answers   Corporate Society, HCL,


#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  


main() { char a[4]="HELLO"; printf("%s",a); }

3 Answers   CSC,


How to use power function under linux environment.eg : for(i=1;i<=n;i++){ pow(-1,i-1)} since it alerts undefined reference to 'pow'.

2 Answers  






PROG. TO PRODUCE 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

1 Answers  


main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

2 Answers  


Predict the Output: int main() { int *p=(int *)2000; scanf("%d",2000); printf("%d",*p); return 0; } if input is 20 ,what will be print

2 Answers  


write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details

2 Answers   TCS,


Cluster head selection in Wireless Sensor Network using C programming language.

0 Answers  


Code for 1>"ascii to string" 2>"string to ascii"

1 Answers   Aricent, Global Logic,


what is the output of the below program & why ? #include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); }

6 Answers   CSC, IIIT,


Categories