SAMPLE PAPER FOR PLACEMENT IN SASKEN TECHNOLOGIES

Jan 5 • General • 1221 Views • No Comments on SAMPLE PAPER FOR PLACEMENT IN SASKEN TECHNOLOGIES

SAMPLE  PAPER  FOR  PLACEMENT  IN  SASKEN  TECHNOLOGIES

1.What are the different types of real data type in C ?
A.float, doubleB.short int, double, long int
C.float, double, long doubleD.double, long int, float

Answer & ExplanationAnswer: Option C

Explanation:

The floating point data types are called real data types. Hence float, double, andlong double are real data types.

2.  If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)?

#include<stdio.h>

#include<math.h>

int main()

{

float a=5.375;

char *p;

int i;

p = (char*)&a;

for(i=0; i<=3; i++)

printf(“%02x\n”, (unsigned char)p[i]);

return 0;

}

A.40 AC 00 00B.04 CA 00 00
C.00 00 AC 40D.00 00 CA 04

Answer & Explanation

Answer: Option C

 

3.  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)D.Error: we can’t divide

Answer & Explanation

Answer: Option C

Explanation:

fmod(x,y) – Calculates x modulo y, the remainder of x/y.
This function is the same as the modulus operator. But fmod() performs floating point divisions.

Example:

 

#include <stdio.h>

#include <math.h>

 

int main ()

{

printf (“fmod of 5.5 by 1.3 is %lf\n”, fmod (5.5, 1.3) );

return 0;

}

Output:
fmod of 5.5 by 1.3 is 0.300000

 

4.  How many bytes are occupied by near, far and huge pointers (DOS)?
A.near=2 far=4 huge=4B.near=4 far=8 huge=8
C.near=2 far=4 huge=8D.near=4 far=4 huge=8

Answer & Explanation

Answer: Option A

Explanation:

near=2, far=4 and huge=4 pointers exist only under DOS. Under windows and Linux every pointers is 4 bytes long.

5.   A pointer is
A.A keyword used to create variables
B.A variable that stores address of an instruction
C.A variable that stores address of other variable
D.All of the above

Answer & Explanation

Answer: Option C

6.  How will you free the allocated memory ?
A.remove(var-name);B.free(var-name);
C.delete(var-name);D.dalloc(var-name);

Answer & Explanation

Answer: Option B

7.  What is the similarity between a structure, union and enumeration?
A.All of them let you define new values
B.All of them let you define new data types
C.All of them let you define new pointers
D.All of them let you define new structures

Answer & Explanation

Answer: Option B

 

8.  In which numbering system can the binary number 1011011111000101 be easily converted to?
A.Decimal systemB.Hexadecimal system
C.Octal systemD.No need to convert

Answer & Explanation

Answer: Option B

Explanation:

Hexadecimal system is better, because each 4-digit binary represents one Hexadecimal digit.

 

9.  Which bitwise operator is suitable for turning off a particular bit in a number?
A.&& operatorB.& operator
C.|| operatorD.! operator

Answer & Explanation

Answer: Option B

 

10.  Assuming, integer is 2 byte, What will be the output of the program?

#include<stdio.h>

 

int main()

{

printf(“%x\n”, -1>>1);

return 0;

}

A.ffffB.0fff
C.0000D.fff0

Answer & Explanation

Answer: Option A

Explanation:

Negative numbers are treated with 2’s complement method.

1’s complement: Inverting the bits ( all 1s to 0s and all 0s to 1s)
2’s complement: Adding 1 to the result of 1’s complement.

Binary of 1(2byte)     :  0000 0000 0000 0001

Representing -1:

1s complement of 1(2byte)    : 1111 1111 1111 1110

Adding 1 to 1’s comp. result : 1111 1111 1111 1111

Right shift 1bit(-1>>1): 1111 1111 1111 1111 (carry out 1)

Hexadecimal            : f   f    f    f

(Filled with 1s in the left side in the above step)

Note:

1. Fill with 1s in the left side for right shift for negative numbers.
2. Fill with 0s in the right side for left shift for negative numbers.
3. Fill with 0s in the left side for right shift for positive numbers.
4. Fill with 0s in the right side for left shift for positive numbers.

 

11.  Which of the following statements are correct about the program?

#include<stdio.h>

 

int main()

{

unsigned int num;

int i;

scanf(“%u”, &num);

for(i=0; i<16; i++)

{

printf(“%d”, (num<<i & 1<<15)?1:0);

}

return 0;

}

A.It prints all even bits from num
B.It prints all odd bits from num
C.It prints binary equivalent num
D.Error

Answer & Explanation

Answer: Option C

Explanation:

If we give input 4, it will print 00000000 00000100 ;

If we give input 3, it will print 00000000 00000011 ;

If we give input 511, it will print 00000001 11111111 ;

 

12.  What will be the output of the program?

#include<stdio.h>

#include<stdlib.h>

 

int main()

{

int *p;

p = (int *)malloc(20); /* Assume p has address of 1314 */

free(p);

printf(“%u”, p);

return 0;

}

A.1314B.Garbage value
C.1316D.Random address

Answer & Explanation

Answer: Option A

 

13.  Which of the following statement is correct prototype of the malloc() function in c ?
A.int* malloc(int);
B.char* malloc(char);
C.unsigned int* malloc(unsigned int);
D.void* malloc(size_t);

Answer & Explanation

Answer: Option D

 

14.  Can I increase the size of statically allocated array?
A.YesB.No

Answer & Explanation

Answer: Option B

 

15.  What will be the output of the program?

#include<stdio.h>

 

int main()

{

int i;

i = printf(“How r u\n”);

i = printf(“%d\n”, i);

printf(“%d\n”, i);

return 0;

}

A.How r u
7
2
B.How r u
8
2
C.How r u
1
1
D.Error: cannot assign printf to variable

Answer & Explanation

Answer: Option B

Explanation:

In the program, printf() returns the number of charecters printed on the console

i = printf(“How r u\n”); This line prints “How r u” with a new line character and returns the length of string printed then assign it to variable i.
So i = 8 (length of ‘\n’ is 1).

i = printf(“%d\n”, i); In the previous step the value of i is 8. So it prints “8” with a new line character and returns the length of string printed then assign it tovariable i. So i = 2 (length of ‘\n’ is 1).

printf(“%d\n”, i); In the previous step the value of i is 2. So it prints “2”.

 

16.  Point out the error in the following program.

#include<stdio.h>

 

int main()

{

fprintf(“IndiaBIX”);

printf(“%.ef”, 2.0);

return 0;

}

A.Error: unknown value in printf() statement.
B.Error: in fprintf() statement.
C.No error and prints “IndiaBIX”
D.No error and prints “2.0”

Answer & Explanation

Answer: Option B

Explanation:

Declaration Syntax:
int fprintf (FILE *stream, const char *format [, argument, …]);

Example:
fprintf(filestream, “%s %d %s”, Name, Age, City);

 

17.  What will be the output of the program?

#include<stdio.h>

int main()

{

int i=0;

for(; i<=5; i++);

printf(“%d,”, i);

return 0;

}

A.0, 1, 2, 3, 4, 5B.5
C.1, 2, 3, 4D.6

Answer & Explanation

Answer: Option D

Explanation:

Step 1: int i = 0; here variable i is an integer type and initialized to ‘0’.
Step 2: for(; i<=5; i++); variable i=0 is already assigned in previous step. The semi-colon at the end of this for loop tells, “there is no more statement is inside the loop”.

Loop 1: here i=0, the condition in for(; 0<=5; i++) loop satisfies and then i is incremented by ‘1’(one)
Loop 2: here i=1, the condition in for(; 1<=5; i++) loop satisfies and then i is incremented by ‘1’(one)
Loop 3: here i=2, the condition in for(; 2<=5; i++) loop satisfies and then i is incremented by ‘1’(one)
Loop 4: here i=3, the condition in for(; 3<=5; i++) loop satisfies and then i is increemented by ‘1’(one)
Loop 5: here i=4, the condition in for(; 4<=5; i++) loop satisfies and then i is incremented by ‘1’(one)
Loop 6: here i=5, the condition in for(; 5<=5; i++) loop satisfies and then i is incremented by ‘1’(one)
Loop 7: here i=6, the condition in for(; 6<=5; i++) loop fails and then i is not incremented.

Step 3: printf(“%d,”, i); here the value of i is 6. Hence the output is ‘6’.

 

18.  A short integer is at least 16 bits wide and a long integer is at least 32 bits wide.
A.TrueB.False

Answer & Explanation

Answer: Option A

Explanation:

The basic C compiler is 16 bit compiler, below are the size of it’s data types
The size of short int is 2 bytes wide(16 bits).
The size of long int is 4 bytes wide(32 bits).

19.  What will be the output of the program in 16 bit platform (Turbo C under DOS)?

#include<stdio.h>

 

int main()

{

int fun();

int i;

i = fun();

printf(“%d\n”, i);

return 0;

}

int fun()

{

_AX = 1990;

}

A.Garbage valueB.0 (Zero)
C.1990D.No output

Answer & Explanation

Answer: Option C

Explanation:

Turbo C (Windows): The return value of the function is taken from the Accumulator_AX=1990.

But it may not work as expected in GCC compiler (Linux).

 

20.  Which of the following is correct way to define the function fun() in the below program?

#include<stdio.h>

 

int main()

{

int a[3][4];

fun(a);

return 0;

}

A.

void fun(int p[][4])

{

}

B.

void fun(int *p[4])

{

}

C.

void fun(int *p[][4])

{

}

D.

void fun(int *p[3][4])

{

}

Answer & Explanation

Answer: Option A

Explanation:

void fun(int p[][4]){ } is the correct way to write the function fun(). while the others are considered only the function fun() is called by using call by reference.

 

 

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published. Required fields are marked *

« »