algorithm, flowchart explanation, and C program — to find the area and perimeter
(circumference) of a circle.
Algorithm
Step 1: Start
Step 2: Declare variables radius, area, perimeter
Step 3: Read the value of radius from the user
Step 4: Calculate the area using the formula
area = 3.14 × radius × radius
Step 5: Calculate the perimeter using the formula
perimeter = 2 × 3.14 × radius
Step 6: Display the values of area and perimeter
Step 7: Stop
🔄 Flowchart (Description)
C Program
#include <stdio.h>
int main() {
float radius, area, perimeter;
const float PI = 3.14;
// Step 1: Input radius
printf("Enter the radius of the circle: ");
scanf("%f", &radius);
// Step 2: Calculate area and perimeter
area = PI * radius * radius;
perimeter = 2 * PI * radius;
// Step 3: Display results
printf("Area of the circle = %.2f\n", area);
printf("Perimeter (Circumference) of the circle = %.2f\n", perimeter);
return 0;
}
Enter the radius of the circle: 5
Area of the circle = 78.50
Perimeter (Circumference) of the circle = 31.40
Draw a flowchart and C program which takes as input p,t,r. Compute the simple
interest and display the result.
C program to calculate Simple Interest (SI) using the formula:
SI=P×T×R100\text{SI} = \frac{P \times T \times R}{100}SI=100P×T×R
where:
P = Principal amount
T = Time (in years)
R = Rate of interest (per annum)
Algorithm
Step 1: Start
Step 2: Declare variables P, T, R, SI
Step 3: Read values of P, T, and R from the user
Step 4: Compute simple interest using the formula:
SI = (P * T * R) / 100
Step 5: Display the value of SI
Step 6: Stop
Flowchart (Text Description)
💻 C Program
#include <stdio.h>
int main() {
float P, T, R, SI;
// Step 1: Input
printf("Enter the Principal amount (P): ");
scanf("%f", &P);
printf("Enter the Time (in years) (T): ");
scanf("%f", &T);
printf("Enter the Rate of Interest (R): ");
scanf("%f", &R);
// Step 2: Compute Simple Interest
SI = (P * T * R) / 100;
// Step 3: Display result
printf("Simple Interest = %.2f\n", SI);
return 0;
}
Enter the Principal amount (P): 5000
Enter the Time (in years) (T): 2
Enter the Rate of Interest (R): 5
Simple Interest = 500.00
Write an algorithm, flow chart and C program to convert the temperature from Celsius
to Fahrenheit and Fahrenheit to Celsius
Algorithm
Step 1: Start
Step 2: Declare variables: celsius, fahrenheit, and a choice variable ch
Step 3: Display menu:
1 → Convert Celsius to Fahrenheit
2 → Convert Fahrenheit to Celsius
Step 4: Read the user’s choice ch
Step 5:
If ch = 1:
Read celsius
fahrenheit = (celsius * 9 / 5) + 32
Display fahrenheit
Else if ch = 2:
Read fahrenheit
celsius = (fahrenheit - 32) * 5 / 9
Display celsius
Else:
Display “Invalid Choice”
Step 6: Stop
C Program
#include <stdio.h>
int main() {
float celsius, fahrenheit;
int choice;
printf("Temperature Conversion Program\n");
printf("1. Convert Celsius to Fahrenheit\n");
printf("2. Convert Fahrenheit to Celsius\n");
printf("Enter your choice (1 or 2): ");
scanf("%d", &choice);
if (choice == 1) {
// Celsius to Fahrenheit
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
fahrenheit = (celsius * 9 / 5) + 32;
printf("Temperature in Fahrenheit = %.2f\n", fahrenheit);
}
else if (choice == 2) {
// Fahrenheit to Celsius
printf("Enter temperature in Fahrenheit: ");
scanf("%f", &fahrenheit);
celsius = (fahrenheit - 32) * 5 / 9;
printf("Temperature in Celsius = %.2f\n", celsius);
}
else {
printf("Invalid choice! Please enter 1 or 2.\n");
}
return 0;
}
Sample Output 1:
Temperature Conversion Program
1. Convert Celsius to Fahrenheit
2. Convert Fahrenheit to Celsius
Enter your choice (1 or 2): 1
Enter temperature in Celsius: 25
Temperature in Fahrenheit = 77.00
Temperature Conversion Program
1. Convert Celsius to Fahrenheit
2. Convert Fahrenheit to Celsius
Enter your choice (1 or 2): 2
Enter temperature in Fahrenheit: 98.6
Temperature in Celsius = 37.00
Write an algorithm, flow chart and C program to Swap Two Numbers with temporary
variable
Algorithm
Step 1: Start
Step 2: Declare three variables — a, b, temp
Step 3: Read two numbers a and b
Step 4: Assign temp = a
Step 5: Assign a = b
Step 6: Assign b = temp
Step 7: Display the swapped values of a and b
Step 8: Stop
C Program
#include <stdio.h>
int main() {
int a, b, temp;
// Step 1: Input two numbers
printf("Enter the first number (a): ");
scanf("%d", &a);
printf("Enter the second number (b): ");
scanf("%d", &b);
// Step 2: Display values before swapping
printf("\nBefore swapping: a = %d, b = %d\n", a, b);
// Step 3: Swap using temporary variable
temp = a;
a = b;
b = temp;
// Step 4: Display values after swapping
printf("After swapping: a = %d, b = %d\n", a, b);
return 0;
}
Enter the first number (a): 5
Enter the second number (b): 10
Before swapping: a = 5, b = 10
After swapping: a = 10, b = 5
Flowchart
Write an algorithm, flow chart and C program to find ASCII value of a character
Algorithm: Find ASCII Value of a Character
Step 1: Start
Step 2: Declare a character variable ch
Step 3: Read the character input from the user
Step 4: Convert the character to its ASCII value using type casting or by assigning it to an
integer variable
Step 5: Display the ASCII value
Step 6: Stop
🧩 Flowchart:
💻 C Program: Find ASCII Value of a Character
#include <stdio.h>
int main() {
char ch;
int asciiValue;
// Step 1: Read a character from user
printf("Enter a character: ");
scanf("%c", &ch);
// Step 2: Find ASCII value
asciiValue = (int)ch;
// Step 3: Display ASCII value
printf("The ASCII value of '%c' is %d\n", ch, asciiValue);
return 0;
}
🧾 Example Output:
Enter a character: A
The ASCII value of 'A' is 65