1. Preprocessing Directive #include <stdio.h>     stdio.h preprocessing directives
               2- #include <  >                   include)- #include “  ”
2.    main( )                           main          “        ”                                     {        }          ...
3.            comment)    source code                  2•
Run >Run      < Ctrl + F9> )  LampangKanlayanee Schoolprintf( )String)                                           ;)       ...
                    : printf()                                     printf()    intprintf (<control>, <argument list>);
printf()(Statements) argument list                              1                            (,)control                   ...
%c%s%   d%   u%   f%   e   e%x%o
              1.1    printf()intmain( ){ intsum=3;printf(“ The sum is %d ”,sum);return 0;}The sum is 3
          1.2  printf()           %d     %uintmain( ){ intnum = -3, tot = 5;printf(“num = %d tot = %u ”,num,tot);return 0...
1.3               printf()        %f      %e              2intmain( ){ floatnum = 22.75;printf(“ %.2fn%.2e ”,num,num);retu...
         printf ( )                       printf( )    print format
    %d    %u    %f    %c       1    %s         1
    n    t   tab         8    a             Backslash
    printf( )
5 + 5 = 10             printf( )   string format
Hello word             3            2              data list
    printf( )                string format                   ““    data list                   ““    printf( )•          ...
      f)    printf( )                f
                     6               printf( )         n)printf( )                           printf( )         n)printf( )
               : scanf()intscanf (<control>, <argument list>);    intscanf (<control>,    <argument list>);        scanf(...
argument list      (,)                             &                  control                        “”         printf
            2.1             scanfintmain( ){ intnum;scanf( “ %d ”,&num);return 0;}         1                       num
2.2                scanfintmain( ){ intnum; charch;scanf( “ %c ”,&ch);scanf( “ %d ” ,&num);printf(“ %d %c ” ,num, ch);retu...
                  : expression    var = expression ;                 var = expression ;     var    Expression
                  : expression    var = expression ;                 var = expression ;     var    Expression
sum = a b ;              a    b        sum
                 –      putchar()                           putchar()    intputchar (<character>);            putchar()  ...
1.4   putchar()intmain( ){ inta=65;putchar(a);putchar(„a‟);return 0;}Aa
2   getchar ( )       getchar ( )                         1        enter               getchar ( );           getchar ( );
3   getch ( )     getch ( )                 1      enter           getch ( );
4   getche ( )     getche ( )                  1       enter           getche ( );
 3.                          –         3.1#include <stdio.h>intmain(){intx_value = 9;printf("x = %dn",x_value);return0;}
         3.2#include <stdio.h>intmain(){intx,y,sum;x = 7; y = 2;sum = x + y;printf("Total = %dn",sum);return0;}
         3.3#include <stdio.h>intmain(){int x, y;x = 7; y = 4;--x; ++y;printf("x = %2dn",x);printf("y = %6dn",y);return0;}
          3.4#include <stdio.h>intmain(){int profits, employees;profits = 9; employees = 2 ;printf("Each employee gets %....
          3.5include<stdio.h>intmain(){charany_char;printf("Please type a character: ");  scanf("c%",&any_char);printf("T...
          3.6#include <stdio.h>int main(){printf("n****Using .1f****n");printf("%.1f%.1f%.1fn", 4.0, 16.5, 589.3);printf(...
         3.7#include <stdio.h>int main(){printf("n");printf("xC9xCDxBBn");printf("xC8xCDxBCn");return 0;}
          3.8#include <stdio.h>#include <ctype.h>intmain(){charany_char;printf("Please type a lowercase letter:");scanf("...
            –                string          char [ n ]    put    puts string_argument ;       string_argument
-     wordChar word [15] = * Example *   ;-            putsputs word ;puts                      ;
           gets    enter               getsgets          ; ;                   string_var = get   ;string_var = get      ...
    -                           enter                gets word ;    - -printf   you name is %s n ,word ;

ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
ภาษาซี
Upcoming SlideShare
Loading in...5
×

ภาษาซี

398

Published on

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

  • Be the first to like this

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

No notes for slide

ภาษาซี

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

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×