You are on page 1of 2

Computer Programming Language and Data Structure Lab (PEC 242)

Name: R. No. : Time: 10 Mint

1. What happens if the following program is executed in C and C++?


#include <stdio.h>
int main(void)
{
int new = 5;
printf("%d", new);
}
a) Error in both C and C++ b)A successful run in both C and C++
c)Error in C and successful execution in C++ d) Error in C++ and successful execution in C

2) Comment on the following pointer declaration.


int *ptr, p;

a) ptr is a pointer to integer, p is not


b) ptr and p, both are pointers to integer
c) ptr is a pointer to integer, p may or may not be
d) ptr and p both are not pointers to integer

3. How many times i value is checked in the following C code?


1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. while (i < 3)
6. i++;
7. printf("In while loop\n");
8. }
a) 2 b) 3 c) 4 d) 1

4. What will be the output of the following C code?


1. #include <stdio.h>
2. int main()
3. {
4. int i = 2;
5. int j = ++i + i;
6. printf("%d\n", j);
7. }
a) 6 b) 5 c) 4 d) Compile time error
Computer Programming Language and Data Structure Lab (PEC 242)
Name: R. No. : Time: 10 Mint

5. Stack and Queue operates on the principle of

a) LIFO & FIFO respectively b) FIFO & LIFO respectively

c) LIFO & LIFO respectively d) FIFO & FIFO respectively

6. Process of inserting an element in stack is called ____________


a) Create b) Push c) Evaluation d) Pop

7. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in
what order will they be removed?
a) ABCD b) DCBA c) DCAB d) ABDC

8. The “if-else” statement can be replaced by which operator?


a) Bitwise operator b) Conditional operator
c) Multiplicative operator d) None of the mentioned

9. Name the loop that executes at least once.


A. For B. If C. do-while D. while

10. What will be the output of the following C code?


1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. int j = i++ + i;
6. printf("%d\n", j);
7. }

a) 0 b) 1 c) 2 d) Compile time error

You might also like