NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.
01
Program No.1
Aim:
To develop a C program that takes marks of three subjects from the user
and calculates the total, average, and grade.
Flowchart:
Algorithm:
Step 1: Start
Step 2: Declare variables subject1,
subject2, subject3, total, average,
grade
Step 3: Accept subject1, subject2,
subject3 from the user
Step 4: total = subject1 + subject2
+ subject3
Step 5: average = total / 3
Step 6: If average >= 90, grade = 'A'
Else if average >= 75, grade = 'B'
Else if average >= 60, grade = 'C'
Else if average >= 50, grade = 'D'
Else, grade = 'F'
Step 7: Print total, average, and
grade
Step 8: End
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.02
CODE:
OUTPUT:
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.03
Program No.2
Aim:
To design and implement a C program that displays the result of all
arithmetic, relational, and logical operations using two user inputs.
Algorithm:
Step 1: Start
Step 2: Declare int variables a, b
Step 3: Accept values of a and b from user
Step 4: Perform arithmetic operations and display results
Step 5: Perform relational operations and display results
Step 6: Perform logical operations and display results
Step 7: End
Flowchart:
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.04
CODE:
OUTPUT:
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.05
Program No.3
Aim: To design and implement a simple program that converts
temperature from Celsius to Fahrenheit and Fahrenheit to Celsius based
on user choice.
Algorithm:
Step 1: Start
Step 2: Display options: 1. Celsius to Fahrenheit 2. Fahrenheit to Celsius
Step 3: Accept user choice
Step 4: If choice == 1: Accept temperature in Celsius Compute Fahrenheit
= (C × 9/5) + 32 Display Fahrenheit Else if choice == 2: Accept temperature
in Fahrenheit Compute Celsius = (F − 32) × 5/9 Display Celsius Else:
Display "Invalid choice"
Step 5: End
Flowchart:
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.06
Code:
OUTPUT:
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.07
Program No.4
Aim:
To Check whether a number is even/odd, prime, or a palindrome.
Flowchart:
Algorithm:
Step 1: Start
Step 2: Input a number n
Step 3: Check Even/Odd:
• If n % 2 == 0 Even
• Else Odd
Step 4: Check Prime:
• If n <= 1 Not Prime
• Else check for factors from
2 to sqrt:
• If any number divides n Not
Prime
• Else Prime
Step 5: Check Palindrome:
• Reverse the number and
compare it to the original.
Step 6: Display results
Step 7: End.
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.08
CODE:
OUTPUT:
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.09
Program No.5
Aim:
Generate a star-pattern triangle using nested loop.
Algorithm:
Step 1: Start
Flowchart:
Step 2: Input the number of rows n.
Step 3: Set i= 1.
Step 4: Repeat steps 5–10 until i > n:
Step 5: Set j = 1.
Step 6: Repeat steps 7–8 until j > i:
Step 7: Print "*" (without moving to
a new line).
Step 8: Increment j by 1.
Step 9: Print a newline (move to the
next line).
Step 10: Increment i by 1.
Step 11: End
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.10
CODE:
OUTPUT:
NAME- SAHIL SHAKYA UID – 25LBME1004 Page No.11