You are on page 1of 2

The SMART SCHOOL PWD CAMPUS

First Term Examination-2023


Name: _______________________________ Class: 10th
SECTION B (22)
Attempt all the questions.
i. Rewrite the code using Conditional Operator.
if (marks > 40)
printf(“PASS”);
else
printf(“FAIL”);
OR
Write a C program to print sum of odd numbers from 1 to 100.
ii. Write down the output of the following program.

OR
Define Nested Selection Structure.
iii. Write down the difference between while loop and do-while loop.
OR
Rewrite the following program using switch statement:
void main(void) {
char grade;
printf("\n Enter the grade of a student from A-C");
if(grade=='A' grade=='a')
printf('\n Excellent");
else if (grade=='A' grade=='b')
printf("\n Well done");
else if (grade=='C' grade=='c')
printf("\n poor performance");
else
printf("\n Invalid Letter");
}
iv. Write down the output of the following code
int n, count, sum;
n=28; count=15; sum=30;
if (n<25) { count=count+5
printf("\nCount=%d", count); }
else { count=count-5;
sum=sum+n;
printf("\nCount=%d",count);
printf(\nSum=%d",sum); }
v. Rewrite the following code using for loop:
int sum = 0, num= 0;
do {
sum = sum + num;
printf (“Enter an integer value”);
scanf(“%d”, &num);
} while (num > = 0 && num < = 15);
vi. Write a program in C to find the factorial of a number.
vii. Write a program in C to generate the following series using for() loop.
5 10 15 20 25 30 35 40 45 50
viii. Write a C program to print sum of odd numbers from 1 to 100.
ix. Write down the difference between for loop and while loop.
OR
Write down the difference between else-if and switch selection structures.
x. Find the errors in the following code.

xi. Write down the output of the following code.

OR
Write down the statement using if-else statement. k=(a +b>20)?a+3;a -b ;
SECTION C
Q3. Attempt all of the following long questions. (4 x 5 = 20)
1. Write a C program to print the following pattern using nesting loop.
54321
5432
543
54
5
2. Rewrite the following code after removing the errors:
# include < std.h>
# include < conio.h>
void main ( ); { int p, s;
printf(“\n Enter a number:);
scanf(“%d”, p);
s=p%2;
if(s=0) printf(“even number %d”, p)
else printf(“odd number %d”, p);
getch( ); }
3. Write a C program to input two numbers and find the GCD (Greatest Common Deviser) of the numbers.
OR
Write a program that take month number as input (from 1 to 12) and print number of days in that
month. If wrong number is given, then show error message.
4. Write a program that takes a number as input and print whether it is prime or not.
5. Explain break and continue statements. OR Program to input 5 positive numbers negative number
should not be added. (loop will be used.)

You might also like