Wednesday, October 7, 2009

temperatures

1.
#include<stdio.h>
int main()
{
int big;
float abc,g;
scanf("%d%f",&big,&abc);
g=big/2+big*4/big-big+abc/3;
printf("%f",g);
return 0;

}
Answer 3.833

2.
#include<stdio.h>
int main()
{
int on,ink=4,act=1;
float tig=3.2;
on=ink*act/2+3/2*act+2+tig;
printf("%d",on);
return 0;
}
Answer 8
3.
#include<stdio.h>
int main()
{
int qui=4,s,add=2,god;
s=qui*add/4-6/2+2/3*6/god;
printf("%d",s);
return 0;
}


Answer -1

4.
#include<stdio.h>
int main()
{
int a,b;
a=-3 - -3;
b=-3 - - (-3);
printf("a=%d b=%d",a,b);
return 0;
}
Answer a=0 b=-6





5.
#include<stdio.h>
int main()
{
float a=5,b=2;
int c;
c= a / b;
printf("%d",c);
return 0;
}
Answer 2

6. fahrengeit to celsius
#include <stdio.h>

/*
* print a table for Fahrenheit to Celsius
* from 0 F to 300 F
*/
void main(void)
{
int fahr; /* fahrenheit temperature */
int celsius; /* celsius temperature */
register int lower = 0; /* begin table here */
register int upper = 300; /* end table here */
register int step = 20; /* increment */

/*
* print out the lines for the table
*/
fahr = lower;
while(fahr <= upper){
/* get corresponding temp in degrees C */
celsius = 5 * (fahr - 32) / 9;
/* print it */
printf("%d\t%d\n", fahr, celsius);
fahr += step;
}

/*
* say goodbye
*/
exit(0);
}

No comments:

Post a Comment