You are on page 1of 4

1) program for finding the max and min from the three numbers

Code:
#include <stdio.h

int main() {

int num1, num2, num3;

printf("Enter three numbers: ");

scanf("%d %d %d", &num1, &num2, &num3);

int max = num1;

if (num2 > max) {

max = num2;

if (num3 > max) {

max = num3;

int min = num1;

if (num2 < min) {

min = num2;

if (num3 < min) {

min = num3;

printf("Maximum: %d\n", max);

printf("Minimum: %d\n", min);

return 0;

Output:
2) Write a program for simple, compound interest.

Code:

#include <stdio.h>

#include <math.h>

int main() {

float principal, rate, simpleInterest, compoundInterest;

int time;

printf("Enter principal amount: ");

scanf("%f", &principal);

printf("Enter rate of interest: ");

scanf("%f", &rate);

printf("Enter time (in years): ");

scanf("%d", &time);

simpleInterest = (principal * rate * time) / 100;

compoundInterest = principal * (pow((1 + rate / 100), time)) - principal;

printf("Simple Interest: %.2f\n", simpleInterest);

printf("Compound Interest: %.2f\n", compoundInterest);

return 0;

Output:
3) . WAP that declares <40% = FAIL, 40 to 60% = SECOND, 60 to 100% = DISTINCTION ,Read
percentage from standard input.

Code:

#include <stdio.h>

int main() {

float percentage;

printf("Enter the percentage: ");

scanf("%f", &percentage);

if (percentage < 40.0) {

printf("Result: FAIL\n");

} else if (percentage >= 40.0 && percentage <= 60.0) {

printf("Result: SECOND\n");

} else if (percentage > 60.0 && percentage <= 100.0) {

printf("Result: DISTINCTION\n");

} else {

printf("Invalid percentage entered. Please enter a percentage between 0 and 100.\n");

return 0;

Output:
4

You might also like