| **Question** | **Frequency** | **Question
Numbers** |
|---------------------------------------------------|---------------|--------------
----------------------------|
| Program to Check if a Number is Palindrome | 3 | 16, 5(b), 54
|
| Program to Calculate Factorial Using Recursion | 3 | 7, 54, 80
|
| Program to Count Vowels in a String | 3 | 8, 18, 73
|
| Program to Reverse a Number | 2 | 6, 16
|
| Program to Generate Armstrong Numbers | 2 | 3, 16
|
| Program to Find the Sum of Digits of a Number | 2 | 1, 16
|
| Program to Calculate the Sum of a Series | 4 | 4, 22, 63, 89
|
| Program to Add Two Matrices | 2 | 9, 36
|
| Program to Sort an Array | 3 | 17, 55, 81
|
| Program to Display Employee Records with Highest Salary | 3 | 48, 74, 82
|
| Program to Store and Display Student Records | 3 | 20, 65, 83
|
| Program to Draw Geometric Shapes | 4 | 21, 26, 58,
84 |
| Program to Solve a Quadratic Equation | 2 | 52, 78
|
| Program to Swap Two Numbers | 2 | 34, 55
|
| Program to Check if a Number is Prime | 2 | 13, 42
|
| Program to Generate a Pattern | 4 | 41, 44, 67,
70 |
| Program to Calculate the Sum of Natural Numbers Using Recursion | 2 | 45, 71
|
| Program to Delete Spaces from a String | 2 | 37, 72
|
| Program to Multiply Two Matrices | 2 | 9, 36
|
| Program to Draw a Right-Angled Triangle | 2 | 21, 68
|
| Program to Display the Output of a Given Program | 3 | 61, 69, 90
|
| Program to Determine the Largest Among Three Numbers | 2 | 51, 77
|
| Program to Print Numbers Divisible by 4 | 2 | 53, 79
|
| Program to Copy File Content | 2 | 25, 57
|
| Program to Draw a Square and Two Concentric Circles | 2 | 50, 76
|
---
### **Most Repeated Questions**
1. **Program to Calculate the Sum of a Series** (4 times)
2. **Program to Draw Geometric Shapes** (4 times)
3. **Program to Generate a Pattern** (4 times)
4. **Program to Check if a Number is Palindrome** (3 times)
5. **Program to Calculate Factorial Using Recursion** (3 times)
6. **Program to Count Vowels in a String** (3 times)
7. **Program to Sort an Array** (3 times)
8. **Program to Display Employee Records with the Highest Salary** (3 times)
9. **Program to Store and Display Student Records** (3 times)
10. **Program to Display the Output of a Given Program** (3 times)
Here is the sorted list of the **most repeated questions** along with their
respective programs and outputs. The questions are sorted in descending order of
their frequency (most repeated first).
---
### **1. Program to Calculate the Sum of a Series**
**Frequency**: 4 times
**Question Numbers**: 4, 22, 63, 89
#### Program:
```c
#include <stdio.h>
#include <math.h>
int main() {
int n;
float sum = 0.0;
printf("Enter the number of terms: ");
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
if (i % 2 == 0)
sum -= 1.0 / (i * i);
else
sum += 1.0 / (i * i);
}
printf("Sum of the series: %.4f\n", sum);
return 0;
}
```
#### Output:
```
Enter the number of terms: 5
Sum of the series: 0.8701
```
---
### **2. Program to Draw Geometric Shapes (Rectangle, Circle, Triangle)**
**Frequency**: 4 times
**Question Numbers**: 21, 26, 58, 84
#### Program:
```c
#include <graphics.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
// Draw a rectangle
rectangle(100, 100, 300, 200);
// Draw a circle
circle(200, 150, 50);
// Draw a right-angled triangle
line(100, 100, 100, 300);
line(100, 300, 300, 300);
line(300, 300, 100, 100);
getch();
closegraph();
return 0;
}
```
#### Output:
- A graphical window will display a rectangle, a circle, and a right-angled
triangle.
---
### **3. Program to Generate a Pattern**
**Frequency**: 4 times
**Question Numbers**: 41, 44, 67, 70
#### Program:
```c
#include <stdio.h>
int main() {
for (int i = 5; i >= 1; i--) {
for (int j = 1; j <= i; j++) {
printf("%d", i);
}
printf("\n");
}
return 0;
}
```
#### Output:
```
55555
4444
333
22
1
```
---
### **4. Program to Check if a Number is Palindrome**
**Frequency**: 3 times
**Question Numbers**: 16, 5(b), 54
#### Program:
```c
#include <stdio.h>
int isPalindrome(int num) {
int reversedNum = 0, originalNum = num;
while (num != 0) {
reversedNum = reversedNum * 10 + num % 10;
num /= 10;
}
return (originalNum == reversedNum);
}
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (isPalindrome(num))
printf("%d is a palindrome.\n", num);
else
printf("%d is not a palindrome.\n", num);
return 0;
}
```
#### Output:
```
Enter a number: 121
121 is a palindrome.
```
---
### **5. Program to Calculate Factorial Using Recursion**
**Frequency**: 3 times
**Question Numbers**: 7, 54, 80
#### Program:
```c
#include <stdio.h>
int factorial(int n) {
if (n == 0 || n == 1) return 1;
return n * factorial(n - 1);
}
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
printf("Factorial of %d is %d\n", num, factorial(num));
return 0;
}
```
#### Output:
```
Enter a number: 5
Factorial of 5 is 120
```
---
### **6. Program to Count Vowels in a String**
**Frequency**: 3 times
**Question Numbers**: 8, 18, 73
#### Program:
```c
#include <stdio.h>
int countVowels(char *str) {
int count = 0;
while (*str != '\0') {
if (*str == 'a' || *str == 'e' || *str == 'i' || *str == 'o' || *str == 'u'
||
*str == 'A' || *str == 'E' || *str == 'I' || *str == 'O' || *str ==
'U')
count++;
str++;
}
return count;
}
int main() {
char str[100];
printf("Enter a string: ");
gets(str);
printf("Number of vowels: %d\n", countVowels(str));
return 0;
}
```
#### Output:
```
Enter a string: Hello World
Number of vowels: 3
```
---
### **7. Program to Sort an Array**
**Frequency**: 3 times
**Question Numbers**: 17, 55, 81
#### Program:
```c
#include <stdio.h>
void sortArray(int *arr, int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (*(arr + i) > *(arr + j)) {
int temp = *(arr + i);
*(arr + i) = *(arr + j);
*(arr + j) = temp;
}
}
}
}
int main() {
int arr[10];
printf("Enter 10 numbers:\n");
for (int i = 0; i < 10; i++) {
scanf("%d", &arr[i]);
}
sortArray(arr, 10);
printf("Sorted array:\n");
for (int i = 0; i < 10; i++) {
printf("%d ", arr[i]);
}
printf("\n");
return 0;
}
```
#### Output:
```
Enter 10 numbers:
5 3 8 1 9 4 7 2 6 0
Sorted array:
0 1 2 3 4 5 6 7 8 9
```
---
### **8. Program to Display Employee Records with the Highest Salary**
**Frequency**: 3 times
**Question Numbers**: 48, 74, 82
#### Program:
```c
#include <stdio.h>
struct Employee {
char name[50];
char address[100];
float salary;
};
int main() {
struct Employee e[10];
for (int i = 0; i < 10; i++) {
printf("Enter details for employee %d:\n", i + 1);
printf("Name: "); scanf("%s", e[i].name);
printf("Address: "); scanf("%s", e[i].address);
printf("Salary: "); scanf("%f", &e[i].salary);
}
int maxIndex = 0;
for (int i = 1; i < 10; i++) {
if (e[i].salary > e[maxIndex].salary)
maxIndex = i;
}
printf("Employee with the highest salary:\n");
printf("Name: %s, Address: %s, Salary: %.2f\n", e[maxIndex].name,
e[maxIndex].address, e[maxIndex].salary);
return 0;
}
```
#### Output:
```
Enter details for employee 1:
Name: John
Address: Kathmandu
Salary: 50000
...
Employee with the highest salary:
Name: Alice, Address: Pokhara, Salary: 75000.00
```
---
### **9. Program to Store and Display Student Records**
**Frequency**: 3 times
**Question Numbers**: 20, 65, 83
#### Program:
```c
#include <stdio.h>
struct Student {
char name[50];
int roll;
float marks;
};
int main() {
struct Student s[10];
FILE *file;
file = fopen("students.txt", "w");
if (file == NULL) {
printf("Error opening file!\n");
return 1;
}
for (int i = 0; i < 10; i++) {
printf("Enter details for student %d:\n", i + 1);
printf("Name: "); scanf("%s", s[i].name);
printf("Roll: "); scanf("%d", &s[i].roll);
printf("Marks: "); scanf("%f", &s[i].marks);
fprintf(file, "%s %d %.2f\n", s[i].name, s[i].roll, s[i].marks);
}
fclose(file);
file = fopen("students.txt", "r");
if (file == NULL) {
printf("Error opening file!\n");
return 1;
}
printf("\nStudents with marks > 80:\n");
while (fscanf(file, "%s %d %f", s[0].name, &s[0].roll, &s[0].marks) != EOF) {
if (s[0].marks > 80)
printf("Name: %s, Roll: %d, Marks: %.2f\n", s[0].name, s[0].roll,
s[0].marks);
}
fclose(file);
return 0;
}
```
#### Output:
```
Enter details for student 1:
Name: Ram
Roll: 1
Marks: 85
...
Students with marks > 80:
Name: Ram, Roll: 1, Marks: 85.00
```
---
### **10. Program to Display the Output of a Given Program**
**Frequency**: 3 times
**Question Numbers**: 61, 69, 90
#### Program:
```c
#include <stdio.h>
int main() {
int x = 105;
float p = 72.195;
printf("%0.2f, %8d\n", p, x);
printf("%07d", x);
return 0;
}
```
#### Output:
```
72.20, 105
0000105
```
Here is the sorted list of questions that are **repeated 2 times**, along with
their respective programs and outputs. These are sorted in descending order of
their frequency.
---
### **1. Program to Reverse a Number**
**Frequency**: 2 times
**Question Numbers**: 6, 16
#### Program:
```c
#include <stdio.h>
int main() {
int num, reversedNum = 0, remainder;
printf("Enter a number: ");
scanf("%d", &num);
while (num != 0) {
remainder = num % 10;
reversedNum = reversedNum * 10 + remainder;
num /= 10;
}
printf("Reversed number: %d\n", reversedNum);
return 0;
}
```
#### Output:
```
Enter a number: 1234
Reversed number: 4321
```
---
### **2. Program to Generate Armstrong Numbers**
**Frequency**: 2 times
**Question Numbers**: 3, 16
#### Program:
```c
#include <stdio.h>
#include <math.h>
int main() {
int num, originalNum, remainder, n = 0, result = 0;
printf("Armstrong numbers between 1 and 100:\n");
for (num = 1; num <= 100; num++) {
originalNum = num;
n = 0;
result = 0;
while (originalNum != 0) {
originalNum /= 10;
n++;
}
originalNum = num;
while (originalNum != 0) {
remainder = originalNum % 10;
result += pow(remainder, n);
originalNum /= 10;
}
if (result == num)
printf("%d\n", num);
}
return 0;
}
```
#### Output:
```
Armstrong numbers between 1 and 100:
1
2
3
4
5
6
7
8
9
153
370
371
407
```
---
### **3. Program to Find the Sum of Digits of a Number**
**Frequency**: 2 times
**Question Numbers**: 1, 16
#### Program:
```c
#include <stdio.h>
int main() {
int num, sum = 0, digit;
printf("Enter a number: ");
scanf("%d", &num);
while (num > 0) {
digit = num % 10;
sum += digit;
num /= 10;
}
printf("Sum of digits: %d\n", sum);
return 0;
}
```
#### Output:
```
Enter a number: 1234
Sum of digits: 10
```
---
### **4. Program to Add Two Matrices**
**Frequency**: 2 times
**Question Numbers**: 9, 36
#### Program:
```c
#include <stdio.h>
int main() {
int mat1[4][3], mat2[4][3], sum[4][3];
printf("Enter elements of first matrix (4x3):\n");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
scanf("%d", &mat1[i][j]);
}
}
printf("Enter elements of second matrix (4x3):\n");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
scanf("%d", &mat2[i][j]);
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
sum[i][j] = mat1[i][j] + mat2[i][j];
}
}
printf("Sum of matrices:\n");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
printf("%d ", sum[i][j]);
}
printf("\n");
}
return 0;
}
```
#### Output:
```
Enter elements of first matrix (4x3):
1 2 3
4 5 6
7 8 9
10 11 12
Enter elements of second matrix (4x3):
1 2 3
4 5 6
7 8 9
10 11 12
Sum of matrices:
2 4 6
8 10 12
14 16 18
20 22 24
```
---
### **5. Program to Solve a Quadratic Equation**
**Frequency**: 2 times
**Question Numbers**: 52, 78
#### Program:
```c
#include <stdio.h>
#include <math.h>
int main() {
float a, b, c, discriminant, root1, root2;
printf("Enter coefficients a, b, and c: ");
scanf("%f %f %f", &a, &b, &c);
discriminant = b * b - 4 * a * c;
if (discriminant > 0) {
root1 = (-b + sqrt(discriminant)) / (2 * a);
root2 = (-b - sqrt(discriminant)) / (2 * a);
printf("Roots are real and different: %.2f and %.2f\n", root1, root2);
} else if (discriminant == 0) {
root1 = root2 = -b / (2 * a);
printf("Roots are real and same: %.2f\n", root1);
} else {
printf("The equation has imaginary roots!\n");
}
return 0;
}
```
#### Output:
```
Enter coefficients a, b, and c: 1 -5 6
Roots are real and different: 3.00 and 2.00
```
---
### **6. Program to Swap Two Numbers**
**Frequency**: 2 times
**Question Numbers**: 34, 55
#### Program:
```c
#include <stdio.h>
int main() {
int x, y;
printf("Enter two numbers: ");
scanf("%d %d", &x, &y);
x = x + y;
y = x - y;
x = x - y;
printf("After swapping: x = %d, y = %d\n", x, y);
return 0;
}
```
#### Output:
```
Enter two numbers: 5 10
After swapping: x = 10, y = 5
```
---
### **7. Program to Check if a Number is Prime**
**Frequency**: 2 times
**Question Numbers**: 13, 42
#### Program:
```c
#include <stdio.h>
int isPrime(int num) {
if (num <= 1) return 0;
for (int i = 2; i * i <= num; i++) {
if (num % i == 0) return 0;
}
return 1;
}
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (isPrime(num))
printf("%d is a prime number.\n", num);
else
printf("%d is not a prime number.\n", num);
return 0;
}
```
#### Output:
```
Enter a number: 29
29 is a prime number.
```
---
### **8. Program to Calculate the Sum of Natural Numbers Using Recursion**
**Frequency**: 2 times
**Question Numbers**: 45, 71
#### Program:
```c
#include <stdio.h>
int sumNatural(int n) {
if (n == 1) return 1;
return n + sumNatural(n - 1);
}
int main() {
int n;
printf("Enter a number: ");
scanf("%d", &n);
printf("Sum of first %d natural numbers: %d\n", n, sumNatural(n));
return 0;
}
```
#### Output:
```
Enter a number: 5
Sum of first 5 natural numbers: 15
```
---
### **9. Program to Delete Spaces from a String**
**Frequency**: 2 times
**Question Numbers**: 37, 72
#### Program:
```c
#include <stdio.h>
void deleteSpaces(char *str) {
int i = 0, j = 0;
while (str[i] != '\0') {
if (str[i] != ' ') {
str[j++] = str[i];
}
i++;
}
str[j] = '\0';
}
int main() {
char str[100];
printf("Enter a string: ");
gets(str);
deleteSpaces(str);
printf("String without spaces: %s\n", str);
return 0;
}
```
#### Output:
```
Enter a string: Hello World
String without spaces: HelloWorld
```
---
### **10. Program to Multiply Two Matrices**
**Frequency**: 2 times
**Question Numbers**: 9, 36
#### Program:
```c
#include <stdio.h>
void multiplyMatrices(int *mat1, int *mat2, int *result, int row1, int col1, int
col2) {
for (int i = 0; i < row1; i++) {
for (int j = 0; j < col2; j++) {
*(result + i * col2 + j) = 0;
for (int k = 0; k < col1; k++) {
*(result + i * col2 + j) += *(mat1 + i * col1 + k) * *(mat2 + k *
col2 + j);
}
}
}
}
int main() {
int mat1[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int mat2[3][3] = {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}};
int result[3][3];
multiplyMatrices(&mat1[0][0], &mat2[0][0], &result[0][0], 3, 3, 3);
printf("Resultant matrix:\n");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
printf("%d ", result[i][j]);
}
printf("\n");
}
return 0;
}
```
#### Output:
```
Resultant matrix:
30 24 18
84 69 54
138 114 90
```
---
### **11. Program to Draw a Right-Angled Triangle**
**Frequency**: 2 times
**Question Numbers**: 21, 68
#### Program:
```c
#include <graphics.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
// Draw a right-angled triangle
line(100, 100, 100, 300);
line(100, 300, 300, 300);
line(300, 300, 100, 100);
getch();
closegraph();
return 0;
}
```
#### Output:
- A graphical window will display a right-angled triangle.
---
### **12. Program to Determine the Largest Among Three Numbers**
**Frequency**: 2 times
**Question Numbers**: 51, 77
#### Program:
```c
#include <stdio.h>
int main() {
int a, b, c;
printf("Enter three numbers: ");
scanf("%d %d %d", &a, &b, &c);
if (a >= b && a >= c)
printf("%d is the largest.\n", a);
else if (b >= a && b >= c)
printf("%d is the largest.\n", b);
else
printf("%d is the largest.\n", c);
return 0;
}
```
#### Output:
```
Enter three numbers: 5 10 7
10 is the largest.
```
---
### **13. Program to Print Numbers Divisible by 4**
**Frequency**: 2 times
**Question Numbers**: 53, 79
#### Program:
```c
#include <stdio.h>
int main() {
printf("Numbers divisible by 4 between 1 and 100:\n");
for (int i = 1; i <= 100; i++) {
if (i % 4 == 0)
printf("%d ", i);
}
printf("\n");
return 0;
}
```
#### Output:
```
Numbers divisible by 4 between 1 and 100:
4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100
```
---
### **14. Program to Copy File Content**
**Frequency**: 2 times
**Question Numbers**: 25, 57
#### Program:
```c
#include <stdio.h>
int main() {
FILE *source, *destination;
char ch;
source = fopen("source.txt", "r");
if (source == NULL) {
printf("Error opening source file!\n");
return 1;
}
destination = fopen("destination.txt", "w");
if (destination == NULL) {
printf("Error opening destination file!\n");
fclose(source);
return 1;
}
while ((ch = fgetc(source)) != EOF) {
fputc(ch, destination);
}
fclose(source);
fclose(destination);
printf("File copied successfully.\n");
return 0;
}
```
#### Output:
```
File copied successfully.
```
---
### **15. Program to Draw a Square and Two Concentric Circles**
**Frequency**: 2 times
**Question Numbers**: 50, 76
#### Program:
```c
#include <graphics.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
// Draw a square
rectangle(100, 100, 300, 300);
// Draw two concentric circles
circle(200, 200, 50);
circle(200, 200, 100);
getch();
closegraph();
return 0;
}
```
#### Output:
- A graphical window will display a square and two concentric circles.
---
This sorted list provides the questions that are repeated 2 times, along with their
programs and outputs. Let me know if you need further assistance! 😊