Accenture Previous Years Solved Sample Placement Papers
-
Identify which of the following are declarations
(a) extern int x;
(b) float square (float x) {...}
(c) double pow(double, double);
(d) 1 and 3 (Ans)
-
Which of the following statement obtains the remainder on dividing 5.5 by 1.3?
(a) rem = (5.5 % 1.3)
(b) rem = modf(5.5, 1.3)
(c) rem = fmod(5.5, 1.3) (Ans)
(d) Error: we can't divide
-
What will be the output of the program?
```c
#include
int main() { char c=48; int i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask = mask<<1; } return 0; } ``` (a) 12400
(b) 12480 (Ans)
(c) 12500
(d) 12556
-
Point out the error in the following program.
```c
#include
#include int main() { int *a[3]; a = (int*) malloc(sizeof(int)*3); free(a); return 0; } ``` (a) Error: unable to allocate memory
(b) Error: We cannot store address of allocated memory in a (Ans)
(c) Error: unable to free memory
(d) No error
-
What is the purpose of fflush() function?
(a) Flushes all streams and specified streams (Ans)
(b) Flushes only specified stream
(c) Flushes input/output buffer
(d) Flushes file buffer
-
Point out the error, if any, in the program.
```c
#include
int main() { int a = 10; switch(a) { } printf("This is C program."); return 0; } ``` (a) Error: No case statement specified
(b) Error: No default specified
(c) No Error (Ans)
(d) Error: Infinite loop occurs
-
What will be the output of the program?
```c
#include
int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d, %d\n", k, l); return 0; } ``` (a) 12, 12 (Ans)
(b) 7, 7
(c) 7, 12
(d) 12, 7
-
In C, if you pass an array as an argument to a function, what actually gets passed?
(a) Value of elements in array
(b) First element of the array
(c) Base address of the array (Ans)
(d) Address of the last element of array
-
Out of fgets() and gets(), which function is safe to use?
(a) gets()
(b) fgets() (Ans)
-
In the following code, what is 'P'?
```c
typedef char *charp;
const charp P;
```
(a) P is a constant (Ans)
(b) P is a character constant
(c) P is character type
(d) None of the above