Programming in
Programming in
DEPARTMENT OF COMPUTER
SCIENCE
PRAT -A
A) Charles Babbage
B) Grahambel
C) Dennis Ritchie
D) Steve Jobs
Answer : C
A) FORTRAN
B) D Language
C) BASIC
D) B Language
Answer : D
A) Low Level
B) High Level
C) Low + High
D) None
Answer : B
Answer : D
Answer: A
A)
main()
{
scanf("Hello World..");
}
B)
main()
{
printf("Hello World..");
}
C)
main()
{
print("Hello World..");
}
D)
main()
{
scan("Hello World..");
}
Answer : B
Answer: B
9) What are the new features of C11 or ISO IEC 9899 2011 standard.?
Answer:D
A) Uniliver Labs
B) IBM Labs
C) AT&T Bell Labs
D) Verizon Labs
Answer:C
A) C Language
B) B Language
C) D Language
D) None
Answer: D
A) Android
B) Linux
C) Ubuntu
D) Unix
Answer: C
A) 1999
B) 1978
C) 1972
D) 1990
Answer: D
A) Databases
B) Graphic applications
C) Word Processors
D) All of the above
Answer: D
A) ?:
B) :?
C) :<
D) <:
Answer : A
16) What is the other name for C Language ?: Question Mark Colon Operator.?
A) Comparison Operator
B) If-Else Operator
C) Binary Operator
D) Ternary Operator
Answer: D
Answer: A
int main()
{
int a=0;
a = 5<2 ? 4 : 3;
printf("%d",a);
return 0;
}
A) 4
B) 3
C) 5
D) 2
Answer: B
int main()
{
int a=0;
a = printf("4");
printf("%d",a);
return 0;
}
A) 04
B) compiler error
C) 40
D) 41
Answer: D
int main()
{
int a=0;
a = 5>2 ? printf("4"): 3;
printf("%d",a);
return 0;
}
A) compiler error
B) 14
C) 41
D) 0
Answer :C
int main()
{
int a=0;
a = (5>2) ? : 8;
printf("%d",a);
return 0;
}
A) 0
B) 1
C) 8
D) compiler error
Answer: B
int main()
{
int a=0, b;
a = (5>2) ? b=6: b=8;
printf("%d %d",a, b);
return 0;
}
a) 6 6
b) 0 6
c) 0 8
d) compiler error
Answer:d
a) (x == y) is x really equal to y.
(x != y) is x not equal to y.
b) (x < y) is x less than y
(x > y) is x greater than y
c) (x <= y) is x less than or equal to y.
(x >= y) is x greater than or equal to y
d) all the above
Answer: d
Answer:c
a)
if( condition )
{
//statements;
}
b)
if( condition )
{
//statements;
}
else
{
//statements;
}
c)
if( condition1 )
{
//statements;
}
else if( condition2)
{
//statements;
}
else
{
//statements;
}
Answer: d
int main()
{
if( 4 > 5 )
{
printf("hurray..\n");
}
printf("yes");
return 0;
}
a) yes
b) hurray..yes
c) hurray..yes
d) compiler error
Answer: a
int main()
{
if( 4 > 5 )
printf("hurray..\n");
printf("yes");
return 0;
}
a) yes
b) hurray..yes
c) hurray..yes
d) no output
Answer:a
return 0;
}
a) hurray..yes
b) hurray..yes
c) compiler error
d) none of the above
Answer : A
int main()
{
if( 4 < 5 )
printf("Hurray..\n");
printf("Yes");
else
printf("England")
return 0;
}
A) Hurray..Yes
B) Hurray..Yes
C) Compiler error
D) None of the above
Answer:C
int main()
{
if( 10 > 9 )
printf("Singapore\n");
else if(4%2 == 0)
printf("England\n");
printf("Poland");
return 0;
}
A) Singapore
B) Singapore
Poland
C) Singapore
England
Poland
D) England
Poland
Answer: B
int main()
{
if(-5)
{
printf("Germany\n");
}
if(5)
{
printf("Texas\n");
}
printf("ZING");
return 0;
}
A) ZING
B) Texas
ZING
C) Germany
Texas
ZING
D) Compiler error as a number can not be put as condition inside IF.
Answer:C
int main()
{
if(10.0)
{
printf("Texas\n");
}
printf("ZING");
return 0;
}
A) ZING
B) Texas
ZING
C) Compiler error.
D) None of the above.
Answer:B
int main()
{
if("abc")
{
printf("India\n");
}
if('c')
{
printf("Honey\n");
}
printf("ZING");
return 0;
}
A) ZING
B) Honey
ZING
C) India
ZING
D) India
Honey
ZING
Answer:D
int main()
{
if(TRUE)
{
printf("India\n");
}
if(true)
{
printf("Honey\n");
}
printf("ZING");
return 0;
}
A) India
ZING
B) Honey
ZING
C) India
Honey
ZING
D) Compiler error
Answer:D
35) What is the Priority among (*, /, %), (+, -) and (=) C Operators.?
Answer:C
int main()
{
int a=0;
a = 4 + 4/2*5 + 20;
printf("%d", a);
return 0;
}
A) 40
B) 4
C) 34
D) 54
Answer:C
37) What is the output of the C Program.?
int main()
{
int a=0;
a = 10 + 5 * 2 * 8 / 2 + 4;
printf("%d", a);
return 0;
}
A) 124
B) 54
C) 23
D) 404
Answer:B
int main()
{
int a=0;
a = 4 + 5/2*10 + 5;
printf("%d", a);
return 0;
}
A) 29
B) 5
C) 4
D) 34
Answer:A
int main()
{
int a=0;
a = 10 + 2 * 12 /(3*2) + 5;
printf("%d", a);
return 0;
}
A) 31
B) 19
C) 11
D) 29
Answer :B
return 0;
}
A) 19
B) 31
C) 11
D) 25
Answer :B
int main()
{
float a=10.0;
a = a % 3;
printf("%f", a);
return 0;
}
A) 0
B) 1
C) 1.000000
D) Compiler error.
Answer:D
int main()
{
float a=10.0;
a = (int)a % 3;
printf("%f", a);
return 0;
}
A) 0
B) 1
C) 1.000000
D) Compiler Error.
Answer:C
int main()
{
int a=0;
a = 14%-5 - 2;
printf("%d", a);
return 0;
}
A) 0
B) -4
C) -2
D) 2
Answer :D
int main()
{
int a= 3 + 5/2;
printf("%d", a);
return 0;
}
A) 3
B) 2
C) 5
D) Can not assign an expression to variable at the time of declaration.
Answer:C
A)#read
B)#get
C)#include
D)#put
Answer: C
Answer: Option B
A)Quit a program
B)Quit the current iteration
C)Both of above
D)None of above
Answer : C
Answer: Option B
#include
void main()
{
char test =`S`;
printf("\n%c",test);
}
A)S
B)Error
C)Garbage value
D)None of above
Answer: A
Answer: A
#include
main()
{
int x,y = 10;
x = y * NULL;
printf(\"%d\",x);
}
A)error
B)0
C)10
D)Garbage value
Answer: B
Answer:A
Answer:B
A) breaker
B) go to
C) shorter
D) default
Answer:D
A) work
B) case
C) constant
D) permanent
Answer:B
A) Float
B) Int
C) Long
D) double
Answer:D
A) short
B) int
C) long
D) All the above
Answer: D
Answer:D
Answer:C
A) 16 bit
B) 32 bit
C) 64 bit
D) 128 bit
Answer: A
A) 16 bit
B) 32 bit
C) 64 bit
D) 128 bit
Answer:B
63) Sizes of short, int and long in a Turbo C C++ compiler in bytes are.?
A) 2, 2, 4
B) 2, 4, 4
C) 4, 8, 16
D) 8, 8, 16
Answer:A
64) Sizes of short, int and long in Visual Studio or GCC compiler in bytes are.?
A) 2, 2, 4
B) 2, 4, 4
C) 4, 4, 8
D) 4, 8, 8
Answer:B
A) -128 to +127
0 to 255
B) 0 to 255
-128 to +127
C) -128 to -1
0 to +127
D) 0 to +127
-128 to -1
Answer:A
A) 0 to 65535
-32768 to +32767
B) -32768 to +32767
0 to 65535
C) -32767 to +32768
0 to 65536
D) 0 to 65536
-32767 to +32768
Answer: B
A) 4, 8, 16
B) 4, 8, 10
C) 2, 4, 6
D) 4, 6, 8
Answer:B
A) -2147483647 to +2147483648
0 to 4294967295
B) -2147483648 to +2147483647
0 to 4294967296
C) -2147483648 to +2147483647
0 to 4294967295
D) 0 to 4294967295
-2147483648 to +2147483647
Answer:C
A) -3.2e38 to +3.2e38
B) -3.8e32 to +3.8e32
C) -3.4e34 to +3.4e34
D) -3.4e38 to +3.4e38
Answer : D
A) A Positive number
B) A Negative Number
C) An Unsigned number
D) None of the above
Answer:A
A. 31
B. 32
C. 64
D. 63
Answer : B
Answer : A
A. TRUE
B. friend
C. export
D. volatile
Answer: A
void main()
{
int x = 10;
float x = 10;
printf("%d", x)
}
A. Compilations Error
B. 10
C. 10
D. 10.1
Answer : A
#include <stdio.h>
int main()
{
int i;
for (i = 0;i < 5; i++)
int a = i;
printf("%d", a);
}
Answer : A
#include <stdio.h>
int var = 20;
int main()
{
int var = var;
printf("%d ", var);
return 0;
}
A. Garbage Value
B. 20
C. Compiler Error
D. None of these
Answer : A
void main()
{
int p, q, r, s;
p = 1;
q = 2;
r = p, q;
s = (p, q);
printf("p=%d q=%d", p, q);
}
A. p=1 q=1
B. p=1 q=2
C. p=2 q=2
D. Invalid Syntex
Answer : B
void main()
{
printf("%x",-1<<4);
}
A. fff0
B. fff1
C. fff2
D. fff3
Ans : A
#include <stdio.h>
void main()
{
int a=1, b=2, c=3, d;
d = (a=c, b+=a, c=a+b+c);
printf("%d %d %d %d", d, a, b, c);
}
A. 11 3 5 11
B. 11 1 5 11
C. 11 3 2 11
D. 11 3 3 11
Ans : A
void main()
{
int a, b = 5, c;
a = 5 * (b++);
c = 5 * (++b);
printf("%d %d",a,c);
}
A. 30 35
B. 30 30
C. 25 30
D. 25 35
Ans :D
81) The format identifier ‘%i’ is also used for _____ data type?
A. char
B. int
C. float
D. double
Answer : B
int main()
{
int a[5] = {1, 2, 3, 4, 5};
int i;
for (i = 0; i < 5; i++)
if ((char)a[i] == '5')
printf("%d\n", a[i]);
else
printf("FAIL\n");
}
A. The compiler will flag an error
B. Program will compile and print the output 5
C. Program will compile and print the ASCII value of 5
D. Program will compile and print FAIL for 5 times
Answer:D
83). Which data type is most suitable for storing a number 65000 in a 32-bit
system?
A. short
B. int
C. long
D. double
Answer :A
Answer:D
A. 4 Bytes
B. 8 Bytes
C. Depends on the system/compiler
D. Cannot be determined.
Answer : C
int main()
{
char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}
A. 128
B. - 128
C. Depends on the compiler
D. None of the mentioned
Answer: B
int main()
{
char c;
int i = 0;
FILE *file;
file = fopen("test.txt", "w+");
fprintf(file, "%c", 'a');
fprintf(file, "%c", -1);
fprintf(file, "%c", 'b');
fclose(file);
file = fopen("test.txt", "r");
while ((c = fgetc(file)) != -1)
printf("%c", c);
return 0;
}
A. a
B. Infinite loop
C. Depends on what fgetc returns
D. Depends on the compiler
Answer : A
Answer:C
int main()
{
float f1 = 0.1;
if (f1 == 0.1)
printf("equal\n");
else
printf("not equal\n");
}
A. equal
B. not equal
C. Output depends on compiler
D. None of the mentioned
Answer :B
int main()
{
float f1 = 0.1;
if (f1 == 0.1f)
printf("equal\n");
else
printf("not equal\n");
}
A. equal
B. not equal
C. Output depends on compiler
D. None of the
Answer: A
int main()
{
int x = 10000;
double y = 56;
int *p = &x;
double *q = &y;
printf("p and q are %d and %d", sizeof(p), sizeof(q));
return 0;
}
Answer:A
Answer : C
union Sti
{
int nu;
char m;
};
int main()
{
union Sti s;
printf("%d", sizeof(s));
return 0;
}
A. 8
B. 5
C. 9
D. 4
Answer : D
int main()
{
float x = 'a';
printf("%f", x);
return 0;
}
A. a
B. run time error
C. a.0000000
D. 97.000000
Answer : D
A. int
B. struct
C. float
D. double
Answer: B
A.For
B.If
C.do-while
D.while
Answer : C
Answer : C
98) A pointer pointing to a memory location of the variable even after deletion of
the variavle is known as _____
A.far pointer
B.dangling pointer
C.null pointer
D.void pointer
Answer : B
A.Constructor
B.dangling pointer
C.Wild Pointer
D.Destructor
Answer : C
Answer :C
scanf("%d",i);
Answer: B
int main()
{
int i = -5;
int k = i %4;
printf("%d\n", k);
}
Answer: B
int main()
{
int i = 5;
int l = i / -4;
int k = i % -4;
printf("%d %d\n", l, k);
return 0;
}
Answer : B
int main()
{
int i = 7;
i = i / 4;
printf("%d\n", i);
return 0;
}
A. Run time error
B. 1
C. 3
D.Compile time error
Answer: B
void main()
{
int x = 4 *5 / 2 + 9;
}
A. 6.75
B. 1.85
C. 19
D. 3
Answer: C
void main()
{
int x = 4.3 % 2;
printf("Value of x is %d", x);
}
A. Value of x is 1.3
B. Value of x is 2
C. Value of x is 0.3
D. Compile time error
Answer: D
107)What is the Priority among (*, /, %), (+, -) and (=) C Operators.?
Answer: C
int main()
{
int a=0;
a = 4 + 4/2*5 + 20;
printf("%d", a);
return 0;
}
A) 40
B) 4
C) 34
D) 54
Answer:C
int main()
{
int a=0;
a = 10 + 5 * 2 * 8 / 2 + 4;
printf("%d", a);
return 0;
}
A) 124
B) 54
C) 23
D) 404
Answer:B
int main()
{
int a=0;
a = 4 + 5/2*10 + 5;
printf("%d", a);
return 0;
}
A) 29
B) 5
C) 4
D) 34
Answer:A
int main()
{
int a=0;
a = 10 + 2 * 12 /(3*2) + 5;
printf("%d", a);
return 0;
}
A) 31
B) 19
C) 11
D) 29
Answer:B
int main()
{
int a=0;
a = 10 + 2 * 12 / 3 * 2 + 5;
printf("%d", a);
return 0;
}
A) 19
B) 31
C) 11
D) 25
Answer:B
int main()
{
float a=10.0;
a = a % 3;
printf("%f", a);
return 0;
}
A) 0
B) 1
C) 1.000000
D) Compiler error.
Answer:D
int main()
{
float a=10.0;
a = (int)a % 3;
printf("%f", a);
return 0;
}
A) 0
B) 1
C) 1.000000
D) Compiler Error.
Answer:C
return 0;
}
A) 0
B) -4
C) -2
D) 2
Answer: D
return 0;
}
A) 3
B) 2
C) 5
D) Can not assign an expression to variable at the time of declaration.
Answer:C
void fn( )
{
char c;
cin.get(c);
if (c != ‘\n’)
{
fn( );
cout.put(c);
}
}
Answer: B
Answer :B
Answer: D
1)If c is a variable initialised to 1, how many times will the following loop be
executed?
A. 60
B. 59
C. 61
D. None of these
Answer : B
120)How many times will the following loop be executed if the input data item is 0
1 2 3 4 ?
A. Ininition
B. never
C. once
D. None of these
Answer: A
A. if statement
B. if…else statement
C. switch statement
D. All of these
Answer: D
A. for
B. switch
C. if
D. while
Answer: B
A. True
B. False
C. None of these
Answer: B
A. True
B. False
C. None of these
Answer: A
A. True
B. False
Answer: B
A. True
B. False
C. None of these
Answer: A
A. True
B. False
C. None of these
Answer: B
A. True
B. False
C. None of these
Answer: B
129)If the Boolean expression of if statement evaluates to ________, then the block
of code inside the if statement will be executed.
A. True
B. False
C. None of these
Answer: A
130)C programming language assumes any non-zero and non-null values as true.
A. Statement is True
B. Statement is False
Answer: A
A) Same
B) Different
C) -
D) -
Answer:A
132) The Java Virtual Machine (JVM) implements arrays as ___ type.
A) Primitive
B) Object
C) -
D) -
Answer:B
A) Names
B) Values
C) Methods and Fields
D) None
Answer:C
Answer:A
A) -1
B) 0
C) 1
D) Any integer
Answer:B
136) Which are the special symbols used to declare an array in Java?
A) Braces { }
B) Parentheses ()
C) Square Brackets [ ]
D) Angled Brackets < >
Answer:C
137) Which are the special symbols used to initialize an array at the time of the
declaration itself?
A) Parentheses ( )
B) Square Brackets [ ]
C) Braces { }
D) Angled Brackets < >
Answer:C
A) FALSE
B) TRUE
C) -
D) -
Answer:A
A) TRUE
B) FALSE
C) -
D) -
Answer:A
140) What is the output of the below Java code snippet with arrays?
A) 0
B) null
C) Compiler error
D) Runtime Exception - Null Pointer Exception
Answer:D
A) 2,65
B) 3,95
C) 3,65
D) Compiler error
Answer:C
A) 0
B) -1
C) 1
D) Compiler error
Answer:A
A)
//int[] ary;
ary.length()
B)
//int[] ary;
ary.length
C)
//int[] ary;
ary->length()
D)
//int[] ary;
ary->length
Answer:B
144) What is the output of the below Java program with arrays?
A) RED
B) YELLOW
C) WHITE
D) Compiler error
Answer:
145) What is the output of the below Java program with arrays?
A) RAM
B) HDD
C) MOUSE
D) Compiler error
Answer:C
A) 25
B) 27
C) 30
D) Compile error
Answer:D
147) We should not specify the array size if declaration and initialization are
done at the same time. (TRUE / FALSE)
A) FALSE
B) TRUE
C) -
D) -
Answer:B
A) N-1
B) N
C) N+1
D) N+2
Answer:C
149) An array in Java can be declared only of some predefined types. (TRUE/FALSE)
A) FALSE
B) TRUE
C) -
D) -
Answer:A
150) The name of an array variable or identifier can start with ___.
A) A letter
B) Underscore ( _ )
C) Dollar Symbol ($)
D) All
Answer:D
151) Shorthand array initialization in Java needs the keyword "new" to allocate
memory to the array and elements. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer:A
152) Lazy initialization of array requires the keyword "new" to allocate memory to
the array and its elements. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer:B
A) 0
B) null
C) -1
D) Garbage value
Answer:B
154) What is the default value of byte, short, int or long data type elements of an
array in Java?
A) -1
B) 1
C) 0
D) Garbage value
Answer:C
155) What is the default value of float or double data type elements of an array in
Java?
A) 0
B) 0.0
C) 1
D) 1.0
Answer:B
156) What is the default value of a char data type elements of an array in Java?
A) 'A'
B) '\0'
C) null
D) '\0' or null
Answer: D
157) What is the default value of boolean data type elements of an array in Java?
A) true
B) false
C) -
D) -
Answer:B
158) Allocating memory with the keyword "new" causes the array elements to carry
default values. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer:B
A) 0,2,4,
B) 1,2,3,
C) 2,4,6,
D) Compiler error
Answer:C
160) What is the output of the below Java program with arrays?
A) AIR
B) PLANE
C) FLY
D) Compiler error
Answer:B
A) Bidirectional
B) Combo
C) Multidimensional
D) Multi-valu
Answer:C
162) A multidimensional array contains elements of the same data-type in all rows
and columns. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer:C
A) N-1
B) N
C) N+1
D) 10*N
Answer:B
164) An array with two dimensions is called a two-dimensional array in Java. State
TRUE or FALSE.
A) TRUE
B) FALSE
C) -
D) -
Answer:A
165) Row number and Column number in a Multidimensional array start with ___.
A) -1
B) 0
C) 1
D) 2
Answer:B
A) 4
B) 3
C) 2
D) 1
Answer:B
A)
int[][] code = {{1,2},{3,4,5}};
B)
int[2][] code = {{1,2},{3,4,5}};
C)
int[][] code={1,2,
3,4,5};
D) All
Answer:A
168) What is the output of the Java program with the multidimensional array?
int[][] goats;
goats = new int[3][];
goats[0] = {1,2};
System.out.println(goats[0][1]);
A) 0
B) 1
C) 2
D) Compiler error
Answer:D
1
2 3
4 5 6
A) FALSE
B) TRUE
C) -
D) -
Answer:B
170) While mentioning the array size in a multidimensional array using the new
keyword, the left-most script is mandatory. State TRUE or FALSE.
int ary[][];
ary = new int[5][];//first dimension is compulsory.
A) FALSE
B) TRUE
C) -
D) -
Answer: A
a) memcpy()
b) strcopy()
c) memcopy()
d) strxcpy()
Answer: a
a) strcpy()
b) strcat()
c) strncon()
d) memcon()
Answer: b
a) strcat()
b) strcon()
c) strncat()
d) memcat()
Answer: c
Answer: b
Answer: a
177) Which of the following is the variable type defined in header string. h?
a) sizet
b) size
c) size_t
d) size-t
Answer: c
a) true
b) false
Answer: a
a) Before memmove place= string1, src = string2 After memmove place = string2, src
= string2
b) Before memmove place = string2, src = string2 After memmove place= string1, src
= string2
c) Before memmove place = string2, src = string1 After memmove place= string2, src
=string2
d) Before memmove place= string1, src = string2 After memmove place=string1, src =
string1
Answer: a
Answer: a
Answer:B
183) What is the Format specifier used to print a String or Character array in C
Printf or Scanf function.?
A) %c
B) %C
C) %s
D) %w
Answer:C
int main()
{
char ary[]="Discovery Channel";
printf("%s",ary);
return 0;
}
A) D
B) Discovery Channel
C) Discovery
D) Compiler error
Answer:B
int main()
{
char str[]={'g','l','o','b','e'};
printf("%s",str);
return 0;
}
A) g
B) globe
C) globe\0
D) None of the above
Answer:D
int main()
{
char str[]={'g','l','o','b','y','\0'};
printf("%s",str);
return 0;
}
A) g
B) globe
C) globe\0
D) Compiler error
Answer:B
A) str[5] = 0;
B) str[5] = '\0'
C) str[]={'g','l','o','b','y','\0'};
D) All the above
Answer:D
int main()
{
int str[]={'g','l','o','b','y'};
printf("A%c ",str);
printf("A%s ",str);
printf("A%c ",str[0]);
return 0;
}
A) A A A
B) A Ag Ag
C) A*randomchar* Ag Ag
D) Compiler error
Answer:C
int main()
{
char str[]={"C","A","T","\0"};
printf("%s",str);
return 0;
}
A) C
B) CAT
C) CAT\0
D) Compiler error
Answer:D
A) 32 characters
B) 64 characters
C) 256 characters
D) None of the above
Answer:D
191) What is the output of C program with strings.?
int main()
{
char str1[]="JOHN";
char str2[20];
str2= str1;
printf("%s",str2);
return 0;
}
A) JOHN
B) J
C) JOHN\0
D) Compiler error
Answer:D
int main()
{
char str[25];
scanf("%s", str);
printf("%s",str);
return 0;
}
//input: South Africa
A) South
B) South Africa
C) S
D) Compiler error
Answer:A
int main()
{
char str[2];
scanf("%s", str);
printf("%s",str);
return 0;
}
//Input: South
A) So
B) South
C) Compiler error
D) None of the above
Answer:B
194) What is the output of C Program with strings.?
int main()
{
char str[2];
int i=0;
scanf("%s", str);
while(str[i] != '\0')
{
printf("%c", str[i]);
i++;
}
return 0;
}
//Input: KLMN
A) KL
B) KLMN
C) Compiler error
D) None of the above
Answer:B
A) SCANF
B) GETS
C) GETC
D) FINDS
Answer:B
Answer:D
int main()
{
char *p1 = "GOAT";
char *p2;
p2 = p1;
printf("%s", p2);
}
A) G
B) GOAT
C) Compiler error
D) None of the above
Answer:B
Answer: D
int main()
{
char *p1 = "GOAT";
char *p2;
p2 = p1;
p2="ANT";
printf("%s", p1);
}
A) ANT
B) GOAT
C) G
D) A
Answer: B
200) A string in C is
C.Any of i & ii
Answer: A
Answer:D
Answer:D
Answer:D
A) Self Function
B) Auto Function
C) Recursive Function
D) Static Function
Answer:C
int main()
{
void show()
{
printf("HIDE");
}
show();
return 0;
}
A) No output
B) HIDE
C) Compiler error
D) None of the above
Answer:B
void show();
int main()
{
show();
printf("ARGENTINA ");
return 0;
}
void show()
{
printf("AFRICA ");
}
A) ARGENTINA AFRICA
B) AFRICA ARGENTINA
C) ARGENTINA
D) Compiler error
Answer:B
int main()
{
show();
printf("BANK ");
return 0;
}
void show()
{
printf("CURRENCY ");
}
A) CURRENCY BANK
B) BANK CURRENCY
C) BANK
D) Compiler error
Answer:D
Answer:A
void show();
void main()
{
show();
printf("RAINBOW ");
return;
}
void show()
{
printf("COLOURS ");
}
A) RAINBOW COLOURS
B) COLOURS RAINBOW
C) COLOURS
D) Compiler error
Answer:B
void main()
{
printf("PISTA ");
show();
}
void show()
{
printf("CACHEW ");
return 10;
}
A) PISTA CACHEW
B) CASHEW PISTA
C) PISTA CASHEW with compiler warning
D) Compiler error
Answer:C
int show();
void main()
{
int a;
printf("PISTA COUNT=");
a=show();
printf("%d", a);
}
int show()
{
return 10;
}
A) PISTA COUNT=
B) PISTA COUNT=0
C) PISTA COUNT=10
D) Compiler error
Answer:C
void main()
{
int a;
printf("TIGER COUNT=");
a=show();
printf("%d", a);
}
int show()
{
return 15;
return 35;
}
A) TIGER COUNT=15
B) TIGER COUNT=35
C) TIGER COUNT=0
D) Compiler error
Answer:A
A) Library Functions
B) User Defined Functions
C) Both Library and User Defined
D) None of the above
Answer:C
int show();
void main()
{
int a;
a=show();
printf("%d", a);
}
int show()
{
return 15.5;
return 35;
}
A) 15.5
B) 15
C) 0
D) Compiler error
Answer:B
void main()
{
myshow(5);
myshow(10);
}
int myshow(int b)
{
printf("Received %d, ", b);
}
Answer:A
int myshow(int);
void main()
{
int a=10;
myshow(a);
myshow(&a);
}
int myshow(int b)
{
printf("Received %d, ", b);
}
Answer:C
void main()
{
int a=10;
myshow(&a);
}
A) Received RANDOMNumber,
B) Received 10,
C) Received 10,
D) Compiler error
Answer:C
void main()
{
int a=10;
printf("%d ", a);
myshow(&a);
printf("%d", a);
A) 10 10
B) 20 20
C) 10 20
D) Compiler error
Answer:C
void myshow(int);
void main()
{
int a=10;
printf("%d ", a);
myshow(a);
printf("%d", a);
void myshow(int k)
{
k=20;
}
A) 10 10
B) 20 20
C) 10 20
D) Compiler error
Answer:A
A) Pass By Value copies the variable value in one more memory location.
B) Pass By Value does not use Pointers.
C) Pass By Value protects your source or original variables from changes in outside
functions or called functions.
D) All the above
Answer:D
Answer:D
Answer:B
int main()
{
structure hotel
{
int items;
char name[10];
}a;
strcpy(a.name, "TAJ");
a.items=10;
printf("%s", a.name);
return 0;
}
A) TAJ
B) Empty string
C) Compiler error
D) None of the above
Answer:C
int main()
{
struct book
{
int pages;
char name[10];
}a;
a.pages=10;
strcpy(a.name,"Cbasics");
printf("%s=%d", a.name,a.pages);
return 0;
}
A) empty string=10
B) C=basics
C) Cbasics=10
D) Compiler error
Answer:C
Answer:B
int main()
{
struct ship
{
};
return 0;
}
Answer:C
int main()
{
struct ship
{
int size;
char color[10];
}boat1, boat2;
boat1.size=10;
boat2 = boat1;
printf("boat2=%d",boat2.size);
return 0;
}
A) boat2=0
B) boat2=-1
C) boat2=10
D) Compiler error
Answer:C
int main()
{
struct ship
{
char color[10];
}boat1, boat2;
strcpy(boat1.color,"RED");
printf("%s ",boat1.color);
boat2 = boat1;
strcpy(boat2.color,"YELLOW");
printf("%s",boat1.color);
return 0;
}
A) RED RED
B) RED YELLOW
C) YELLOW YELLOW
D) Compiler error
Answer:A
int main()
{
struct tree
{
int h;
}
struct tree tree1;
tree1.h=10;
printf("Height=%d",tree1.h);
return 0;
}
A) Height=0
B) Height=10
C) Height=
D) Compiler error
Answer:B
Answer:C
Answer:D
A) structure is used to implement Linked Lists, Stack and Queue data structures
B) Structures are used in Operating System functionality like Display and Input
taking.
C) Structure are used to exchange information with peripherals of PC
D) All the above
Answer:D
int main()
{
struct tree
{
int h;
int w;
};
struct tree tree1={10};
printf("%d ",tree1.w);
printf("%d",tree1.h);
return 0;
}
A) 0 0
B) 10 0
C) 0 10
D) 10 10
Answer:C
int main()
{
struct tree
{
int h;
int rate;
};
struct tree tree1={0};
printf("%d ",tree1.rate);
printf("%d",tree1.h);
return 0;
}
A) 0 0
B) -1 -1
C) NULL NULL
D) Compiler error
Answer:A
int main()
{
struct laptop
{
int cost;
char brand[10];
};
struct laptop L1={5000,"ACER"};
struct laptop L2={6000,"IBM"};
printf("Name=%s",L1.brand);
return 0;
}
A) ACER
B) IBM
C) Compiler error
D) None of the above
Answer:A
int main()
{
struct forest
{
int trees;
int animals;
}F1,*F2;
F1.trees=1000;
F1.animals=20;
F2=&F1;
printf("%d ",F2.animals);
return 0;
}
A) 0
B) 20
C) Compiler error
D) None of the above
Answer:C
237) What
int main()
{
struct bus
{
int seats;
}F1, *F2;
F1.seats=20;
F2=&F1;
F2->seats=15;
printf("%d ",F1.seats);
return 0;
}
A) 15
B) 20
C) 0
D) Compiler error
Answer:A
int main()
{
struct pens
{
int color;
}p1[2];
struct pens p2[3];
p1[0].color=5;
p1[1].color=9;
printf("%d ",p1[0].color);
printf("%d",p1[1].color);
return 0;
}
A) 5 5
B) 5 9
C) 9 5
D) Compiler error
Answer:B
int main()
{
struct car
{
int km;
}*p1[2];
struct car c1={1234};
p1[0]=&c1;
printf("%d ",p1[0]->km);
return 0;
}
A) 0
B) 1
C) 1234
D) Compiler error
Answer:C
240) Choose a correct statement about C structures.
Answer:D
int main()
{
struct car
{int color;};
struct garage
{
struct car mycar[10];
}gar;
struct car c1={5};
gar.mycar[0]=c1;
printf("%d",gar.mycar[0]);
return 0;
}
A) NULL
B) 0
C) 5
D) Compiler error
Answer:C
int main()
{
struct books{
int pages;
char str[4];
}b;
printf("%d",sizeof(b));
return 0;
}
A) 5
B) 6
C) 7
D) 8
Answer:B
int main()
{
struct books{
int pages;
char str[4];
}*ptr;
printf("%d",sizeof(ptr));
return 0;
}
A) 2
B) 6
C) 7
D) 8
Answer:B
A) district
B) state
C) country
D) None of the above
Answer: A
245) What is actually passed if you pass a structure variable to a function.?
Answer:A
void show(int,int);
int main()
{
struct paint{
int type;
int color;
}p;
p.type=1;
p.color=5;
show(p.type,p.color);
return 0;
}
void show(int a,int b)
{
printf("%d %d",a,b);
}
A) 1 1
B) 1 5
C) 5 1
D) Compiler error
Answer:B
247) What is the output of C program with structures.?
int main()
{
struct paint{
int type;
int color;
}p1, p2;
p1.type=1;
p1.color=5;
if(sizeof(p1)==sizeof(p2))
{
printf("SAME");
}
else
{
printf("DIFFERENT");
}
return 0;
}
A) SAME
B) DIFFERENT
C) Compiler error
D) None of the above
Answer:A
Answer:D
Answer:D
Answer:D
Answer: B
A. struct
B. enum
C. typedef
D. All of the mentioned
Answer:D
A.Windows
B. Linux
C.Oracle
D.DOS
Answer:C
A. 4
B. 5
C. 8
D. 12
Answer: C
A. 1948
B. 1949
C. 1950
D. 1951
Answer: C
A.1994
B.1990
C.1992
D.1985
Answer:D
A. .txt
B. .xls
C. .ppt
D. .bmp
Answer: A
A.prompt
B.kernel
C.shell
D.command
Answer: C
Answer: B
A. By operating system
B. By compiler
C. By interpreter
D. By application software
Answer: A
A. Restarting computer
B. Install the program
C. To scan
D. To turn off
Answer:A
Answer: C
A. To prevent deadlock
B. To deadlock recovery
C. To solve the deadlock
D. None of these
Answer: A
264) When you delete a file in your computer, where does it go?
A. Recycle bin
B. Hard disk
C.Taskbar
D. None of these
Answer: A
Answer: C
Answer: D
Answer: A
A. Cold boot
B. Cold hot boot
C. Cold hot strap
D. Hot boot
Answer: A
A. To disk protection
B. To CPU protection
C. To memory protection
D. None of these
Answer: C
Answer: b
A. Windows
B. MAC
C. Ms-Dos
D. None of these
Answer:C
A) #include<stdio.h>
main()
{
auto int a;
printf("%d", a);
}
B) #include<stdio.h>
main()
{
auto int a;
printf("%d", a);
}
//output = 0
C) #include<stdio.h>
main()
{
auto int a;
printf("%d", a);
}
//output = null
D) #include<stdio.h>
main()
{
auto int a;
printf("%d", a);
}
//output = some random number
Answer:D
#include<stdio.h>
int main()
{
printf("Hello Boss.");
}
A) Hello Boss.
B) hello boss
C) No output
D) Compiler error
Answer:D
int main()
{
auto int a=10;
{
auto int a = 15;
printf("%d ", a);
}
printf("%d ", a);
return 1;
}
A) 10 10
B) 10 15
C) 15 10
D) Compiler error
Answer:C
int main()
{
register a=10;
{
register a = 15;
printf("%d ", a);
}
printf("%d ", a);
return 20;
}
A) 15 20
B) 15 10
C) 10 15
D) 15 15
Answer:B
A) null
B) 0
C) random integer number
D) random real number
Answer:C
int main()
{
register a=80;
auto int b;
b=a;
printf("%d ", a);
printf("%d ", b);
return -1;
}
A) Compiler error. You can not assign register value to int variable.
B) 80 80
C) 80 0
Register value can not be copied.
D) Compiles, but output is none.
Answer:B
void myshow();
int main()
{
myshow();
myshow();
myshow();
}
void myshow()
{
static int k = 20;
printf("%d ", k);
k++;
}
A) 20 20 20
B) 20 21 21
C) 20 21 22
D) Compiler error.
Answer: C
#include<stdio.h>
static int k;
int main()
{
printf("%d", k);
return 90;
}
A) -1
B) 0
C) 90
D) Compiler error
Answer:B
int main()
{
register k = 25;
printf("%d", &k);
return 90;
}
Answer:D
A) Declaration
B) Definition
C) Initialization
D) None of the above
Answer :A
Answer:D
283) Every C Variable must have.?
A) Type
B) Storage Class
C) Both Type and Storage Class
D) Either Type or Storage Class
Answer:C
A) static
B) auto
C) register & extern
D) All the above
Answer:D
A) static
B) auto
C) register
D) extern
Answer:B
Answer:B
Answer:C
288) Variables of type auto, static and extern are all stored in .?
A) ROM
B) RAM
C) CPU
D) Compiler
Answer:B
A) register
B) auto
C) static
D) extern
Answer:B
A) auto
B) register
C) static
D) extern
Answer:D
Answer:B
D) You get a compiler error as you can not store non integer value in a CPU
register.
Answer:C
293)which of the following is not a storage class specifier?
A. auto
B. register
C. extern
D. volatile
Ans : A
A. 0
B. Null
C. Garbage
D. Infinite
Ans : C
A. Within block
B. Within Program
C. Global Multiple files
D. None of the above
Ans : C
A. Within block
B. Within Program
C. Global Multiple files
D. None of the above
View Answer
Ans : A
A. 0
B. Null
C. Garbage
D. Infinite
View Answer
Ans : A
A. 2 1
B. 0 0
C. 3 2
D. Compilation error
Ans : B
299) What will be output for the folowing code?
A. 5
B. 6
C. 4
D. Compilation error
Ans : C
A. Only I is correct
B. Only II is correct
C. Both I & II are correct
D. Both I & II are incorrect
Ans : D