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

main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }

2 Answers  


void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }

1 Answers  


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

0 Answers   Home,


1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.

8 Answers   IBPS, Infosys, TCS,






main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }

1 Answers  


main() { unsigned int i=65000; while(i++!=0); printf("%d",i); }

1 Answers  


What is your nationality?

1 Answers   GoDB Tech,


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

0 Answers   Mbarara University of Science and Technology,


Which one is taking more time and why ? :/home/amaresh/Testing# cat time.c //#include <stdio.h> #define EOF -1 int main() { register int c; while ((c = getchar()) != EOF) { putchar(c); } return 0; } ------------------- WIth stdio.h:- :/home/amaresh/Testing# time ./time_header hi hi hru? hru? real 0 m4.202s user 0 m0.000s sys 0 m0.004s ------------------ Witout stdio.h and with #define EOF -1 =================== /home/amaresh/Testing# time ./time_EOF hi hi hru? hru? real 0 m4.805s user 0 m0.004s sys 0 m0.004s -- From above two case , why 2nd case is taking more time ?

0 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,


# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }

1 Answers  


Categories