Q What is the output of the below code snippet?
float foo(int i);
int main()
{
float x;
x = foo(10);
printf(“%0.2f\t”, x);
}
float foo(int i)
{
float j = 5;
j = j / i;
printf(“%0.3f ”, j);
return j;
}
A. Compilation Error.
B. 0.500 0.50
C. 10 5
D. No Output
Ans. b
Q What is the output of the below code?
int main ()
{
int skip_num;
for (skip_num = 1; skip_num<=5; skip_num++){
if(skip_num = =2 || skip_num = =4){
continue;
}
cout<<skip_num;
}
return 0;
}
A. 1 3 5
B. 1 3 4 5
C. 1 2 5
D. 2 4 6
Ans. a
Q What will be the output of the following code?
class Food
{
private:
string food;
public:
void orderFood (string food)
{
this->food = food;
}
void myFood() { cout<< food <<endl;}
};
int main()
{
Food name;
string food = “pizza”;
string* fastfood = &food;
name.orderFood(*fastfood);
name.myFood();
return 0;
}
A. pizza
B. food
C. fastfood
D. No Output
Ans. a
Q What is the average case time complexity of Radix Sort, if n is the number of elements in the array, k is
the maximum number of digits in any element of the array?
A. O(n+k)
B. Θ(n+k)
C. Θ(nk)
D. O(nk)
Ans. c
Q Below is the JSON format to share the employee data.
{
“id”: “001”,
“Name’: “John”
“Department”: “QA”
A JSON format, designed with a collection of (key, value) and pairs in which each of the key appears at once
in the collection.
Which type of data structures is most suitable to implement JSON format?
A. Doubly Linked List
B. AVL Tree
C. Single Linked List
D. Associative Array
Ans. b