0% found this document useful (0 votes)
2 views

piyush_FCS

The document contains a computer assignment by Piyush The OG, detailing various C programming tasks including temperature conversion, average calculation, gross salary computation, time conversion, length conversion, speed calculation, compound interest calculation, and digit operations. Each task includes the C code implementation and sample output. The assignment is structured with questions and answers, showcasing practical programming exercises for a B.Tech CSE course.

Uploaded by

kavyanshisemwal1
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)
2 views

piyush_FCS

The document contains a computer assignment by Piyush The OG, detailing various C programming tasks including temperature conversion, average calculation, gross salary computation, time conversion, length conversion, speed calculation, compound interest calculation, and digit operations. Each task includes the C code implementation and sample output. The assignment is structured with questions and answers, showcasing practical programming exercises for a B.Tech CSE course.

Uploaded by

kavyanshisemwal1
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/ 9

Computer

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);
}

Output:- Enter the temperature in Celsius degree= 5


Temperature in Fahrenheit= 41.000000
_______________________________________________________________
Name:- Piyush The OG
Section:- I1
Roll number:- 46
Course:- B.tech CSE
Q2. Write a C program to enter marks of a student in four subjects, Find the
average of total marks of a student (accurately up to 2 Decimal places).

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);
}

Output:- Enter the marks obtained in Subjects= 4 4 6 6


Average= 5.00
_______________________________________________________________

Name:- Piyush The OG


Section:- I1
Roll number:- 46
Course:- B.tech CSE
Q3.Write a C program to compute the gross salary of an employee by Reading
his basic pay from the keyboard. Gross=BP+DA+HRA+TA
HRA =10% of BP TA=5% of BP
DA=15% of BP

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);
}

Output:- Enter the BP= 100


Gross= 130.000000
_______________________________________________________________
Name:- Piyush The OG
Section:- I1
Roll number:- 46
Course:- B.tech CSE

Q4.Write a C program to convert a given number of seconds into Hours,


minutes and seconds. (HH : MM:SS).

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);
}

Output:- nter the number of seconds: 3712


Hours: 1 Minutes: 1 Seconds: 52
_______________________________________________________________

Name:- Piyush The OG


Section:- I1
Roll number:- 46
Course:- B.tech CSE
Q5.Write a C program to read length in centimeters and then convert it into
meters and kilometers. Display the converted length to the Screen.

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);
}

Output:- Enter the length in centimetres= 100000


Length in metres and kilometres= 1000.0 1.0
_______________________________________________________________
Name:- Piyush The OG
Section:- I1
Roll number:- 46
Course:- B.tech CSE

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);
}

Output:- Enter the distance and time in kilometres and hours= 72 2


Speed= 10.00
_______________________________________________________________

Name:- Piyush The OG


Section:- I1
Roll number:- 46
Course:- B.tech CSE
Q7.Write a C program to calculate the compound interest by reading the principal
‘p’, rate ‘r’ and time ‘n’ as input by the user. (HINT: p*(1+r/100) raised to power n -
p)

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
_______________________________________________________________

Name:- Piyush The OG


Section:- I1
Roll number:- 46
Course:- B.tech CSE
Q8.Write a C program to display the sum of individual digits of a given three- digit
number.

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
_______________________________________________________________

Name:- Piyush The OG


Section:- I1
Roll number:- 46
Course:- B.tech CSE
Q9.Write a C program to display the product of individual digits of a given three-
digit number.

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);
}

Output:- Enter the three-digit number= 120


Product= 0
______________________________________________ Name:- Piyush The OG
Section:- I1
Roll number:- 46
Course:- B.tech CSE
Q10.Write a C program to find x raised to the power y using pow () function.

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);
}

Output:- Enter the value of 'x'and 'y' = 2 3 Answer= 8


_______________________________xxx______________________________

You might also like