You are on page 1of 6

Assignment

to
.


Submitted To_____________________________________________
Submitted From___________________________________________
Roll No._________________________________________________
Submitted Date____________________________________________





1. Write a program that take tow values and print the sum, product, difference quotient
and remainder.
#include <stdio.h>
int main(){
int num1,num2;
int sum, sub, prod, quot, rem;
printf("Plz Enter 1st Number:");
scanf("%d", &num1);
printf("Plz Enter 2nd Number:");
scanf("%d", &num2);
sum = num1 + num2;
sub = num1 - num2;
prod = num1 * num2;
quot = num1 / num2;
rem = num1 % num2;
printf("Your Answer is=%d\n", sum);
printf("Your Answer is=%d\n", sub);
printf("Your Answer is=%d\n", prod);
printf("Your Answer is=%d\n", quot);
printf("Your Answer is=&d\n", rem);
return 0;
}
2. Write a program that covert temperature from Centigrade to Fahrenheit.
#include <stdio.h>
int main(){
float C,F;
printf("Enter Centigrate=");
scanf("%f",&C);
F=((C*9)/5)+32;
printf("Fahrenheit=%f",F);
return0;
}
3. Write a program that covert temperature from Fahrenheit to Centigrade .
#include <stdio.h>
int main(){
float C,F;
printf("Enter Fahrenheit=");
scanf("%f",&F);
C=(F-32)*5/9;
printf("Centigrate=%f",C);
return 0;
}
4. Write a program that allows the user to enter two fractional values and
printout their sum.
#include <stdio.h>
int main(){
float number1, number2, answer;
printf("Plz enter the first fraction number:");
scanf("%f", &number1);
printf("Plz enter the second fraction number:");
scanf("%f", &number2);
answer = number1 + number2;
printf("Your answer is= %f", answer);
return 0;
}
5. Solve the quadratic equation by taking three input values.
#include <stdio.h>
int main(){
float a,b,c,sum1,sum2,sum;
printf("Plz enter value of a :");
scanf("%f", &a);
printf("Plz enter value of b :");
scanf("%f", &b);
printf("Plz enter value of c :");
scanf("%f", &c);

sum1=(-b+sqrt(b*b-4*a*c))/(2*a);
sum2=(-b-sqrt(b*b-4*a*c))/(2*a);
sum=sum1+sum2;
pritnf("Answer=%f",sum);
return0;
}
6. input four integer from user and calculate the following 6 a * a 2 b * b + 5 1
b + 3 b c d
#include <stdio.h>
int main(){
int a, b, c, d, sum;
printf("Plz enter the first number:");
scanf("%d", &a);
printf("Plz enter the second number:");
scanf("%d", &b);
printf("Plz enter the third number:");
scanf("%d", &c);
printf("Plz enter the fourth number:");
scanf("%d", &d);
sum = 6 * a * a - 2 * b * b + 5 * a * b + 3 * b * c - d;
printf("Your answer is= %d", sum);
return 0;
}

8. Write a program that take five digit number as input and print sum &
product of its digits.
(Like 25364 yields 2+5+3+6+4 & 2*5*3*6*4
#include <stdio.h>
int main(){
int a, b, c, d, e;
int sum, prod;
printf("Plz enter the first number:");
scanf("%d", &a);
printf("Plz enter the second number:");
scanf("%d", &b);
printf("Plz enter the third number:");
scanf("%d", &c);
printf("Plz enter the fourth number:");
scanf("%d", &d);
printf("Plz enter the fifth number:");
scanf("%d", &e);
sum = a + b + c + d + e;
prod = a * b * c * d * e;
printf("Your answer for Sum =%d\n", sum);
printf("Your answer for Prod =%d\n", prod);
return 0;
}


9. Calculate Volume V of a cube by taking measures from user. (Volume= length *
width * height)
#include <stdio.h>
int main(){
int length, width, height, volume;
printf("Plz enter the legth of cube:");
scanf("%d", length);
printf("Plz enter the width of cube:");
scanf("%d", width);
printf("Plz enter the height of cube:");
scanf("%d", height);
volume = length * width * height;
printf("Your answer is= %d", volume);
return 0;
}
10. Calculate the Area of a circle with radius as input through key board
#include <stdio.h>
#define PI 3.1416
int main(){
float radius, areaofcircle;
printf("Plz enter radius of the circle:");
scanf("%f", &radius);
areaofcircle = PI * radius * radius;
printf("Area of the circle is= %f", areaofcircle)
return 0;
}
11. Determine the area of cylinder by taking height & diameter from user:
(2 * pi * radius * (height + radius))
#include<stdio.h>
# define PI 3.1416
int main(){
int height, diameter, radius, area;
printf("Plz enter the height:");
scanf("%d", &height);
printf("Plz enter the diameter:");
scanf("%d", &diameter);
radius = diameter / 2;
area = (2 * PI * radius * (height + radius));
printf("Area of the cylinder =%d", area);
return 0;
}
14. Write a program that calculates the arc length of a convex lens by taking
radius of arc and angle made by arc(length = radius * angle)
#include <stdio.h>
int main(){
int radius, angle, length;
printf("Plz enter the radius:");
scanf("%d", &radius);
printf("Plz enter the angle:");
scanf("%d", &angle);
length = radius + angle;
printf("Arc Length=%d", length);
return 0;
}

15. Write a program that calculates the final velocity of an object by taking following inputs
from the user.
#include <stdio.h>
int main(){
int vi, a, t, vf;
printf("Plz enter the initial velocit:");
scanf("%d", &vi);
printf("Plz enter the acceleration:");
scanf("%d", &a);
printf("Plz enter the time spended:");
scanf("%d", t);
vf = (vi + a * t);
printf("Your final velocity is= %d", vf);
return 0;
}
16. Write a program that accepts distance in Kms from user and converts it into
meter & centimeters.
#include <stdio.h>
Int main(){
int km, meter, cm;
printf("Plz enter the Kilometers:");
scanf("&d", km);
meter = km * 1000;
cm = km * 1000 * 100;
printf("Meters are= %d\n", meter);
printf("Centimeters are= %d\n", cm);
return 0;
}
18. Write a program that takes marks obtained by a student in five different
subjects find out the aggregate marks and percentage.
#include <stdio.h>
int main(){
int subject1, subject2, subject3, subject4, subject5, agregatemarks;
float percentage;
printf("Plz enter the number of 1st subject:");
scanf("%d", &subject1);
printf("Plz enter the number of 2nd subject:");
scanf("%d", &subject2);
printf("Plz enter the number of 3rd subject:");
scanf("%d", &subject3);
printf("Plz enter the number of 4th subject:");
scanf("%d", &subject4);
printf("Plz enter the number of 5th subject:");
scanf("%d", &subject5);
agregatemarks = (subject1 + subject2 + subject3 + subject4 + subject5) / 5;
percentage = ((subject1 + subject2 + subject3 + subject4 + subject5) * 100) /
500; printf("Your agregatemarks are=%d\n", agregatemarks);
printf("Your percentage is=%f\n", percentage);
return 0;

}

You might also like