wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Aptitude-2

Total questions: 75

Worksheet time: 51mins

Name
Class
Date
1.
Which for loop is correct?
a)
for (1; x < 5; i--)
b)
for(x; 5; ++1)
c)
for(int i = 0; i < 5; i++)
d)
for(int i = 0, i < 5, i++)
2.
What is a correct array?
a)
int a() = { 1, 2 };
b)
int a{} = [ 1, 2 ];
c)
int a = ( 1, 2 );
d)
int a[2] = { 1, 2 };
3.
Which type is incorrect?
a)
int
b)
double
c)
float
d)
array
4.

What is a Variable?

a)

It is a place where you can store some data

b)

It is a place in your code that changes

c)

It is a name given to a special sub-routine that changes how the program works

d)

It is when you want to add two number together

5.
The first element in an array is always element 1.
a)
False
b)
True
6.
Arrays always have the same...
a)
data types
b)
text types
c)
numbers
d)
types of data
7.
Arrays are collection of the same data type under a single identifier.
a)
True
b)
False
8.
Values in arrays cannot be changed.
a)
False
b)
True
9.
The first and last elements of an array declared as scores[10] is...
a)
scores[0], scores[9]
b)
scores[1], score [11]
c)
scores[4], scores[3]
d)
score[0], score[9]
10.
myArray[0] + myArray[1] adds the first two values in an array together.
a)
True
b)
False
11.
Loops are useful for cycling through an array.
a)
True
b)
False
12.
Which of the following is not a valid C variable name?
a)
int number;
b)
float rate;
c)
int variable_count
d)
int $main
13.
The format identifier ‘%i’ is also used for _____ data type?
a)
char
b)
int
c)
float
d)
double
14.
Which of the following cannot be checked in a switch case statement ?
a)
char
b)
int
c)
Enum
d)
float
15.
We cannot use String in the Switch case as label
a)
Yes
b)
No
16.
Continue statement is allowed inside the switch case statement ?
a)
Yes
b)
No
17.
For loop is _________.
a)
Function Controlled
b)
Entry Controlled
c)
Exit Controlled
d)
None
18.
Comment on the output of this C code?
 int main()
  {
 float f1 = 0.1;
  if (f1 == 0.1)
  printf("equal\n");
  else
  printf("not equal\n");
  }
a)
equal
b)
not equal
c)
depends on compiler
d)
None
19.
Predict output
  void main()
  {    
float x = 0.1;
  printf("%d, ", x);
  printf("%f", x);
  }
a)
0.100000 , junk value
b)
junk value, 0.100000
c)
0, 0.100000
d)
0, 0.999999
20.
What will be the data type returned for the following function?
  int func()
  {
 return (double)(char)5.0;
  }
a)
char
b)
int
c)
double
d)
Return illegal
21.
Which keyword is used to prevent any changes in the variable within a C program?
a)
immuta
b)
mutable
c)
const
d)
vola
22.
The name of the variable used in one function cannot be used in another function?
a)
True
b)
False
23.
 #include is called
a)
Preprocessor directive
b)
Inclusion directive
c)
File inclusion directive
d)
None
24.

What value will be stored in z if the following code is executed?

x = 5 , y = -10, a = 4, b = 2;

z = x+++++y * b/a;

a)

-2

b)

0

c)

1

d)

2

25.

Expression x % y is equivalent to____?

a)

(x – (x/y))

b)

(x – (x/y) * y)

c)

(y – (x/y))

d)

(y – (x/y) * y)

26.

a=2;b=6; (a<b):10:15

a)

10

b)

15

c)

2

d)

6

27.
What is machine code?
a)
Instructions converted by a translator
b)
Instructions in an HLL used by the CPU
c)
Instructions in binary used by the CPU
d)
Instructions in assembly used by the CPU
28.
What is a translator?
a)
A program that converts commands into machine code
b)
A program that converts HLL to assembly code
c)
A program that converts the inputs from a keyboard
d)
A program for writing code
29.
What is Assembly code?
a)
Another name for Pseudocode
b)
A programming language that uses mnemonic codes
c)
A program that joins pieces of code together
d)
Another name for machine code
30.
What does IDE stand for?
a)
Integrated Debugging Equipment
b)
Integrated Debugging Environment
c)
Integrated Development Equipment
d)
Integrated Development Environment
31.

int myArray[10] = {1,2,3,4,5,6,7,8,9}


What is the value of :

myArray[myArray[0]+myArray[4]];

a)

9

b)

8

c)

7

d)

6

32.

Consider the following code snippet


if (x<50)

if (x>=0 && x<=25)

x+=25;

else

x-=25;

else

if (x>=75 && x <= 100)

x-=25;

else

x+25;


What will be the final value of x if x=100?

a)

100

b)

75

c)

50

d)

25

33.

Which of the following statements is/are correct?

a. char middle_name='c';

scanf("%c", middle_name);

b. char middle_name="c";

scanf("%c", middle_name);

c. char middle_name='c';

scanf("%s",middle_name);

d. char middle_name='c';

scanf("%c", &middle_name);

a)

A is correct.

b)

B is correct.

c)

C is correct.

d)

D is correct.

34.

Predict the output of the following C program:


#include <stdio.h>

int main( ) {

int x= -1;

int y= -2;

int z=++x || ++y;

printf("%d,%d,%d", x,y,z);

return 0;

}

a)

1,-1,1

b)

0,-1,0

c)

1,0,-1

d)

0,-1,1

35.

What is output of below program?

void main()

{

const int a = 10;

printf("%d",++a);

}

a)

11

b)

10

c)

Compilation Error

d)

0

36.
For the array:
float stats[3];
What is the range of the index?
a)
0 to 3
b)
0 to 2
c)
1 to 3
d)
0 to 4
37.
for(int i=0; i<10; i++)
           numbers[i] = 2 * i + 1;
// Which index of the array holds the value of 5?
a)
1
b)
2
c)
3
d)
4
38.
What is the error in the following code fragment?
float average [20];
average[20] = 15.25;
a)
A cast is required
b)
data not initialized
c)
A two-dimensional array is required
d)
Array Out-of-bounds error
39.
How can you fetch data from the array?
a)
using index
b)
using value
c)
using arrayname
d)
using operator
40.
Syntax errors are always spotted when the program is compiled or interpreted.
a)
True
b)
False
41.
A program won't run if there is a logic error.
a)
False
b)
True
42.
Modern IDEs are able to spot syntax errors as the programmer types.
a)
True
b)
False
43.
Which statement best describes logic errors?
a)
An error in a program that causes it to produce incorrect ouputs but not a crash.
b)
An error in a program that causes it to crash.
c)
An error in the program caused by mis-spelt instructions.
d)
An error in a program caused by hardware failure.
44.
Which of the following variable names is valid according to variable naming rules?
a)
1Name
b)
Phone#
c)
phoneNumber
d)
First Name
45.
Which programming term means joining two strings together?
a)
Concatenation
b)
Evaluating
c)
Declaring
d)
Initializing
46.
Which of the following is used by the computer to determine how the data stored in a variable can be manipulated?
a)
Name
b)
Assignment
c)
Data Type
d)
Operator
47.
Which data type contains only two values and is used to compare conditions?
a)
String
b)
Boolean
c)
Floating Point
d)
Integer
48.
When you give a variable a starting value, it is called ___________ the variable.
a)
initializing
b)
naming
c)
assigning
d)
declaring
49.
What is the function of the <= operator?
a)
Greater than or equal to
b)
Less than or equal to
c)
Not equal to
d)
And equal 
50.
Which choice lists examples of logical (Boolean) operators?
a)
++, !=, ||
b)
!, &&, %
c)
++, %, !
d)
&&, !, ||
51.
Telling a program that a specific named variable exists is called:
a)
declaring
b)
evaluating
c)
initializing
d)
naming
52.
Which of the following is not a data type?
a)
Character
b)
String
c)
Integer
d)
Object
53.
A whole number that does not contain a decimal is a ________?
a)
character
b)
integer
c)
string
d)
floating point
54.
What is the term for a combination of variables, values, functions and operators?
a)
Expressions
b)
Variables
c)
Programs
d)
Algorithms
55.
Expressions are evaluated using _______.
a)
variable rules
b)
order of operations
c)
rules of initializing
d)
declaration
56.

_____________________ allows the computer to make a choice between alternative conditions.

a)

control structure

b)

sequence structure

c)

selection structure

d)

iteration structure

57.
In coding terms, the action of doing something over and over again.
a)
Repeating
b)
Repetition
c)
Loop
d)
Do-over
58.

(2.1-60105) Before a variable is used it must be

a)

defined

b)

declared

c)

included

d)

evaluated

e)

assigned

59.
A disadvantage of programming in Low Level is
a)
No technical skill is required
b)
Needs to be translated before it can be executed
c)
Difficult for humans to debug
60.
Which of the following is not a high level programming language?
a)
Assembly
b)
C++
c)
Java
d)
Python
61.
The first and last elements of an array declared as scores[10] is...
a)
scores[0], scores[9]
b)
scores[1], score [11]
c)
scores[4], scores[3]
d)
score[0], score[9]
62.
Which of the following is the start of an example of a condition controlled loop
a)
for index in range (10):
b)
while not reached:
63.

SCD, TEF, UGH, ____, WKL

a)

CMN

b)

UIJ

c)

VIJ

d)

VJT

64.

Look at this series: 7, 10, 8, 11, 9, 12, ... What number should come next?

a)

7

b)

10

c)

12

d)

13

65.

How many 3 digits numbers can be formed using the digits 1,2,3,4,5,7,9.

a)

343

b)

464

c)

565

d)

666

66.

Fill the series 17,32,19,29,21,26,23,__,__

a)

25,25

b)

20,22

c)

23,25

d)

25,22

67.
For the array:
float stats[3];
What is the range of the index?
a)
0 to 3
b)
0 to 2
c)
1 to 3
d)
0 to 4
68.
int nums[ ] =
{2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums
a)
nums[4]
b)
nums[3]
c)
nums(4)
d)
nums(3)
69.
for(int i=0; i<10; i++)
           numbers[i] = 2 * i + 1;
// Which index of the array holds the value of 5?
a)
1
b)
2
c)
3
d)
4
70.
What is the error in the following code fragment?
float average [20];
average[20] = 15.25;
a)
A cast is required
b)
data not initialized
c)
A two-dimensional array is required
d)
Array Out-of-bounds error
71.
________________________ are used to create a multi dimensional array.
a)
Single round brackets
b)
Single square brackets
c)
Multiple squares brackets
d)
Single angled brackets
72.
 Which of the following is a two-dimensional array?
a)
array anarray[20][20];
b)
int anarray[20][20];
c)
int array[20, 20];
d)
char array[20];
73.

Identify the array index of each element.

int arr[] = {2, 4, 6, 8}

a)

0, 1, 2, 3

b)

1, 2, 3, 4

c)

2, 4, 6, 8

d)

0, 2, 4, 6

74.
Which of the following declares an array of int named img?
a)
int img;
b)
int[] img;
c)
new int img[];
d)
int img = int[];
75.
What data type is this 'C'?
a)
String
b)
Char
c)
int
d)
boolean