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 |
Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.
1 Answers Samar State University,
int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().
main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }
main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } }
main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?
main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }
Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.
16 Answers Aricent, Cisco, Directi, Qualcomm,
#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }
main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); }
What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }
void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }
main() { char *p = “ayqm”; char c; c = ++*p++; printf(“%c”,c); }