Lab2 - width*/ #include <stdio.h> int...

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

View Full Document Right Arrow Icon
Tao Lin Lab#2 Question #3 #include <stdio.h> int main( void ) { int a=5,b=3; //assign a with 5, and b with 3 a=b++; //assign a with b, and then increase b by 1 printf( "a=%d,b=%d\n" , a,b); b=++a*b; //increase a by 1, and then assign b with product of a and b printf( "a=%d,b=%d\n" , a,b); a=a--*3; //assign a with a times 3, and then decrease a by 1 printf( "a=%d,b=%d\n" , a,b); a=--a*b++; //decrease a by 1, and then assign a with product of a and b, and then increase b by 1 printf( "a=%d,b=%d\n" , a,b); return 0; } RESULT: a=3,b=4 a=4,b=16 a=11,b=16 a=160,b=17 Press any key to continue . . .
Background image of page 1

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

View Full DocumentRight Arrow Icon
Tao Lin Lab#2 Question #4 /*A program that calculate area and perimeter base on the input length and
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: width*/ #include &lt;stdio.h&gt; int main(viod) { int length,width,area,perimeter; printf( &quot;Please enter the length and width of a rectangule(use space between data): &quot; ); /*scan both length and width at the same time*/ scanf( &quot;%d%d&quot; ,&amp;length,&amp;width); /*claculate are and perimeter*/ area=length*width; perimeter=2*(length+width); /*display both results at the same time*/ printf( &quot;The area is %d and the perimeter is %d\n&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

This note was uploaded on 09/04/2011 for the course EE 140 taught by Professor Lanxiang during the Spring '11 term at Montgomery College.

Page1 / 2

Lab2 - width*/ #include &amp;amp;lt;stdio.h&amp;amp;gt; int...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online