PWC_question bank
PWC_question bank
PWC_question bank
Rasi patel
PROGRAMMING WITH C | Question bank
Unit 2: Basic input output and Control structure (14 marks) (4+5+5)
1. What will be the output of the following C code? (code might be random) (2 Marks)
#include <stdio.h>
void main()
{
int x = 5;
int y = x++ + 10;
printf("%d,%d",x,y);
}
2. What will be the output of the following C code? (2 Marks)
#include <stdio.h>
void main()
{
int a,b,c,d;
a=12;
b=21;
c= a++ +10;
d= --c;
printf("%d,%d",c,d);
}
3. What will be the output of the following C code? (2 Marks)
#include <stdio.h>
void main()
{
int x = 10;
if(x=5)
{
printf("In If block");
}
printf("End program");
}
4. Write down syntax for do..while loop and also draw the flowchart for it. (2 Marks)
5. Differentiate nested if-else and else-if ladder with proper example. (5 Marks)
Rasi patel
PROGRAMMING WITH C | Question bank
6. Write down Syntax of switch case and explain it with an example. (5 Marks)
7. Explain for loop with its syntax, flow chart and example. (5 Marks)
8. Explain while loop with its syntax, flow chart and example. (5 Marks)
9. Differentiate entry-controlled loop and exit-controlled loop with an example. (5 Marks)
10. Write a program to find smallest number among three numbers using nested if...else
statement. (5 Marks)
11. Write a C program to create basic calculator using switch case. (5 Marks)
12. Write a program to reverse a given integer number. (5 Marks)
13. Write a program to check the given number is Armstrong number or not. (5 Marks)
14. Write a program to print first N Fibonacci numbers. (5 marks)
15. Write a program to reverse a given integer number and also check for palindrome. (5 marks).
16. Write a program to print the following pattern using loop. (5 Marks)
****
***
**
*
17. Write a program to print the following pattern using loop. (5 Marks)
AAAAA
BBBB
CCC
DD
E
18. Write a program to print the following pattern.
*
**
***
****
*****
19. Write a program to read marks from keyboard and display equivalent grade according to
following data: (5 Marks)
Marks Grade
100 - 80 Distinction
79 - 60 First Class
59 - 40 Second Class
< 40 Fail
20. Write a program to print the following pattern using loop. (5 Marks)
1
22
333
4444
55555
Rasi patel
PROGRAMMING WITH C | Question bank
12. Write a program to find out the Maximum and Minimum number from given 10 numbers. (5
Marks)
13. Write a program to get n numbers and find sum and average of numbers. (5 Marks)
14. Write a program to find number of odd and even numbers from given n numbers. (5 Marks)
15. Write a program to sort given n numbers and display them in ascending and descending order.
Rasi patel