Download C Operator Problem Solving

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Lateral computing wikipedia , lookup

Granular computing wikipedia , lookup

Simulated annealing wikipedia , lookup

Thermoregulation wikipedia , lookup

Transcript
Computing STPM
PROGRAMMING EXERCISES
C Operator Problem Solving
1.
Write a program that reads two integers from the keyboard, multiplies them, and then prints the two
numbers and their product.
Int a,b,total;
printf(“Please enter 2 number :”);
scanf(“%d, %d”, a,b);
total=a*b;
printf(“Product of %d multiply by %d is %d”,a,b,total);
2.
Write a program that calculates the area and perimeter of a rectangle from a user-supplied
(scanf) length and width.
int L,W,area,perim;
printf(“Enter length and width of a rectangle”);
scanf(“%d %d”,L,W);
area=L*W;
perim=L*2 + W*2;
printf(“Area = %d”,area);
printf(“Perimeter = %d”,perim);
3.
The formula for converting centigrade temperatures to Fahrenhit is as shown below. Write a
program that asks the user to enter a temperature reading in centigrade and then prints the
equivalent Fahrenhit value.
F = 32 +
C x 180.0
100.0
int F,C;
printf(“Please enter temperature in centrigrade :”);
scanf(“%d”,C);
F=32+(C*180/100);
printf(“The equivalent temperature in Fahrenhit is %d”,F);
4.
Write a C code for each of the following formulas. Assume that all variables are defined as float.
(a)
KinEn = mv2
2
(b)Res = b + c
2bc
KinEn=(m*v*v)/2
Res=(b+c)/(2*b*c)
It is never too late to learn, it is never too late to mend. It is not work that kills, but worry.
Sur Aziz @ SMKDPM 2009