C PROGRAM 1(C,D) PROGRAM (2)
C PROGRAM 1(C,D) PROGRAM (2)
AIM:
To write program to find area and circumference of a circle
ALGORITHM:
1. Start.
2. Initialize the variable radius with a given value.
3. Calculate the area of the circle using the formula: area = pi * radius * radius.
4. Calculate the circumference of the circle using the formula: circumference = 2
* pi * radius.
5. Print the area and circumference.
6. End
PROGRAM :
#include <stdio.h>
#define PI 3.14159
int main() {
float radius, area, circumference;
//Prompt user to enter the radius of circle
printf("Enter the radius of the circle: ");
scanf("%f", &radius);
// Calculate area and circumference of circle
area = PI * radius * radius;
circumference = 2 * PI * radius;
// Print are and circumference of circle
printf("Area of the circle: %.2f\n", area);
printf("Circumference of the circle: %.2f\n", circumference);
return 0;
}
Output:
Enter the radius of the circle: 2
Area of the circle: 12.57
Circumference of the circle: 12.57
AIM :
To write program to find simple interest and compound interest.
ALGORITHM :
Simple Intersest
1. Step 1:Start.
2. Step 2:Read Principal Amount, Rate and Time.
3. Step 3:Calculate Interest using formula SI= ((amount*rate*time)/100)
4. Step 4:Print Simple Interest. AND Compound intersest
5. Step 5:Stop
Compound Interset
1. Step 1: Start
2. Step 2: Read 3 number for p, n, r
3. Step 3: Calculate C.I = p × (1 + r/100)n – p
4. Step 4: Print “The compound Interest = C.l”
5. Step 5: stop
PROGRAM
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float p, t, r, si, ci;
clrscr();
printf("Enter principal amount (p): ");
scanf("%f", &p);
printf("Enter time in year (t): ");
scanf("%f", &t);
printf("Enter rate in percent (r): ");
scanf("%f", &r);
/* Calculating simple interest */
si = (p * t * r)/100.0;
/* Calculating compound interest */
ci = p * (pow(1+r/100, t) - 1);
printf("Simple Interest = %0.3f\n", si);
printf("Compound Interest = %0.3f", ci);
getch();
return(0);
}
Output:
Simple & Compound Interest
Enter principal amount (p): 5000 ↲
Enter time in year (t): 2 ↲
Enter rate in percent (r): 18 ↲
Simple Interest = 1800.000
Compound Interest = 1962.000