Your SlideShare is downloading. ×
ภาษาซี
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

ภาษาซี

374
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
374
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 1. Preprocessing Directive #include <stdio.h> stdio.h preprocessing directives
  • 2.  2- #include < > include)- #include “ ”
  • 3. 2. main( ) main “ ” { } { } main( ) void main(void) main()
  • 4. 3. comment) source code 2•
  • 5. Run >Run < Ctrl + F9> ) LampangKanlayanee Schoolprintf( )String) ;) stdio ( standardinput output) #include directive) stdio.h header file)
  • 6.  : printf() printf() intprintf (<control>, <argument list>);
  • 7. printf()(Statements) argument list 1 (,)control “” 2
  • 8. %c%s% d% u% f% e e%x%o
  • 9.  1.1 printf()intmain( ){ intsum=3;printf(“ The sum is %d ”,sum);return 0;}The sum is 3
  • 10.  1.2 printf() %d %uintmain( ){ intnum = -3, tot = 5;printf(“num = %d tot = %u ”,num,tot);return 0;}num = -3 tot = 5
  • 11. 1.3 printf() %f %e 2intmain( ){ floatnum = 22.75;printf(“ %.2fn%.2e ”,num,num);return 0;}22.752.28e+01
  • 12.  printf ( ) printf( ) print format
  • 13.  %d %u %f %c 1 %s 1
  • 14.  n t tab 8 a Backslash
  • 15.  printf( )
  • 16. 5 + 5 = 10 printf( ) string format
  • 17. Hello word 3 2 data list
  • 18.  printf( ) string format ““ data list ““ printf( )• d 2• d a• s b
  • 19.  f) printf( ) f
  • 20.  6 printf( ) n)printf( ) printf( ) n)printf( )
  • 21.  : scanf()intscanf (<control>, <argument list>); intscanf (<control>, <argument list>); scanf() (key board)
  • 22. argument list (,) & control “” printf
  • 23.  2.1 scanfintmain( ){ intnum;scanf( “ %d ”,&num);return 0;} 1 num
  • 24. 2.2 scanfintmain( ){ intnum; charch;scanf( “ %c ”,&ch);scanf( “ %d ” ,&num);printf(“ %d %c ” ,num, ch);return 0;} 2 1 num 1
  • 25.  : expression var = expression ; var = expression ; var Expression
  • 26.  : expression var = expression ; var = expression ; var Expression
  • 27. sum = a b ; a b sum
  • 28.  – putchar() putchar() intputchar (<character>); putchar() (Statements)
  • 29. 1.4 putchar()intmain( ){ inta=65;putchar(a);putchar(„a‟);return 0;}Aa
  • 30. 2 getchar ( ) getchar ( ) 1 enter getchar ( ); getchar ( );
  • 31. 3 getch ( ) getch ( ) 1 enter getch ( );
  • 32. 4 getche ( ) getche ( ) 1 enter getche ( );
  • 33.  3. – 3.1#include <stdio.h>intmain(){intx_value = 9;printf("x = %dn",x_value);return0;}
  • 34.  3.2#include <stdio.h>intmain(){intx,y,sum;x = 7; y = 2;sum = x + y;printf("Total = %dn",sum);return0;}
  • 35.  3.3#include <stdio.h>intmain(){int x, y;x = 7; y = 4;--x; ++y;printf("x = %2dn",x);printf("y = %6dn",y);return0;}
  • 36.  3.4#include <stdio.h>intmain(){int profits, employees;profits = 9; employees = 2 ;printf("Each employee gets %.2f", (float) profits/employees);return0;}
  • 37.  3.5include<stdio.h>intmain(){charany_char;printf("Please type a character: "); scanf("c%",&any_char);printf("Thank you, your character are %c",any_char);return0;}
  • 38.  3.6#include <stdio.h>int main(){printf("n****Using .1f****n");printf("%.1f%.1f%.1fn", 4.0, 16.5, 589.3);printf("%.1f%.1f%.1f", 400.0, 1600.5, 58900.3);printf("nn****Using 8.1f****n");printf("%8.1f%8.1f%8.1fn", 4.0, 16.5, 589.3);printf("%8.1f%8.1f%8.1f", 400.0, 1600.5, 58900.3);printf("%-8.1f%-8.1f%-8.1fn", 4.0, 16.5, 589.3);printf("%-8.1f%-8.1f%-8.1f", 400.0, 1600.5, 58900.3);return 0;}
  • 39.  3.7#include <stdio.h>int main(){printf("n");printf("xC9xCDxBBn");printf("xC8xCDxBCn");return 0;}
  • 40.  3.8#include <stdio.h>#include <ctype.h>intmain(){charany_char;printf("Please type a lowercase letter:");scanf("%c", &any_char);if(any_char>= a)printf("In uppercase: %c n", toupper(any_char));return0;}
  • 41.  – string char [ n ] put puts string_argument ; string_argument
  • 42. - wordChar word [15] = * Example * ;- putsputs word ;puts ;
  • 43.  gets enter getsgets ; ; string_var = get ;string_var = get ;
  • 44.  - enter gets word ; - -printf you name is %s n ,word ;
  • 45.