{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lab1 - printf&amp;quot;Please enter the length and...

This preview shows pages 1–2. Sign up to view the full content.

Tao Lin Lab#1 Question #2 /*A program that convert temperature from Celcius to Fahrenheit*/ #include <stdio.h> int main(viod) { float celcius,fahren; printf( "Please enter a Celsius degree number: " ); scanf( "%f" ,&celcius); fahren=celcius*1.8+32.0; printf( "The temperature is %f Fahrenheit\n" ,fahren); return 0; } RESULT: Please enter a Celsius degree number: 26.2 The temperature is 79.160004 Fahrenheit Press any key to continue . . .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Tao Lin Lab#1 Question #3 /*A program that calculate area and perimeter base on the input length and width*/ #include <stdio.h> int main(viod) { int length,width,area,perimeter;
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf( &amp;quot;Please enter the length and width of a rectangule(use space between data): &amp;quot; ); /*scan both length and width at the same time*/ scanf( &amp;quot;%d%d&amp;quot; ,&amp;amp;length,&amp;amp;width); /*claculate are and perimeter*/ area=length*width; perimeter=2*(length+width); /*display both results at the same time*/ printf( &amp;quot;The area is %d and the perimeter is %d\n&amp;quot; ,area,perimeter); return 0; } RESULT: Please enter the length and width of a rectangule(use space between data): 3 5 The area is 15 and the perimeter is 16 Press any key to continue . . ....
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

Lab1 - printf&amp;quot;Please enter the length and...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online