0% found this document useful (0 votes)
10 views2 pages

PSP Lab Cycle 1

Problem Solving and Programming - All Programs for understanding

Uploaded by

leninantony2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

PSP Lab Cycle 1

Problem Solving and Programming - All Programs for understanding

Uploaded by

leninantony2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CYCLE – 1

1. C program to find the area and perimeter of a rectangle


#include <stdio.h>
int main()
{
float length, width, perimeter, area;
printf("Enter the length and width : ");
scanf("%f%f", &length, &width);
perimeter = 2 * (length + width);
area = length * width;
printf("Perimeter = %f ", perimeter);
printf("Area = %f", area);
return 0;
}

2. C program to calculate the diameter, circumference and area of a circle.


#include <stdio.h>
int main()
{
float radius, diameter, circumference, area;
printf("Enter the radius : ");
scanf("%f",&radius);
diameter = 2 * radius;
circumference = 2 * 3.14 * radius;
area = 3.14 * radius * radius;
printf(" Diameter = %.2f \n Circumference = %.2f \n Area = %.2f", diameter, circumference,
area);
return 0;
}

3. C program to convert temperature from degree Celsius to Fahrenheit.


#include <stdio.h>
int main()
{
float celsius, fahrenheit;
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
fahrenheit = (celsius * 9 / 5) + 32;
printf("%.2f Celsius = %.2f Fahrenheit ", celsius, fahrenheit);
return 0;
}
4. C program to convert days into years, months and days.
#include <stdio.h>
int main()
{
int total_days, years, months, days;
printf("Enter number of days: ");
scanf("%d", &total_days);
years = total_days / 365;
total_days = total_days % 365;
months = total_days / 30;
days = total_days % 30;
printf("%d years, %d months, and %d days\n", years, months, days);
return 0;
}

5. C program to calculate total, average and percentage of 5 subjects.


#include <stdio.h>
int main()
{
float sub1, sub2, sub3, sub4, sub5;
float total, average, percentage;
printf("Enter marks of five subjects: ");
scanf("%f %f %f %f %f", &sub1, &sub2, &sub3, &sub4, &sub5);
total = sub1 + sub2 + sub3 + sub4 + sub5;
average = total / 5;
percentage = (total / 500) * 100;
printf("Total: %.2f\n", total);
printf("Average: %.2f\n", average);
printf("Percentage: %.2f%%\n", percentage);
return 0;
}

You might also like