Best site for GRE, LSAT, SAT, GMAT, TOEFL, CCNA, CCSA and interview sample questions

Technical Sample Questions : C |  C++ |  Oracle |  Java | Unix |  Operating Systems |  Data Structure

# C Sample Question

1. ```struct point
{
int x;
int y;
};
struct point origin,*pp;
main()
{
pp=&origin;
printf("origin is(%d%d)\n",(*pp).x,(*pp).y);
printf("origin is (%d%d)\n",pp->x,pp->y);
} ```

origin is(0,0)
origin is(0,0)

Explanation:

pp is a pointer to structure. we can access the elements of the structure either with arrow mark or with indirection operator.

Note:

Since structure point is globally declared x & y are initialized as zeroes
2. ```main()
{
int i=_l_abc(10);
printf("%d\n",--i);
}
int _l_abc(int i)
{
return(i++);
}```

9

Explanation:

return(i++) it will first return i and then increments. i.e. 10 will be returned.
3. ```main()
{
char *p;
int *q;
long *r;
p=q=r=0;
p++;
q++;
r++;
printf("%p...%p...%p",p,q,r);
}```

0001...0002...0004

Explanation:

++ operator when applied to pointers increments address according to their corresponding data-types.
4. ```main()
{
char c=' ',x,convert(z);
getc(c);
if((c>='a') && (c<='z'))
x=convert(c);
printf("%c",x);
}
convert(z)
{
return z-32;
}```

Compiler error

Explanation:

declaration of convert and format of getc() are wrong.
5. ```main(int argc, char **argv)
{
printf("enter the character");
getchar();
sum(argv[1],argv[2]);
}
sum(num1,num2)
int num1,num2;
{
return num1+num2;
}```

Compiler error.

Explanation:

argv[1] & argv[2] are strings. They are passed to the function sum without converting it to integer values.

« Previous || Next »

C Sample Question Number : 1-3 | 4-7 | 8-11 | 12-16 | 17-21 | 22-25 | 26-30 | 31-35 | 36-40 | 41-45 | 46-48 | 49-52 | 53-59 | 60-64 | 65-69 | 70-74 | 75-79 | 80-83 | 84-87 | 88-91 | 92-95 | 96-100 | 101-105 | 106-110 | 111-115 | 116-120 | 121-125 | 126-130 | 131-135 | 136-140 | 141-145 | 146-150

Sample Test Questions
GRE Sample Questions
CAT Sample Questions
GMAT Sample Questions
TOEFL Sample Questions
ACT Sample Questions
SAT Sample Questions
LSAT Sample Questions
PSAT Sample Questions
MCAT Sample Questions
PMP Sample Questions
GED Sample Questions
ECDL Sample Questions
DMV Sample Questions
CCNA Sample Questions
MCSE Sample Questions
Network+ Sample Questions
A+ Sample Questions
Technical Sample Questions
WASL Sample Questions
CISA Sample Questions