{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lab2 - width#include<stdio.h> int main(viod int...

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

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 . . .

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

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

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

Lab2 - width#include<stdio.h> int main(viod int...

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

View Full Document
Ask a homework question - tutors are online