EContent 2 2025 09 12 10 30 08 PPS1 Manualpdf 2025 07 24 10 06 48
EContent 2 2025 09 12 10 30 08 PPS1 Manualpdf 2025 07 24 10 06 48
Lab Manual
Programming for Problem Solving-I
2BTES101
Name: ___________________________________________________
Enrolment: ________________________________________________
School: ___________________________________________________
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
CERTIFICATE
Institute Seal
1
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Index
Sr. Practical AIM Date Sign
No.
1 Write a program to calculate simple interest (i =
(p*r*n)/100)
2 Write a program that accepts centigrade and converts
it into Fahrenheit (f=1.8*c +32)
3 Write a program to demonstrate the use of Arithmetic
operators by getting two numbers from the user
4 Write a program that accepts a number from the
keyboard and find weather the number is
ODD or EVEN using Conditional operators
5 Write a program to demonstrate the use of increment
and decrement operators.
6 Write a program to demonstrate the use of shorthand
operators
7 Write a program to demonstrate the use of sizeof() of
operator.
8 Write a program that accepts three numbers from the
user and print the maximum of them
9 Demonstrate the use of the GOTO statement
10 Write a c program to prepare a pay slip using the
following data. Da = 10% of basic, Hra = 7.50% of basic,
Ma = 300, Pf = 12.50% of basic, Gross = basic + Da +
Hra + Ma, Nt = Gross – Pf
11 Write a program to read marks from the keyboard and
your program should display an equivalent grade
according to the following table (if-else ladder)
12 Write a C program to find factorial of a given number
13 Write a program that do sum=1+3+5+.......N terms Print
value of Sum.
14 Write a program to accept one number from the user.
i) Display reverse of that number. ii) Find if it is
Armstrong or not.
15 Write a C program to display different Patterns
16 Write a program to accept 5 numbers in an array and
display it
17 Write a program to accept 9 numbers in form of a
matrix and display it in matrix form.
18 Write a program to accept 5 numbers in array and find
the maximum and minimum values of it.
19 Write a C program to find 1+1/2+1/3+1/4+....+1/n
20 Write a program to count a number of vowels in a
given string.
2
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
#include <stdio.h>
int main() {
int n;
float p, r, I;
printf("\n Enter Amount :");
scanf("%f", & p);
printf("\n Enter No of Years :");
scanf("%d", & n);
printf("\n Enter Rate :");
scanf("%f", & r);
I = (p * r * n) / 100;
printf("\n Interest = %.2f", I);
return 0;
}
OUTPUT
EVALUATION:
Observation & Timely
Viva Total
Implementation Completion
4 2 4 10
Sign: Date:
3
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
float F, C;
printf("Enter Temperature in Celsius : ");
scanf("%f", & C);
F = (C * 1.8) + 32;
printf("\n %.2f Celsius = %.2f Fahrenheit", C, F);
return 0;
}
OUTPUT
EVALUATION:
Sign: Date:
4
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
#include <stdio.h>
int main() {
// Declare variables to store the two numbers
float num1, num2;
return 0;
}
OUTPUT
Enter the first number: 10
Enter the second number: 5
Addition: 10.00 + 5.00 = 15.00
Subtraction: 10.00 - 5.00 = 5.00
Multiplication: 10.00 * 5.00 = 50.00
Division: 10.00 / 5.00 = 2.00
EVALUATION:
Sign: Date:
5
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Practical 4: Write a program that accepts a number from the keyboard and
find weather the number is ODD or EVEN using Conditional operators
#include <stdio.h>
int main() {
// Declare variable to store the number
int number;
return 0;
}
OUTPUT
Enter a number: 4
4 is EVEN
Enter a number: 7
7 is ODD
EVALUATION:
Sign: Date:
6
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
// Declare variables
int num;
// Demonstrate post-increment
printf("Value of num after post-increment (num++): %d\n", num++);
printf("Value of num after post-increment operation: %d\n", num);
// Demonstrate pre-increment
printf("Value of num after pre-increment (++num): %d\n", ++num);
// Demonstrate post-decrement
printf("Value of num after post-decrement (num--): %d\n", num--);
printf("Value of num after post-decrement operation: %d\n", num);
// Demonstrate pre-decrement
printf("Value of num after pre-decrement (--num): %d\n", --num);
return 0;
}
7
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
OUTPUT
Initial value of num: 10
Value of num after post-increment (num++): 10
Value of num after post-increment operation: 11
Value of num after pre-increment (++num): 12
Value of num after post-decrement (num--): 12
Value of num after post-decrement operation: 11
Value of num after pre-decrement (--num): 10
EVALUATION:
Sign: Date:
8
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
// Declare and initialize variables
int num = 10;
return 0;
}
9
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
OUTPUT
Initial value of num: 10
After num += 5: 15
After num -= 3: 12
After num *= 2: 24
After num /= 4: 6
After num %= 3: 0
EVALUATION:
Sign: Date:
10
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
// Declare variables of different types
char c;
int i;
float f;
double d;
long l;
long long ll;
short s;
return 0;
}
OUTPUT
11
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
EVALUATION:
Sign: Date:
12
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Practical 8: Write a program that accepts three numbers from the user and
print the maximum of them.
#include <stdio.h>
int main() {
// Declare variables to store the three numbers
int num1, num2, num3;
return 0;
}
13
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
OUTPUT
Enter the first number: 5
Enter the second number: 8
Enter the third number: 3
The maximum of the three numbers is: 8
EVALUATION:
Sign: Date:
14
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
int num;
return 0;
}
OUTPUT
Enter a number (negative to exit): 5
You entered: 5
Enter another number (negative to exit): 8
You entered: 8
Exiting the program.
15
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
EVALUATION:
Sign: Date:
16
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Practical 10: Write a c program to prepare a pay slip using the following
data.
Da = 10% of basic, Hra = 7.50% of basic, Ma = 300,
Pf = 12.50% of basic, Gross = basic + Da + Hra + Ma, Nt = Gross – Pf
#include<stdio.h>
int main() {
float basic;
printf("\n Enter Basic Salary :");
scanf("%f", & basic);
printf("\n===================================");
printf("\n SALARY SLIP");
printf("\n===================================");
printf("\n Basic : %.2f", basic);
printf("\n DA : %.2f", basic * 0.10);
printf("\n HRA : %.2f", basic * 0.075);
printf("\n MA : %.2f", 300.00);
printf("\n===================================");
printf("\n GROSS : %.2f", basic + (basic * 0.10) + (basic * 0.075) + 300.00);
printf("\n===================================");
printf("\n PF : %.2f", basic * 0.125);
printf("\n===================================");
printf("\n NET : %.2f", (basic + (basic * 0.10) + (basic * 0.075) + 300.00) -
(basic * 0.125));
printf("\n===================================");
return 0;
}
17
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
OUTPUT
EVALUATION:
Sign: Date:
18
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Practical 11: Write a program to read marks from the keyboard and your
program should display an equivalent grade according to the following table
(if-else ladder)
Marks Grade
100 - 80 Distinction
79 - 60 First Class
59 - 40 Second Class
< 40 Fail
#include<stdio.h>
int main() {
int marks;
printf("\n Enter Marks between 0-100 :");
scanf("%d", & marks);
if (marks > 100 || marks < 0) {
printf("\n Your Input is out of Range");
} else if (marks >= 80) {
printf("\n You got Distinction");
} else if (marks >= 60) {
printf("\n You got First Class");
} else if (marks >= 40) {
printf("\n You got Second Class");
} else {
printf("\n You got Fail");
}
return 0;
}
OUTPUT
EVALUATION:
Sign: Date:
19
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
int num;
unsigned long long result;
return 0;
}
OUTPUT
Enter a number to find its factorial: 5
Factorial of 5 is 120
EVALUATION:
Sign: Date:
20
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
int N, sum = 0;
return 0;
}
OUTPUT
Enter the number of terms: 5
Sum of the series up to 5 terms is: 25
EVALUATION:
Sign: Date:
21
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Practical 14: Write a program to accept one number from the user. i) Display
reverse of that number. ii)Find if it is Armstrong or not.
#include <stdio.h>
#include <math.h>
while (temp != 0) {
remainder = temp % 10;
sum += pow(remainder, n);
temp /= 10;
}
while (num != 0) {
remainder = num % 10;
reversed = reversed * 10 + remainder;
num /= 10;
}
return reversed;
}
int main() {
int num;
22
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
return 0;
}
OUTPUT
Enter a number: 153
Reverse of the number: 351
153 is an Armstrong number.
EVALUATION:
Sign: Date:
23
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
int rows;
// Get the number of rows for the patterns from the user
printf("Enter the number of rows: ");
scanf("%d", &rows);
24
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
printf("\nPyramid Pattern:\n");
pyramid(rows);
return 0;
}
OUTPUT:
Enter the number of rows: 5
Pyramid Pattern:
*
***
*****
*******
*********
EVALUATION:
Sign: Date:
25
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Practical 16: Write a program to accept 5 numbers in an array and display it.
#include <stdio.h>
int main() {
// Declare an array to store 5 numbers
int numbers[5];
return 0;
}
OUTPUT
Enter 5 numbers:
Number 1: 10
Number 2: 20
Number 3: 30
Number 4: 40
Number 5: 50
The numbers you entered are:
10 20 30 40 50
EVALUATION:
Sign: Date:
26
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
#define ROWS 3
#define COLS 3
int main() {
// Declare a 2D array (matrix) to store 9 numbers
int matrix[ROWS][COLS];
return 0;
}
OUTPUT
Enter 9 numbers for the matrix (3x3):
Enter element at position [1][1]: 1
Enter element at position [1][2]: 2
Enter element at position [1][3]: 3
Enter element at position [2][1]: 4
Enter element at position [2][2]: 5
Enter element at position [2][3]: 6
Enter element at position [3][1]: 7
Enter element at position [3][2]: 8
Enter element at position [3][3]: 9
27
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
EVALUATION:
Sign: Date:
28
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Practical 18: Write a program to accept 5 numbers in array and find the
maximum and minimum values of it.
#include <stdio.h>
#define SIZE 5
int main() {
int numbers[SIZE];
int max, min;
// Initialize max and min with the first element of the array
max = min = numbers[0];
return 0;
}
OUTPUT
Enter 5 numbers:
Number 1: 10
Number 2: 5
Number 3: 8
Number 4: 15
Number 5: 3
Maximum value: 15
29
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
Minimum value: 3
EVALUATION:
Sign: Date:
30
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
int n;
double sum = 0.0;
return 0;
}
OUTPUT
Enter a positive integer: 5
Sum of the series 1 + 1/2 + 1/3 + ... + 1/5 is: 2.283334
EVALUATION:
Sign: Date:
31
Programming for Problem Solving-I [2BTES101] Dr. Subhash University
int main() {
char str[100];
int count = 0;
return 0;
}
OUTPUT
Enter a string: Hello, World!
Number of vowels in the string: 3
EVALUATION:
Sign: Date:
32