QUESTION BANK for Programming for Problem Solving
QUESTION BANK for Programming for Problem Solving
Course Outcomes
(COs)
3 To test and execute the programs and correct syntax and logical errors
Acronyms:
F: Factual
Con: Conceptual
P: Procedural
M: Metacognitive
11 (24F)16=(?)8 1
2 1
What will be the output of the below program
#include <stdio.h>
int main()
return (0);
}
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
3
What will be the output of the below code snippet?
#include <stdio.h>
int main()
int a = 15, b;
b = (a++) + (a++);
a = (b++) + (++b);
return (0);
6 1
What will be the output of the below code snippet?
#include <stdio.h>
int main()
{
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
int a = 15, b;
b = (a++) + (a++);
a = (b++) + (b++);
return (0);
7 1
What will be the output of the program
#include<stdio.h>
void main()
printf("%d", sizeof(number));
8 1
What will be the output of the program
#include<stdio.h>
void main()
{
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
printf("%d", sizeof("program"));
10 1
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = -5;
i = i / 3;
printf("%d\n", i);
return 0;
}
11 1
What will be the output of the following C code?
#include <stdio.h>
int main()
int i = 0, k;
if (i == 0)
goto label;
}
5 1
What is the output of the following program?
int main()
int a=1;
switch(a)
{
printf("GATE-CSE");
case 0: printf("Zero");
case 1: printf("One");
default: printf("None");
}
return 0;
6 4
Write a C Program to print the following pattern
7 4
Write a C Program to print the following pattern
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
8 1
What is the output of the following program?
#include<stdio.h>
void main()
int colour = 2;
switch (colour) {
case 0:
printf("Black"); break;
case 1:
printf("Red");
case 2:
printf("Aqua"); break;
case 3:
printf("Green"); break;
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
default:
printf("Other");
}
9 1
Write the output of the below program:
#include<stdio.h>
void main()
int i = 10;
static int x = i;
if (x == i)
printf("equal");
printf("less than");
else
printf("greater than");
}
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
10 1
Write the output of the below program:
#include <stdio.h>
int main() {
int i;s
for (i = 0; ; i++) {
printf("%d\n", i);
return 0;
11 3
Write a C program to accept a year as user input and
check whether this year is leap year or not. Show the
message accordingly. (Note: Use appropriate variable
names and write comment in each line of code for
understanding)
12 1
What will be the output of the following program, in case
of any error also mention the reason?
int main(void)
main();
return -1;
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
13 1
How many iterations are needed to search an element in
a sorted array of n elements in an average case
scenario?
1 1
2 3 5
8 13 21 34
16 3
Write a C program to check whether a given number is
an Armstrong number. Number is given as user input.
(Hint: Armstrong number is a number that is equal to
the sum of its own digits each raised to the power of
the number of digits.
A
A B
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
A B C
18 3
Write a C program to reverse the digits of an input
number. Print the reversed number.
19 3
Write a C program to print an input number in words.
Unit 4 : Arrays
1 3
Write a C program to initialize an array of floating point
number and find the average of the elements in
the array.
2 4
Write a C program to initialize an array of floating point
numbers and sort the elements in the array in
descending order.
Sl Question Mark Q C ILO KD C HOT Reso
s T O D s/LO urce
Ts s&
Hints
3 4
Write a C program to initialize an array of floating point
numbers and sort the elements in the array in
ascending order
4 1
What is the index of the first element in a C array?(a)
-1 (b) 0 (c) 1 (d) depends on compiler
main()
{
int a[3] = {1, 2};
printf("%d", a[2]);
}
(a) 0 (b) 1 (c) 2 (d) garbage value