Bsc CSIT Semester 1 – C Programming – Unit 5: Control Statement (4 Hrs.)
Comprehensive questions and detailed answers for Unit 5: Control Statement (4 Hrs.). Perfect for exam preparation and concept clarity.
Write a program to display first 50 prime numbers.
Write a program to display the following series up to 25 terms but do not print the 7th term. 2 x 3, 3 x 5, 4 x 7, 5 x 9…
Trace the output
#include<conio.h>
#include<stdio.h>
void main(){
int i =0,k;
for(k=5;k>=0;k-){
i=i+k;
}
printf(“%d\t”,i);
getch();
}
Why do we need a break and continue statement? Define formal argument and actual argument in function with examples. Identify and list the errors in the following code.
1int main(){
2 int a,b,c
3 scanf("%d%d%d, &a, &b, &c);
4 sum(a, b, c);
5 return -1;
6}
7void sum(int x, int y, int z){
8 int sum;
9 sum = a + b + c;
10 return sum;
11}Write a program to demonstrate the following menu-driven program. The user will provide an integer and alphabet for making choice and the corresponding task has to be performed according as follow: A. Find Odd or Even B. Find Positive or Negative C. Find the Factorial value D. Exit The choice will be displayed until the user will give “D” as a choice.
What do you mean by jump statement? Explain each jump statement with example. Write a program to check whether a number entered is prime or not.
Write a program to print largest among three numbers entered by the user.
What do you mean by looping? Explain while loop with suitable example. Compare while loop with do-while loop. Write a program to find sum and average of first n natural numbers.
Write a program to display first n prime numbers.
What is looping statement? Discuss different looping statements with suitable example of each.
What is break statement? Discuss with example. How the break statement is different from continue statement?
Write a program to check whether a number entered is even or odd.
Write a program to calculate sum of first 10 odd numbers.
Discuss different types of if statements with example of each. Differentiate if statement with switch statement.
Sample Questions
Write a program to display the following series up to 25 terms but do not print the 7th term. 2 x 3, 3 x 5, 4 x 7, 5 x 9…
Trace the output $\quad$ include<conio.h> $\quad$include<stdio.h> $\quad$void main(){ $\quad$ int i =0,k; $\quad$ for(k=5;k>=0;k–){ $\quad$ i=i+k; $\quad$ } $\quad$ printf(“%d\t”,i); $\quad$ getch();
Why do we need a break and continue statement? Define formal argument and actual argument in function with examples. Identify and list the errors in the following code. c int main(){ int a,b,c
Write a program to demonstrate the following menu-driven program. The user will provide an integer and alphabet for making choice and the corresponding task has to be performed according as follow: $\
And more questions available on this page.