NEW
Font size
S
M
L
XL
WorksheetsTechnical Skills- End Examin - 13-01-2024 ECE & EEE SEM V
Total questions: 25
Worksheet time: 25mins
Name
Class
Date
1.
#include<stdio.h>
enum happylife
{
a,b,c=5
};
enum happylife s;
main()
{
c++;
printf("%d",c);
}
a)
error
b)
5
c)
6
d)
2
2.
main()
{
enum resut {pass, fail};
enum result s1,s2;
s1=pass;
s2=fail;
printf("%d",s1);
}
a)
error
b)
pass
c)
fail
d)
0
3.
#include <stdio.h>
enum example {a = 1, b, c};
enum example example1 = 2;
enum example answer()
{
return example1;
}
int main()
{
(answer() == a)? printf("yes"): printf("no");
return 0;
}
a)
yes
b)
no
c)
2
d)
error
4.
#include<stdio.h>
#define MAX 4
enum ccc
{
a,b=3,c
};
main()
{
if(MAX!=c)
printtf("hello");
else
printf("welcome");
}
a)
error
b)
hello
c)
welcome
d)
2
5.
What will be the output of the following C code if input given is 2? #include<stdio.h>
enum day
{
a,b,c=5,d,e
};
main()
{
printf("Enter the value for a");
scanf("%d",a);
printf("%d",a);
}
a)
2
b)
0
c)
3
d)
error
6.
What will be the output of the following C code if the code is executed on a 32 bit platform?#include <stdio.h>
enum sanfoundry
{
c = 0,
d = 10,
h = 20,
s = 3
} a;
int main()
{
a = c;
printf("Size of enum variable = %d bytes", sizeof(a));
return 0;
}
a)
error
b)
Size of enum variable = 2 bytes
c)
Size of enum variable = 4 bytes
d)
Size of enum variable = 8 bytes
7.
#include <stdio.h>
union stu
{
int ival;
float fval;
};
void main()
{
union stu r;
r.ival = 5;
printf("%d", r.ival);
}
a)
9
b)
compile time error
c)
16
d)
5
8.
#include <stdio.h>
union
{
int x;
char y;
}p;
int main()
{
p.y = 60;
printf("%d\n", sizeof(p));
}
a)
Compile time error
b)
sizeof(int) + sizeof(char)
c)
Depends on the compiler
d)
sizeof(char)
9.
#include <stdio.h>
union p
{
int x;
char y;
}k = {1, 97};
int main()
{
printf("%d\n", k.y);
}
a)
Compile time error
b)
97
c)
a
d)
1
10.
Which of the following share a similarity in syntax?
1. Union, 2. Structure, 3. Arrays and 4. Pointers
a)
1 and 3
b)
1 and 2
c)
3 and 4
d)
1,3 and 4
11.
What will be the output of the following C code? (Assuming size of char = 1, int = 4, double = 8) #include <stdio.h>
union utemp
{
int a;
double b;
char c;
}u;
int main()
{
u.c = 'A';
u.a = 1;
printf("%d", sizeof(u));
}
a)
1
b)
4
c)
8
d)
13
12.
#include <stdio.h>
int main()
{
union {
int i1;
int i2;
} myVar = {.i2 = 100};
printf("%d %d", myVar.i1, myVar.i2);
return 0;
}
a)
Compile error due to incorrect syntax of initialization
b)
No compile error and it’ll print “0 100”.
c)
No compile error and it’ll print “100 100”.
d)
compile time error
13.
Time complexity of the code?
int fun(int n, int m, int o)
{
if (n <= 0)
printf("%d, %d\n",m, o);
else
{
fun(n-1, m+1, o);
fun(n-1, m, o+1);
}
a)
Quadratic
b)
O (log n)
c)
O (n log m)
d)
Exponential
14.
What is the time complexity of the following code?
int fun(int x)
{
if (x <= 0)
return 1;
return 1 + fun(x-1);
}
a)
O(n)
b)
O (log n)
c)
O (n log n)
d)
O (log log n)
15.
What is the time complexity of the code?
int fun(int x)
{
if (x <= 0)
return 1;
return 1 + fun(x/5);
}
a)
O(n)
b)
O (log n)
c)
O (n log n)
d)
O (log log n)
16.
What is the time complexity to count the number of elements in the linked list?
a)
O(1)
b)
O(n)
c)
O(logn)
d)
None of the mentioned
17.
What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?
a)
O(1)
b)
O(n)
c)
θ (n)
d)
θ (1)
18.
What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6
void fun(struct node* start)
{
if(start == NULL)
return;
printf("%d ", start->data);
if(start->next != NULL )
fun(start->next->next);
printf("%d ", start->data);
}
a)
1 4 6 6 4 1
b)
1 3 5 1 3 5
c)
1 2 3 5
d)
1 3 5 5 3 1
19.
What is the functionality of the following piece of code?
public int function(int data)
{
Node temp = head;
int var = 0;
while(temp != null)
{
if(temp.getData() == data)
{
return var;
}
var = var+1;
temp = temp.getNext();
}
return Integer.MIN_VALUE;
}
a)
Find and delete a given element in the list
b)
Find and return the given element in the list
c)
Find and return the position of the given element in the list
d)
Find and insert a new element in the list
20.
Linked lists are not suitable to for the implementation of?
a)
Insertion sort
b)
Radix sort
c)
Polynomial manipulation
d)
Binary search
21.
#include <stdio.h>
int main()
{
void foo();
printf("1 ");
foo();
}
void foo()
{
printf("2 ");
}
a)
1 2
b)
Compile time error
c)
1 2 1 2
d)
Depends on the compiler
22.
#include <stdio.h>
int main()
{
void foo(), f();
f();
}
void foo()
{
printf("2 ");
}
void f()
{
printf("1 ");
foo();
}
a)
Compile time error as foo is local to main
b)
1 2
c)
2 1
d)
Compile time error due to declaration of functions inside main
23.
#include <stdio.h>
int main()
{
void foo();
void f()
{
foo();
}
f();
}
void foo()
{
printf("2 ");
}
a)
2 2
b)
2
c)
Compile time error
d)
Depends on the compiler
24.
#include <stdio.h>
void foo();
int main()
{
void foo();
foo();
return 0;
}
void foo()
{
printf("2 ");
}
a)
Compile time error
b)
2
c)
Depends on the compiler
d)
Depends on the standard
25.
What is tail recursion?
a)
A recursion with a base case
b)
A recursion with only one base case
c)
A recursion where the recursive call is the last thing executed
d)
A recursion without any base case
Reset
