003 - 3 3.1 N S A 1 1 4 C i f s w i t c h c a s e f o r w h...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3 3.1 N - S A 1 1 . 4 C i f s w i t c h c a s e f o r w h i l e d o w h i l e b r e a k c o n t i n u e g o t o 3.2 C / O s c a n f ( ) p r i n t f ( ) g e t c h a r ( ) p u t c h a r ( ) 3.2.1 scanf s c a n f ( ) s c a n f ( " " s c a n f ( ) & 1. 3 2 C % [ < > ] < > 3 - 1 3-1 d o x f e c s s c a n f ( " % 3 d " & a ) a l h d o x l h s c a n f ( " % 1 0 l d % h d " , & x , & i ) x 1 0 i * * s c a n f ( " % 4 d % * d % 4 d " , & x , & y , & z ) ↵ x = 1 z = 3 y 2. (1) s c a n f ( " % d % c " , & a , & c h ) 3 2 q a = 3 2 c h = q c h s c a n f ( " % d % c " , & a , & c h ) % d q (2) \ n \ t s c a n f ( " % d % d " , & a , & b ) ; s c a n f ( " % d % d % d " , & x , & y , & z ) ; 1 2 3 ↵ 4 5 6 ↵ a = 1 b = 2 x = 3 y = 4 z = 5 s c a n f ( " % d % d \ n " , & a , & b ) ; s c a n f ( " % d % d % d " , & x , & y , & z ) ; a = 1 b = 2 x = 4 y = 5 z = 6 s c a n f \ n s c a n f (3) s c a n f ( " % d % d % c " & a & b & c h ) ; 1, 2, q ↵ a = 1 b = 2 c h = q 1 2 q ↵ a = 1 b c h s c a n f [ 3-1] A B S A B 2 m a i n ( ) { float a,b,h,s; printf("please input a,b,h:"); s c a n f ( " % f % f % f " , & a , & b , & h ) ; s = 0 . 5 * ( a + b ) * h ; printf("a=%5.2f b=%5.2f h=%5.2f",a,b,h); p r i n t f ( " s = % 7 . 4 f " , s ) ; } R U N ↵ please input a,b,h: 3.5 4.2 2.8 ↵ a=3.50 b=4.20 h=2.80 s = 1 0 . 7 8 0 3.2.2 printf( ) s c a n f ( ) p r i n t f ( ) p r i n t f 3 3 3 1. % [ < > ] < > 3 - 2 3-2 c o d x u s f g e f e (1) 3 - 3 3-3 M % m d m m 0 m % 0 m d m m m n %m .nf m i = 1 2 3 a = 1 2 . 3 4 5 6 7 p r i n t f ( " % 4 d + + + % 5 . 2 f " i a ) ; 1 2 3 + + + 1 2 . 3 5 p r i n t f ( " % 2 d + + + % 2 . 1 f " i a ) ; 1 2 3 + + + 1 2 . 3 1 2 . 3 4 5 6 7 %5.2f 1 2 . 3 5 1 2 . 3 4 5 6 7 %2.1f 1 2 . 3 " * " % i = 1 2 3 ; p r i n t f ( " % * d " , 5 , i ) ; 3 4 C 5 1 2 3 p r i n t f ( " % * d " , k , i ) ; k i (2) - i 1 2 3 a = 1 2 . 3 4 5 6 7 p r i n t f ( % 4 d % 1 0 . 4 f i a ) ; 1 2 3 1 2 . 3 4 5 7 p r i n t f ( % - 4 d % 1 0 . 4 f i a ) ; 1 2 3 1 2 . 3 4 5 7 p r i n t f ( % 4 d % - 1 0 . 4 f i a ) ; 1 2 3 1 2 . 3 4 5 7 (3) l h d f u l o n g s h o r t hd lf ld hu 2. i = 1 2 3 n = 4 5 6 a = 1 2 . 3 4 5 6 7 i n p r i n t f ( " % 4 d \ t % 7 . 4 f \ n \ t % l u \ n " , i , a , n ) ; 1 2 3 1 2 . 3 4 5 7 4 5 6 \ t \ t \ n \ n c [ 3-2] # include<stdio.h> m a i n ( ) { int a; 3 3 5 3 6 C long int b; short int c; unsigned int d; char e; float f; double g; a = 1 0 2 3 ; b = 2 2 2 2 ; c = 1 2 3 ; d = 1 2 3 4 ; e = ' x ' ; f = 3 . 1 4 1 5 9 2 6 5 3 5 8 9 8 g = 3 . 1 4 1 5 9 2 6 5 3 5 8 9 8 ; p r i n t f ( " a = % d \ n " , a ) ; p r i n t f ( " a = % 0 \ n " , a ) ; p r i n t f ( " a = % x \ n " , a ) ; p r i n t f ( " b = % l d \ n " , b ) ; p r i n t f ( " c = % d \ n " , c ) ; p r i n t f ( " d = % u \ n " , d ) ; p r i n t f ( " e = % c \ n " , e ) ; p r i n t f ( " f = % f \ n " , f ) ; p r i n t f ( " g = % f \ n " , g ) ; p r i n t f ( " \ n " ) ; } R U N ↵ a = 1 0 2 3 a = 1 7 7 7 a = 3 f f b = 2 2 2 2 c = 1 2 3 d = 1 2 3 4 e = x f = 3 . 1 4 1 5 9 3 g = 3...
View Full Document

This note was uploaded on 04/05/2010 for the course FINANCE AN FRE6851 taught by Professor Gallagher,evan during the Spring '09 term at NYU Poly.

Page1 / 26

003 - 3 3.1 N S A 1 1 4 C i f s w i t c h c a s e f o r w h...

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

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