main()

{

int c[ ]={2.8,3.4,4,6.7,5};

int j,*p=c,*q=c;

for(j=0;j<5;j++) {

printf(" %d ",*c);

++q; }

for(j=0;j<5;j++){

printf(" %d ",*p);

++p; }

}



main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { ..

Answer / susie

Answer :

2 2 2 2 2 2 3 4 6 5

Explanation:

Initially pointer c is assigned to both p and q.
In the first loop, since only q is incremented and not c ,
the value 2 will be printed 5 times. In second loop p itself
is incremented. So the values 2 3 4 6 5 will be printed.

Is This Answer Correct ?    46 Yes 9 No

Post New Answer

More C Code Interview Questions

Write a C function to search a number in the given list of numbers. donot use printf and scanf

5 Answers   Honeywell, TCS,


Derive expression for converting RGB color parameters to HSV values

1 Answers  


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

2 Answers  


main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }

6 Answers  


main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }

1 Answers  






main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }

7 Answers  


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

9 Answers   Microsoft,


What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }

1 Answers  


struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); } a. Your Name b. compile error c. Name d. Runtime error

3 Answers   HCL,


main() { int i=10; i=!i>14; Printf ("i=%d",i); }

1 Answers  


main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(ā€œ%dā€ ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(ā€œ%d ā€ ,*p); p++; } }

1 Answers  


int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }

3 Answers   Cisco, HCL,


Categories