Font size
WorksheetsC Aptitude-2
Total questions: 75
Worksheet time: 51mins
What is a Variable?
It is a place where you can store some data
It is a place in your code that changes
It is a name given to a special sub-routine that changes how the program works
It is when you want to add two number together
int main()
{
float f1 = 0.1;
if (f1 == 0.1)
printf("equal\n");
else
printf("not equal\n");
}
void main()
{
float x = 0.1;
printf("%d, ", x);
printf("%f", x);
}
int func()
{
return (double)(char)5.0;
}
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;
-2
0
1
2
Expression x % y is equivalent to____?
(x – (x/y))
(x – (x/y) * y)
(y – (x/y))
(y – (x/y) * y)
a=2;b=6; (a<b):10:15
10
15
2
6
int myArray[10] = {1,2,3,4,5,6,7,8,9}
What is the value of :
myArray[myArray[0]+myArray[4]];
9
8
7
6
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?
100
75
50
25
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 is correct.
B is correct.
C is correct.
D is correct.
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;
}
1,-1,1
0,-1,0
1,0,-1
0,-1,1
What is output of below program?
void main()
{
const int a = 10;
printf("%d",++a);
}
11
10
Compilation Error
0
float stats[3];
What is the range of the index?
numbers[i] = 2 * i + 1;
// Which index of the array holds the value of 5?
float average [20];
average[20] = 15.25;
_____________________ allows the computer to make a choice between alternative conditions.
control structure
sequence structure
selection structure
iteration structure
(2.1-60105) Before a variable is used it must be
defined
declared
included
evaluated
assigned
SCD, TEF, UGH, ____, WKL
CMN
UIJ
VIJ
VJT
Look at this series: 7, 10, 8, 11, 9, 12, ... What number should come next?
7
10
12
13
How many 3 digits numbers can be formed using the digits 1,2,3,4,5,7,9.
343
464
565
666
Fill the series 17,32,19,29,21,26,23,__,__
25,25
20,22
23,25
25,22
float stats[3];
What is the range of the index?
{2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums
numbers[i] = 2 * i + 1;
// Which index of the array holds the value of 5?
float average [20];
average[20] = 15.25;
Identify the array index of each element.
int arr[] = {2, 4, 6, 8}
0, 1, 2, 3
1, 2, 3, 4
2, 4, 6, 8
0, 2, 4, 6
int named img?