Sunteți pe pagina 1din 36

What is the output of the following program segment?

main()
{
long i = 65536;
printf(%d\n, i);
}
A.

B.

65536

C.

-1

D.

65

Answer A ---------------------------------------------------------------______
The statement that transfers control to the beginning of the loop is called
A.

Break statement

B.

Exit statement

C.

Continue statement

D.

Goto statement

Answer C --------------------What would be output of the following program?


# define SQR(X) (X*X)
main()
{
int a, b=3;

a = SQR(b+2);
printf(\n%d, a);
}

A.

25

B.

11

C.

Error

D.

Garbage value

Answer B --------------------Each C preprocessor directive begins with


A.

B.

include

C.

main

D.

Answer A ---------------------------------------------------------------_
What is the output of the following program segment?
main()
{
int i = ++2;
printf(%d\n, i);
}

A.

B.

C.

D.

-1

Answer A --------------------The loop in which the statements within the loop are executed at least once
is called

A.

Do-while

B.

While

C.

For

D.

Goto

Answer A --------------------Which number system is usually followed in a typical 32-bit computer?

A.

B.

10

C.

16

D.

32

Answer A --------------------The function fprintf is used in a program

A.

When too many printf calls have been already used in the program

B.

In place of printf, since printf uses more memory

C.

When the output is to be printed on to a file

D.

When the type of variables to be printed are not known before

Answer C --------------------What will be the output of the following c-code ?


void main ( )
{
char *P = "ayqm" ;
char c;
c = ++*p ;
printf ("%c", c);
}

A.

B.

C.

D.

Answer A --------------------How many times the following program would print (abc)?
main()
{
printf(\nabc);
main();
}

A.

Infinite number of times

B.

32767 times

C.

65535 times

D.

Till the stack does not overflow

Answer A

If an integer needs two bytes of storage, then the maximum value of


unsigned integer is

A.

216 1

B.

215 1

C.

215

D.

216

Answer A
_____________________________________________________________
________________________
The __________ statement causes immediate exit from the loop overriding
the condition test

A.

Exit

B.

Break

C.

Goto

D.

None of the above

Answer B
_____________________________________________________________
________________________
The following program fragment
int *a;
*a = 7;

A.

assigns 7 to a

B.

results in compilation error

C.

assigns address of a as 7

D.

segmentation fault

Answer D
_____________________________________________________________
________________________
The decimal value 0.5 in IEEE single precision floating point representation
has

A.

fraction bits of 000000 and exponent value of 0

B.

fraction bits of 000000 and exponent value of -1

C.

fraction bits of 100000 and exponent value of 0

D.

no exact representation

Answer C
_____________________________________________________________
________________________

The statement which is used to terminate the control from the loop is

A.

Break

B.

Continue

C.

Goto

D.

Exit

Answer A
_____________________________________________________________
________________________
The value of an automatic variable that is declared but not initialised will be

A.

B.

-1

C.

Unpredictable

D.

None of these

Answer C
_____________________________________________________________
________________________
The _______ memory allocation function modifies the previous allocated
space.

A.

calloc( )

B.

free( )

C.

malloc( )

D.

realloc( )

Answer D
_____________________________________________________________
________________________
Unsigned integer occupies

A.

Two bytes

B.

Four bytes

C.

One byte

D.

Eight bytes

Answer B
_____________________________________________________________
________________________
The value that follows the keyword CASE may only be

A.

Constants

B.

Variable

C.

Number

D.

Semicolon

Answer A
_____________________________________________________________
________________________
Which one of the following sentences is true ?

A.

The body of a while loop is executed at least once.

B.

The body of a do while loop is executed at least once.

C.

The body of a do while loop is executed zero or more times.

D.

A for loop can never be used in place of a while loop.

Answer B
A pointer variable can be

A.

Passed to a function as argument

B.

Changed within function

C.

Returned by a function

D.

Assigned an integer value

Answer C
_____________________________________________________________
________________________
The language that the computer can understand and execute is called

A.

Machine Language

B.

Application Software

C.

System Program

D.

Assembly language

Answer A
_____________________________________________________________
________________________
The expression P >> 6 shifts all bits of P six places to right. What is the
value of P >> 6 if P 0.6db7 ?

A.

0.1234

B.

0.0001

C.

0.0000

D.

0.1B6

Answer D
_____________________________________________________________
________________________
The process of production of customer list in alphabetical order falls under
the category of

A.

Editing

B.

Sorting

C.

Updating

D.

Calculating

Answer B
_____________________________________________________________
________________________
The control automatically passes to the first statement after the loop in

A.

Continue statement

B.

Break statement

C.

Switch statement

D.

If statement

Answer B
_____________________________________________________________
________________________

What would be the output of the following program, if run from the
command line as myprog 1 2 3 ?
main (int argc, char * argv[ ])
{ int i ;
i = argv[1] + argv[2] + argv[3] ;
printf (% d, i) ;
}

A.

123

B.

C.

Error

D.

123

Answer
_____________________________________________________________
________________________
Output of the program given below is
int i;
main()
{
printf(%d, i)

A.

B.

C.

-1

D.

NULL

Answer B
_____________________________________________________________
________________________
Determine which of the following is a valid character constant

A.

\\

B.

\0

C.

xyz

D.

\052

Answer A
_____________________________________________________________
________________________
Is the following statement a declaration or definition? extern int i;

A.

Declaration

B.

Definition

C.

Function

D.

Error

Answer A
_____________________________________________________________
________________________
A template stores
A.

Styles, macros

B.

Auto Text entires, Customized word command Settings

C.

Graphics, text

D.

All of the above

Answer A

Which technology is used in optical disks?

A.

Mechanical

B.

Electrical

C.

Electro Magnetic

D.

Laser

Answer D
_____________________________________________________________
________________________
C is often called

A.

Object oriented language

B.

High level language

C.

Assembly language

D.

Machine level language

Answer B
_____________________________________________________________
________________________
Any integer composed of 3n identical digits divisible by

A.

2n

B.

3n

C.

5n

D.

7n

Answer B
_____________________________________________________________
________________________
The machine registers are sometimes called

A.

Local variables

B.

Global variables

C.

Accumulators

D.

Static variables

Answer A
_____________________________________________________________
________________________
The statement which is used to terminate the control from the loop is

A.

Break

B.

Continue

C.

Goto

D.

Exit

Answer A
_____________________________________________________________
________________________

Which one of the following will set the value of y to 5 if x has the value 3,
but not otherwise ?

A.

if (x = 3) y = 5

B.

if x = = 3 (y = 5)

C.

if (x = = 3); y = 5

D.

if (x = = 3) y = 5

Answer D
_____________________________________________________________
________________________
The maximum value that an integer constant can have is

A.

.32767

B.

32767

C.

1.7014e+38

D.

1.7014e+38

Answer B
_____________________________________________________________
________________________
What would be output of the following program, if the array begins at
65486?
main()
{
int arr[ ] = {12, 14, 15, 23, 45};
printf(%u%u, arr+1, &arr+1);

A.

65486, 65486

B.

65488, 65488

C.

65488, 65496

D.

None of the above

Answer C
_____________________________________________________________
________________________
What will be the output of the following program?
main()
{
int i = 5;
printf(%d, i=++i==6);
}

A.

B.

C.

D.

Answer B
_____________________________________________________________
________________________
Consider the following C code segment.

int a, b, c = 0;
void prtFun(void);
main( )
{ static int a = 1; /* Line 1 */
prtFun( );
a += 1;
prtFun( );
printf( \n %d %d , a, b);
}
void prtFun(void)
{ static int a = 2; /* Line 2 */
int b = 1;
a += ++b;
printf( \n %d %d , a, b);
}
What output will be generated by the given code segment?

A.

31

41
42
B.
61
61

42

C.

42

62
20
D.

31

52
52
Answer C
The << operator is used for

A.

Right shifting

B.

Right shifting

C.

Bitwise shifting

D.

Bitwise complemen

Answer B
_____________________________________________________________
________________________
In addition to communicating with I/O, the processor must communicate
with the ______________ unit.

A.

Control

B.

Memory

C.

Arithmetic

D.

Process

Answer B

_____________________________________________________________
________________________
Which of the following is FALSE in C

A.

Keywords can be used as variable names

B.

Variable names can contain a digit

C.

Variable names do not contain a blank space

D.

Capital letters can be used in variable names

Answer A
_____________________________________________________________
________________________
If an array is used as function argument, the array is passed

A.

By value

B.

By reference

C.

By name

D.

The array cannot be used as a function argument

Answer B
_____________________________________________________________
________________________
printf(%c, 100);

A.

prints 100

B.

prints ASCII equivalent of 100

C.

prints garbage

D.

None of the above

Answer B
_____________________________________________________________
________________________
Portable program means

A.

Program with wheels

B.

Independent from its authors

C.

Independent of platform

D.

None of the above

Answer C
_____________________________________________________________
________________________
Output of the following program fragment is
x = 5;
y = x++;
printf(%d%d, x, y);

A.

5, 6

B.

5, 5

C.

6, 5

D.

6, 6

Answer C
Explanation x is incremented by 1 and before that increment the value
is assigned to y so value of x=6 and y=5

_____________________________________________________________
________________________
What will happen if the following loop is executed?
int num = 0;
do
{
--num;
printf(%d, num);
num++;
}while (num >= 0);
}

A.

The loop will run infinite number of times.

B.

The program will not enter the loop.

C.

There will be a compilation error.

D.

There will be runtime error.

Answer C
_____________________________________________________________
________________________
The directive that can be used to test whether an expression evaluates to a
nonzero value or not is

A.

#if

B.

#elif

C.

#endif

D.

#exit

Answer A
_____________________________________________________________
________________________
Which of the following does not represent a valid storage class in c?

A.

automatic

B.

static

C.

union

D.

extern

Answer C
Which of the following storage devices can store maximum amount of data?

A.

Floppy Disk

B.

Hard Disk

C.

Compact Disk

D.

Magneto Optic Disk

Answer B
_____________________________________________________________
________________________
If a = 5 and b = 7 then the statement p = (a > b) : a ? b

A.

assigns a value 5 to p

B.

assigns a value 7 to p

C.

assigns a value 8 to p

D.

gives an error message

Answer D
_____________________________________________________________
________________________
Which of the following is not a correct variable type?

A.

float

B.

real

C.

int

D.

double

Answer B
_____________________________________________________________
________________________
C language was invented by

A.

Abacus

B.

Charles babage

C.

Thomson

D.

Dennis Ritchie

Answer D
_____________________________________________________________
________________________
A variable which is visible only in the function in which it is defined, is

called

A.

Static variable

B.

Auto variable

C.

External variable

D.

Local variable

Answer D
_____________________________________________________________
________________________
________ unit controls the flow and manipulation of data and information.

A.

Arithmetic logic

B.

Central

C.

Middle

D.

Control

Answer D
_____________________________________________________________
________________________
The C language includes the header file standard input & output in

A.

stdlib.h library

B.

stdio.h library

C.

conio.h library

D.

#include library

Answer B
_____________________________________________________________
________________________
From the point of view of the programmer, what are the major advantages of
using a high-level language rather than internal machine code or assembly
language ?

A.

Program portability

B.

Easy development

C.

Efficiency

D.

None of the above

Answer B
_____________________________________________________________
________________________
It is necessary to declare the type of function in the calling program if

A.

Function returns an integer

B.

Function returns a non-integer value

C.

Function is not defined in the same file

D.

Function is called number of times

Answer B
_____________________________________________________________
________________________
Which of the following was not associated with second generation
computers?

A.

High level procedural language

B.

Operating system

C.

Magnetic core and transistor

D.

All of the above were associated

Answer D

Literal means

A.

A string

B.

A string constant

C.

A character

D.

An alphabet

Answer B
_____________________________________________________________
________________________
If an integer occupies 4 bytes and a character occupies 1 bytes of memory,
each element of the
following structure would occupy how many bytes?
struct name
{
int age;
char name [20];
}

A.

B.

24

C.

21

D.

22

Answer B
_____________________________________________________________
________________________
By default real number is treated as

A.

Float

B.

Double

C.

Long double

D.

Far double

Answer B
_____________________________________________________________
________________________
Output of following Program
main() {
long i = 30000;
printf(%d, i); }
the output is

A.

3000

B.

3000

C.

-1

D.

Answer B
_____________________________________________________________
________________________
C allows a three-way transfer of control with the help of

A.

Unary operator

B.

Relational operator

C.

Ternary operator

D.

Comparison operator

Answer C
_____________________________________________________________
________________________
Consider the following C code segment.
int a, b, c = 0;
void prtFun(void);
main( )
{ static int a = 1; /* Line 1 */
prtFun( );
a += 1;
prtFun( );
printf( \n %d %d , a, b);
}

void prtFun(void)
{ static int a = 2; /* Line 2 */
int b = 1;
a += ++b;
printf( \n %d %d , a, b);
}
What output will be generated by the given code segment if:
Line 1 is replaced by auto int a = 1;
Line 2 is replaced by register int a = 2;

A.

31

41
42
B.

42

61
61
C.

42

62
20
D.

42

42
20
Answer D

_____________________________________________________________
________________________
What is the correct value to return to the operating system upon the
successful completion of a program?

A.

-1

B.

C.

D.

Programs do not return a value.

Answer C
_____________________________________________________________
________________________
Usually, an algorithm will contain a number of procedural steps which are
dependent on results of previous steps and is called _______________.

A.

Flowchart

B.

Chart

C.

Drawing Chart

D.

Food Chart

Answer A
_____________________________________________________________
________________________
Which of the following metric does not depend on the programming
language used ?

A.

Line of code

B.

Function count

C.

Member of token

D.

All of the above

Answer B
_____________________________________________________________
________________________
What is the output of the following program segment?
main()
{
int i = 1;
do
{
printf(%d.., i);
}
while(i--);
}

A.

0..1..

B.

1..0..

C.

D.

-1

Answer B
The break statement causes an exit

A.

Only from the innermost loop

B.

Only from the innermost switch

C.

From the innermost loop or switch

D.

From the program

Answer C
_____________________________________________________________
________________________
The spacing between character pairs is called

A.

Kerning

B.

x-height

C.

intercap

D.

serif

Answer A
_____________________________________________________________
________________________
What is the only function all C++ programs must contain?

A.

start()

B.

system()

C.

main()

D.

program()

Answer C
_____________________________________________________________
________________________

How many of the following declarations are correct ?


1.int z = 7.0;
2.double void = 0.000;
3.short array [2] = {0, 1, 2};
4.char c = \n

A.

None

B.

One is correct

C.

Two are correct

D.

All four are correct

Answer C
_____________________________________________________________
________________________
The _______ operator is a technique to forcefully convert one data type to
the others

A.

Cast

B.

Conversion

C.

Type

D.

Unary

Answer A
_____________________________________________________________
________________________
If an integer needs two bytes of storage, then the maximum value of a signed
integer is

A.

216 1

B.

215 1

C.

216

D.

215

Answer B
_____________________________________________________________
________________________
Output of the following program fragment is
printf (%d, printf (tim));

A.

results in a syntax error

B.

outputs tim3

C.

outputs garbage

D.

outputs tim and terminates abruptly

Answer B
_____________________________________________________________
________________________
Consider the following program
main ( )
{ float a = 0.5, b = 0.7;
if (b < 0.8)
if (a < 0.5) printf (ABCD);
else printf (PQR);

else printf (JKLF);


}
The output is

A.

ABCD

B.

PQR

C.

JKLF

D.

None of these

Answer B
Explanation Since b=0.7<0.8, the control goes to second if
statement where (a<0.5) is false to printf
_____________________________________________________________
________________________
What is the value of b after the execution of the following code statements:
C=10;
B=++c+++c;

A.

20

B.

22

C.

23

D.

None

Answer D
_____________________________________________________________
________________________

A Compiler is _____________________.

A.

A combination of computer hardware

B.

A program which translates from one high-level language to another

C.

A program which translates from one high-level to a machine level

D.

None of these

Answer C

S-ar putea să vă placă și