piyush_FCS
piyush_FCS
Assignment
Name:- Piyush The OG 🗿🗿
Section:- I1
Roll number:- 46
Course:- B.tech CSE
🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣Haan bacho teepne aaye ho 🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣
🤣🤣🤣
Q1. Write a C program to convert temperature from degree Celsius to Degree
Fahrenheit.
Ans1.
#include<stdio.h>
void main()
{
float temp, temp_f;
printf("Enter the temperature in Celsius degree= "); scanf("%f", &temp);
temp_f= (temp*(9/5.0))+32;
printf("Temperature in Fahrenheit= %f", temp_f);
}
Ans2.
#include<stdio.h>
void main()
{
float s1, s2, s3, s4, avg;
printf("Enter the marks obtained in Subjects= "); scanf("%f %f %f %f", &s1, &s2,
&s3, &s4);
avg= (s1+s2+s3+s4)/4.0;
printf("Average= %.2f", avg);
}
Ans3.
#include<stdio.h>
void main(){
float hra, ta, da, bp, gross;
printf("Enter the BP= "); scanf("%f", &bp);
hra= (10/100.0)*bp;
ta= (5/100.0)*bp;
da= (15/100.0)*bp;
gross= bp+da+hra+ta ;
printf("Gross= %f", gross);
}
Ans4.
#include <stdio.h>
void main(){
int totalSeconds, hours, minutes, seconds;
printf("Enter the number of seconds: ");
scanf("%d", &totalSeconds);
hours = totalSeconds / 3600;
totalSeconds = totalSeconds % 3600;
minutes = totalSeconds / 60;
seconds = totalSeconds % 60;
printf("Hours: %d\n", hours);
printf("Minutes: %d\n", minutes);
printf("Seconds: %d\n", seconds);
}
Ans5.
#include<stdio.h>
void main()
{
float cm, m, km;
printf("Enter the length in centimetres= "); scanf("%f", &cm);
m= cm/100.0;
km= m/1000.0;
printf("Length in metres and kilometres= %.1f %.1f", m, km);
}
Q6.Write a C program to calculate the speed of a bike in m/sec when the bike
travels ‘d’ km of distance in ‘h’ hours.
Ans6.
#include<stdio.h>
void main()
{
float d, t, sp, sp1;
printf("Enter the distance and time in kilometres and hours= ");
scanf("%f %f", &d, &t);
sp= (d/t);
sp1= sp*(5/18.0);
printf("Speed= %.2f", sp1);
}
Ans7.
#include<stdio.h>
#include<math.h>
void main()
{
float p, r n, ci;
printf("Enter the principal, rate, and time= ");
scanf("%f %f %f", &p, &r, &n);
ci= pow(p*((1+r)/(100.0)), (n-p));
printf("Compound Interest= %f", ci);
}
Output:- Enter the principal, rate, and time= 4.0 99.0 6.0 Compound
Interest= 16.000000
_______________________________________________________________
Ans8.
#include<stdio.h>
void main()
{
int num, f, m l, sum;
printf("Enter the three-digit number= ");
scanf("%d", &num);
f= num/100;
r= num%100;
m= r/10;
l= r%10;
sum= f+m+l;
printf("Sum= %d", sum);
}
Output:- Enter the three-digit number= 120
Sum= 3
_______________________________________________________________
Ans9.
#include<stdio.h>
void main()
{
int num, f, m l, product;
printf("Enter the three-digit number= ");
scanf("%d", &num);
f= num/100;
r= num%100;
m= r/10;
l= r%10;
product= f*m*l;
printf("Product= %d", product);
}
Ans10.
#include<stdio.h>
#include<math.h>
void main()
{
int x, y, p;
printf("Enter the value of 'x' and 'y' = ");
scanf("%d %d", &x, &y);
p= pow(x,y);
printf("Answer= %d", p);
}