RHS-FPL Prelim Exam
RHS-FPL Prelim Exam
Q1.A Explain the importance of program design tools like algorithms and flowcharts. [5]
B Write an algorithm and draw a flowchart to calculate the factorial of a number [5]
C What are C tokens? List and explain different types of C tokens with examples. [4]
OR
Q2. A Discuss the history and importance of the C programming language. [5]
B Define Symbolic Constants, declaring a Variable as Constant [5]
C What is the difference between constants and volatile variables in C? [4]
OR
Q4. A What are the different types of operators in C? Explain each type with examples. [5]
B Differentiate prefix and postfix operators with example [5]
C Write difference between Logical Operators and Assignment Operators with program
code. [4]
Q5. A Explain the use of if, else-if, and switch statements in C with examples. [5]
B Write a program using a switch statement to find the day of the week based on an [5]
Integer input.
C Write a program to find given number is positive or negative. [4]
OR
Q6. A Write a program to print the multiplication table of a given number using a for loop. [5]
B What are loops in C? Explain while, do-while, and for loops with examples. [5]
C What is the purpose of break and continue statements in C? Explain with examples [4]
Q7. A Explain the declaration and initialization of one-dimensional arrays in C with [5]
examples.
B Write a program to find the largest element in an array of integers. [5]
C Define a two-dimensional array in C. Write a program to multiply two matrices. [4]
OR
Q8. A How are strings handled in C? Explain how to declare and initialize strings. Write a [5]
program to compare two strings using strcmp().
B Write a simple Program to calculate the result of any five subjects using an array. [5]
C Write any 4 Characteristics of Arrays and Strings [4]
Q9. A What is the need for user-defined functions in C? Explain with an example. [5]
B What is recursion? Write a recursive function to calculate the factorial of a number. [5]
C Explain the different categories of functions in C with examples: [4]
OR
Q10. A Define a structure in C. Write a program to store information about a student (name, [5]
roll number, and marks) using structures and display it.
B What is User Defined Functions: write in brief about Definition of Functions, Return [5]
Values and their Types, Function Calls, Function Declaration,
C Differentiate between Call by Value & Call by Reference with Example. [4]
Q.No.5B:
/**
* C program to print day of week using switch case
*/
#include <stdio.h>
int main()
{
int week;
switch(week)
{
case 1:
printf("Monday");
break;
case 2:
printf("Tuesday");
break;
case 3:
printf("Wednesday");
break;
case 4:
printf("Thursday");
break;
case 5:
printf("Friday");
break;
case 6:
printf("Saturday");
break;
case 7:
printf("Sunday");
break;
default:
printf("Invalid input! Please enter week number between 1-
7.");
}
return 0;
}
Q.No.5C:
#include <stdio.h>
int main() {
double num;
printf("Enter a number: ");
scanf("%lf", &num);
if (num <= 0.0) {
if (num == 0.0)
printf("You entered 0.");
else
printf("You entered a negative number.");
}
else
printf("You entered a positive number.");
return 0;
}
Q.No.6A:
#include <stdio.h>
int main() {
int n;
printf("Enter an integer: ");
scanf("%d", &n);
#include <stdio.h>
int main() {
int n;
double arr[100];
printf("Enter the number of elements (1 to 100): ");
scanf("%d", &n);
return 0;
}
Run Code
Output
This program takes n number of elements from the user and stores it in the arr array.
To find the largest element,
the first two elements of array are checked and the largest of these two elements are
placed in arr[0]
the first and third elements are checked and largest of these two elements is placed
in arr[0] .
this process continues until the first and last elements are checked
1. #include<stdio.h>
2. #include<stdlib.h>
3. int main(){
4. int a[10][10],b[10][10],mul[10][10],r,c,i,j,k;
5. system("cls");
6. printf("enter the number of row=");
7. scanf("%d",&r);
8. printf("enter the number of column=");
9. scanf("%d",&c);
10. printf("enter the first matrix element=\n");
11. for(i=0;i<r;i++)
12. {
13. for(j=0;j<c;j++)
14. {
15. scanf("%d",&a[i][j]);
16. }
17. }
18. printf("enter the second matrix element=\n");
19. for(i=0;i<r;i++)
20. {
21. for(j=0;j<c;j++)
22. {
23. scanf("%d",&b[i][j]);
24. }
25. }
26.
27. printf("multiply of the matrix=\n");
28. for(i=0;i<r;i++)
29. {
30. for(j=0;j<c;j++)
31. {
32. mul[i][j]=0;
33. for(k=0;k<c;k++)
34. {
35. mul[i][j]+=a[i][k]*b[k][j];
36. }
37. }
38. }
39. //for printing result
40. for(i=0;i<r;i++)
41. {
42. for(j=0;j<c;j++)
43. {
44. printf("%d\t",mul[i][j]);
45. }
46. printf("\n");
47. }
48. return 0;
49. }
QNO 8B:
#include <stdio.h>
int main()
{
float eng, phy, chem, math, comp;
float total, average, percentage;
return 0;
}
QNO 9B:
#include<stdio.h>
long int multiplyNumbers(int n);
int main() {
int n;
printf("Enter a positive integer: ");
scanf("%d",&n);
printf("Factorial of %d = %ld", n, multiplyNumbers(n));
return 0;
}
int main() {
students[1].roll_number = 5;
students[1].name = "Geeks5";
students[1].age = 10;
students[1].total_marks = 56.84;
students[2].roll_number = 2;
students[2].name = "Geeks2";
students[2].age = 11;
students[2].total_marks = 87.94;
students[3].roll_number = 4;
students[3].name = "Geeks4";
students[3].age = 12;
students[3].total_marks = 89.78;
students[4].roll_number = 3;
students[4].name = "Geeks3";
students[4].age = 13;
students[4].total_marks = 78.55;