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. In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'.
```main(){
int * j;
void fun(int **);
fun(&j);
}
void fun(int **k) {
int a =0;
}```

*k = &a

Explanation:

The argument of the function is a pointer to a pointer.
2. What are the following notations of defining functions known as?
1. int abc(int a,float b)
{
/* some code */
}
2. int abc(a,b)
int a; float b;
{
/* some code*/
}

i. ANSI C notation
ii. Kernighan & Ritche notation (K&R Notation)
3. ```main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);
}```

300
Explanation:
The pointer points to % since it is incremented twice and again decremented by 2, it points to '%d\n' and 300 is printed.
4. ```main(){
char a[100];
a[0]='a';a[1]]='b';a[2]='c';a[4]='d';
abc(a);
}
abc(char a[]){
a++;
printf("%c",*a);
a++;
printf("%c",*a);
}```

Explanation:

The base address is modified only in function and as a result a points to 'b' then after incrementing to 'c' so bc will be printed.

« 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