• Dev-C++:

•
•
•
•
•

             2
Dev-C++
•
    File > New > Source File


•


•                         .c
        first.c
                                 3
Dev-C++
•
    

       F9
•                  :
        getch()




                                 4
main
                                                         stdio.h
                  #include <stdio.h>

            int   int main()
                  {
                    int a, b, sum;
printf()            printf("Enter A: ");          int
                    scanf("%d", &a);           a, b       sum
                    printf("Enter B: ");
                    scanf("%d", &b);           scanf()
                    sum = a+b;
                    printf("Sum = %dn", sum);
                    getch();
                    return 0;
                  }
                                  0
                                                           ;

                                                                   5
(Comment)
•


•   /*   …
             (        )… */
    //   …
                 (    )…
         /* arithmetic
                 expression */
         // create                 6
a
(Beep)
  n                 (newline)
         backslash


  ’
                                 7
(address) (data)
   0000     32     1   =1   8
   0001     67
   0002    255
   0003      0
   0004    121
     :       :



                            8
(       )
char         1                 -128              +127

short        2             -32,768            +32,767

int
         2            -32,768    -        +32,767
             4       2,147,483,648     +2,147,483,647

long         4       -2,147,483,648    +2,147,483,647

float        4           3.4 * 10-38        3.4 * 1038

double       8          1.7 * 10-308       1.7 * 10-308
                                                          9
(Variable)
•

                                         (               )
                                    :          :
            short a, b, sum;       1000       10
                                               2    a
            a = 10;                1001       30
                                               0
            b = 5;                 1002       211
                                               5    b
            sum = a+b;             1003       0
                                              5
                                   1004       15
                                               8    sum
                                   1005       23
                                               0
                                    :          :
        b         5            )
        &b         1002
                                                              10
(Variable)

               underscore ( _ )

               underscore ( _ )
            1-32
                                 $
   Case sensitive

    Reserve words                     11
C
auto      double        int      struct
break     else          long     switch
case      enum          register typedef
char      extern        return   union
const     float         short    unsigned
continue for            signed   void
default   goto sizeof   while    do
                                            12
type variable-list   [=value] ;

• variable-list




               (,)
     type
     value                                     13
int a=1;
int lower;
float      man,ratio;
double point;
char       ch,c=„5‟,name;


                            14
#include <stdio.h>
#define PI 3.414     const.c
int main()
{
                     3.414
  printf("%.3f",PI);
  getch();
  return 0;
}
                               15
•

•
    short arr[3];        :      :
    arr[0] = 50;        0020   50
                                2    arr
    arr[2] = 89;        0021   30
                                0
                        0022   211
    arr      20         0023   5
    arr[0]        50    0024   89
                               8
    arr[1]        211   0025   23
                                0
    arr[2]        89    0026   33
                        0027   12
                         :      :
                                           16
• “       ”
  (array of char)
      char s[5] = "Hello";
       printf("%c %c %cn", s[0], s[1], s[2]);


                   0 1 2 3 4
          S        H e l l o
               :
       H e l


                                                 17
/
•                             (           /
                      )
                 “stdio.h”
•
       scanf                         (
        %format)
•                                 (Output
    Function)
       printf                            (
        %format)                              18
•

•                                         printf
int c = 65;                                :
                                           2
printf("c (as a number) = %dn", c);
                                           30
printf("c (as a character) = %cn", c);
                                           65   c
                                           5
     :                                     8
c (as a number) = 65                       23
c (as a character) = A                     :


                                                    19
%format    scanf
       printf
                             %for
                             mat
        int                   %d
        long                 %ld
        long long            %lld
        unsigned int          %u
        unsigned long        %lu
        unsigned long long   %llu
        float                 %f
        double               %lf
        char                  %c
        char array[]          %s

                                    20
scanf
char name[20];
int age;

printf("Enter your name and age: ");
scanf("%s %d", name, &age);

printf("Hello %s.   You are %d years old.n",
   name, age);



     :
Enter your name and age: Tony 38
Hello Tony. You are 38 years old.



                                                21
•
                 START


                Statement1


                Statement2
     START

                Statement3
    Statement


      END       Statementn


                  END




                             22
Relational Operators
•
             (Operand)
Operator
     <
    <=
     >
    >=
    ==
    !=

                            23
Expression
•
  (Operand)
  (Operator)
A = 10; B = 3; C = 20;
Expressio
    n
A+B           13
(A + B) – C   -7
(C*B)+(A*B)   90
A%B           1
C%B           2
                             24
Relational Operators
•                               Relational
    Operators
i = 1; j = 2; k = 3;
    Expression
            i<j          true            1
       (i + j) >= k      true            1
    (j + k) > (i + 5)   false            0
          k != 3        false            0
          j == 2         true            1



                                             25
Logical (Bitwise) Operators
•
    (Operand)
      Operator Operator)
           (Logical
        &&                 AND

         ||                OR




                                 26
AND Operators
•


    A     B     A && B
True    True    T && T   True    1
True    False   T && F   False   0
False   True    F && T   False   0
False   False   F && F   False   0


                                     27
AND Operators
•                                        AND Operators
i = 8; j = 4.5; k = „z‟; // ascii    z        122
         Expression
(i >= 6) && (k == „z‟)              T && T == T          1
(i >= 6) && (k == 122)              T && T == T          1
(j >= 0) && (j != 4.5)              T && F == F          0
(k > 0) && (j != 5)                 T && T == T          1
(i < 0) && (j > 0) && (k > 0)       F && T && T ==       0
                                    F

                                                             28
OR Operators
•


    A     B     A || B
True    True    T || T   True    1
True    False   T || F   True    1
False   True    F || T   True    1
False   False   F || F   False   0


                                     29
OR Operators
•                                           OR Operators
i = 8; j = 4.5; k = „z‟; // ascii       z         122
       Expression
(i >= 6) || (k == „z‟)              T || T == T            1
(i >= 6) || (k != 122)              T || F == T            1
(j < 0) || (j != 4.5)               F || F == F            0
(k > 0) || (j != 5)                 T || T == T            1



                                                               30
•
i = 7; f = 4.5;
       Expression
f>5                 False   0
!(f > 5)            True    1
i <= 3              False   0
!(i <=3)            True    1
i > (f + 1)         True    1
!(i > (f + 1))      False   0


                                31
(Precedence)

•

                           Operators
unary operators        - , ++ , -- , ! , sizeof()   R->L
multiply, divide and           *,/,%                L->R
remainder
add and subtract                +,-                 L->R
relational                 < , <= , > , >=          L->R
equality                       == , !=              L->R
                                                           32
(Precedence)

•


                           Operators

and                             &&             L->R
or                               ||            L->R
assignment operators   =, +=, -=, *=, /=, %=   R->L
                                                      33
i = 8; j = 4.5; k = „z‟; // ascii     z         122
         Expression

i + j <= 10                    False                    0
i >= 8 && k == „z‟             True && True == True     1
k != „a‟ || i + j <= 10        True || False == True    1
k != „a‟ || i < j && k < i     True || False && False   0
                               == True && False
                               == False
k != „a‟ || i < j && k < i     True || False && False   1
                               == True || False
                               == True                      34
•
       if
       if…else
       if
       switch-case
•
       while loop
       do…while loop
       for loop
•                       35
if
          C Syntax                  Flowchart
     if (condition)           START
     {
       statement1;
           :                            true
                            condition
       statementN;
     }                      false        Statement


•               condition                Statement


    int
•                    {}        END

    condition


•                                                    36
if
#include <stdio.h>      if1.c
int main()
{                       I>J
  int i=101,j=100;
  if(i>j)
    printf("I > J");
  getch();
  return 0;
}                               37
if…else
          Flowchart                       C Syntax

              START                   if (condition)
                                      {
   true                 false           statementt1;
          condition
                                        statementt2;
Statementt1           Statementf1
                                      }
                                      else
Statementt2           Statementf2     {
                                        statementf1;
                                        statementf2;
               END                    }



                                                       38
if…else
#include <stdio.h>        ifelse1.c
int main()
{                          I <= J
  int i=101,j=102;
  if(i>j)
    printf("I > J");
  else
    printf("I <= J");
 getch();
 return 0;
}
                                      39
if
                                    if (x==1)
             true                     Action1;
      x==1          Action1;
   false
                                    else if (x==2)
      x==2
             true
                    Action2;          Action2;
   false                            else if (x==3)
             true
      x==3          Action3;          Action3;
   false
             true
                                    else if (x==4)
      x==4          Action4;
   false
                                      Action4;
Default_Action;                     else
                                      Default_Action;




                                                        40
if
#include <stdio.h>             ifelse2.c
int main()
{                                 >6
  int i=7;
  if(i>7) printf("> 7");
  else if(i>6) printf("> 6");
       else if(i>5) printf("i> 5");
          else printf("1 , 2 , 3");
 getch();
 return 0;
}
                                           41
switch-case
                                switch (x)
      x==1
             true
                    Action1;
                                {
                                 case 1: Action1;
   false
             true                        break;
      x==2          Action2;
                                 case 2: Action2;
   false
             true
                                         break;
      x==3          Action3;
                                 case 3: Action3;
   false
             true
                                         break;
      x==4          Action4;     case 4: Action4;
   false                                 break;
Default_Action;
                                 default: Default_Action;
                                           break;
                                }




                                                            42
switch-case
#include <stdio.h>
int main()                          switch1.c
{
  int i=2;
  switch(i)
  {
                                        2
    case 2 : printf("2");
         break;
    case 1 : printf("1");
         break;
    default : printf("NO MATCH");
           break;
  }
 getch();
 return 0;
}                                               43
i++    =    i
= i--1 =
  i+       i = i-
1
  i+=5 =   i=
i+i-=5 =
  5        i = i-
5                   44
while
     while (condition)            START
     {
        stmt1;
        stmt2;
        :                                    false
                                 condition
        stmtN;
     }                           true
                                 Statement
•                 stmt1
    stmtN                        Statement
                 condition

                                     END


                                                     45
Counting
              Loop)
•


•
    int i, sum = 0;
    i = 1;
    while (i <= 10)
    {
      sum = sum + i;
      i = i + 1;
    }
    printf("Sum = %dn", sum);


                                 46
while
#include <stdio.h>
int main()
                            while1.c
{                           Hello 1
                            Hello 2
  int i=1;                  Hello 3
  while(i<=10)              Hello 4
  {                         Hello 5
                            Hello 6
    printf("Hello %dn",i); Hello 7
    i++;                    Hello 8
 }                          Hello 9
                            Hello 10
 getch();
 return 0;
}                                      47
while
      (INFINITY LOOP)
#include <stdio.h>
int main()                    while2.c
{                             Hello 1
  int i=1;                    Hello 2
  while(1)                    Hello 3
  {                           Hello 4
    printf("Hello %dn",i);   Hello 5
    if(i==10)                 Hello 6
                              Hello 7
      break;                  Hello 8
  i++;                        Hello 9
 }                            Hello 10
 getch();
 return 0;
}                                        48
do…while
    do                                  START
    {
       stmt1;
       stmt2;
       :                               Statement1
       stmtN;
    } while (condition);
                                       StatementN

•             stmt1...stmtN
                                true
                                       condition

           condition                        false



•
                                          END
           stmt1...stmtN

                                                    49
do…while
#include <stdio.h>
                              dowhile1.c
int main()
{                              Hello 1
  int i=1;                     Hello 2
  do                           Hello 3
                               Hello 4
  {                            Hello 5
    printf("Hello %dn",i);    Hello 6
    i++;                       Hello 7
  }                            Hello 8
  while(i<=10);                Hello 9
 getch();                      Hello 10
 return 0;
}
                                           50
for
•
         for (init_stmt; condition; update_stmt)
         {
            statement1;
            statement2;
            :
            statementN;
         }



•
    1.             init_stmt

    2.      condition
     statement1...statementN
                                                   51
for
                                            START


                                           init_stmt

for (init_stmt; condition; update_stmt)
{
   statement1;
                                                        false
   statement2;                             condition
   :
   statementN;
}
                                           true
                                          Statement1


                                          StatementN


                                          update_stmt



                                             END
                                                                52
for
#include <stdio.h>
int main()                    for1.c
{                           Hello 1
                            Hello 2
  int i;                    Hello 3
  for(i=1;i<=10;i++)        Hello 4
  {                         Hello 5
                            Hello 6
    printf("Hello %d",i);   Hello 7
    printf("n");           Hello 8
  }                         Hello 9
                            Hello 10
 getch();
 return 0;
}                                      53
(Subroutine)
•                (Function)
•


•

    

    

    



                             54
•                      (Standard
    Functions)
    



        printf(), scanf(), ...
•                           (User Defined
    Functions)
    

                main()
                                            55
scanf, printf,
stdio.h
           gets, puts
math.h     sin, cos, exp, pow
           isalpha, isdigit,
ctype.h
           islower, isupper

string.h   strlen, strcpy,
           strcmp
stdlib.h   rand, atoi, atof



                                56
•                         void say_hi(char *name)
                          {
                           printf("Hi, %sn", name);
        void              }

    
        return
                          int max(int a, int b)
                          {
•                           if (a > b)
                              return a;
                            else
                             return b;
                          }

                return
                                                        57
#include <stdio.h>
int incr(int i)
{
  int j;
                           function1.c
  j = i + 1;
  return j;
}

int main()
{
  int k, m = 4;
  k = incr(m);
  printf ("k = %d, m = %dn", k, m);
  getch();
  return 0;
}

                                         58
(Function)

  #include <stdio.h>
  void print1()
  {
    printf(“Hello”);
                       function2.c
    printf(“n”);
  }

  int main()
  {
    print1();
    print1();
    getch();
    return 0;
  }

                                     59
(Function)
#include <stdio.h>
float cal_tax(float i)
{
                         function3.c
  float ctax;
  ctax = i*0.07;
  return ctax;
}

int main()
{
  float money=7290,ff;
  ff = cal_tax(money);
  printf(“%f”,ff);
  getch();
  return 0;
}
                                       60
•

•




    61
•
    Enter N: 3   Enter N: 5
    *            *
    **           **
    ***          ***
                 ****
                 *****




                              62
#include <stdio.h>

int main ()
{                      i     scanf
  int i;

    scanf("%d", i);
    if (i = 0)
      puts("false");   (=)
    else
      puts("true");
                                (==)

    return 0;
}




                                       63

โปรแกรมภาษาซีเบื้องต้น

  • 2.
  • 3.
    Dev-C++ • File > New > Source File • • .c  first.c 3
  • 4.
    Dev-C++ •   F9 • :  getch() 4
  • 5.
    main stdio.h #include <stdio.h> int int main() { int a, b, sum; printf() printf("Enter A: "); int scanf("%d", &a); a, b sum printf("Enter B: "); scanf("%d", &b); scanf() sum = a+b; printf("Sum = %dn", sum); getch(); return 0; } 0 ; 5
  • 6.
    (Comment) • • /* … ( )… */ // … ( )… /* arithmetic expression */ // create 6
  • 7.
    a (Beep) n (newline) backslash ’ 7
  • 8.
    (address) (data) 0000 32 1 =1 8 0001 67 0002 255 0003 0 0004 121 : : 8
  • 9.
    ( ) char 1 -128 +127 short 2 -32,768 +32,767 int 2 -32,768 - +32,767 4 2,147,483,648 +2,147,483,647 long 4 -2,147,483,648 +2,147,483,647 float 4 3.4 * 10-38 3.4 * 1038 double 8 1.7 * 10-308 1.7 * 10-308 9
  • 10.
    (Variable) •  ( ) : : short a, b, sum; 1000 10 2 a a = 10; 1001 30 0 b = 5; 1002 211 5 b sum = a+b; 1003 0 5 1004 15 8 sum 1005 23 0 : : b 5 ) &b 1002 10
  • 11.
    (Variable)  underscore ( _ )  underscore ( _ )  1-32  $  Case sensitive  Reserve words 11
  • 12.
    C auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof while do 12
  • 13.
    type variable-list [=value] ; • variable-list (,)  type  value 13
  • 14.
    int a=1; int lower; float man,ratio; double point; char ch,c=„5‟,name; 14
  • 15.
    #include <stdio.h> #define PI3.414 const.c int main() { 3.414 printf("%.3f",PI); getch(); return 0; } 15
  • 16.
    • • short arr[3]; : : arr[0] = 50; 0020 50 2 arr arr[2] = 89; 0021 30 0 0022 211 arr 20 0023 5 arr[0] 50 0024 89 8 arr[1] 211 0025 23 0 arr[2] 89 0026 33 0027 12 : : 16
  • 17.
    • “ ” (array of char) char s[5] = "Hello"; printf("%c %c %cn", s[0], s[1], s[2]); 0 1 2 3 4 S H e l l o : H e l 17
  • 18.
    / • ( / ) “stdio.h” •  scanf ( %format) • (Output Function)  printf ( %format) 18
  • 19.
    • • printf int c = 65; : 2 printf("c (as a number) = %dn", c); 30 printf("c (as a character) = %cn", c); 65 c 5 : 8 c (as a number) = 65 23 c (as a character) = A : 19
  • 20.
    %format scanf printf %for mat int %d long %ld long long %lld unsigned int %u unsigned long %lu unsigned long long %llu float %f double %lf char %c char array[] %s 20
  • 21.
    scanf char name[20]; int age; printf("Enteryour name and age: "); scanf("%s %d", name, &age); printf("Hello %s. You are %d years old.n", name, age); : Enter your name and age: Tony 38 Hello Tony. You are 38 years old. 21
  • 22.
    START Statement1 Statement2 START Statement3 Statement END Statementn END 22
  • 23.
    Relational Operators • (Operand) Operator < <= > >= == != 23
  • 24.
    Expression • (Operand) (Operator) A = 10; B = 3; C = 20; Expressio n A+B 13 (A + B) – C -7 (C*B)+(A*B) 90 A%B 1 C%B 2 24
  • 25.
    Relational Operators • Relational Operators i = 1; j = 2; k = 3; Expression i<j true 1 (i + j) >= k true 1 (j + k) > (i + 5) false 0 k != 3 false 0 j == 2 true 1 25
  • 26.
    Logical (Bitwise) Operators • (Operand) Operator Operator) (Logical && AND || OR 26
  • 27.
    AND Operators • A B A && B True True T && T True 1 True False T && F False 0 False True F && T False 0 False False F && F False 0 27
  • 28.
    AND Operators • AND Operators i = 8; j = 4.5; k = „z‟; // ascii z 122 Expression (i >= 6) && (k == „z‟) T && T == T 1 (i >= 6) && (k == 122) T && T == T 1 (j >= 0) && (j != 4.5) T && F == F 0 (k > 0) && (j != 5) T && T == T 1 (i < 0) && (j > 0) && (k > 0) F && T && T == 0 F 28
  • 29.
    OR Operators • A B A || B True True T || T True 1 True False T || F True 1 False True F || T True 1 False False F || F False 0 29
  • 30.
    OR Operators • OR Operators i = 8; j = 4.5; k = „z‟; // ascii z 122 Expression (i >= 6) || (k == „z‟) T || T == T 1 (i >= 6) || (k != 122) T || F == T 1 (j < 0) || (j != 4.5) F || F == F 0 (k > 0) || (j != 5) T || T == T 1 30
  • 31.
    • i = 7;f = 4.5; Expression f>5 False 0 !(f > 5) True 1 i <= 3 False 0 !(i <=3) True 1 i > (f + 1) True 1 !(i > (f + 1)) False 0 31
  • 32.
    (Precedence) • Operators unary operators - , ++ , -- , ! , sizeof() R->L multiply, divide and *,/,% L->R remainder add and subtract +,- L->R relational < , <= , > , >= L->R equality == , != L->R 32
  • 33.
    (Precedence) • Operators and && L->R or || L->R assignment operators =, +=, -=, *=, /=, %= R->L 33
  • 34.
    i = 8;j = 4.5; k = „z‟; // ascii z 122 Expression i + j <= 10 False 0 i >= 8 && k == „z‟ True && True == True 1 k != „a‟ || i + j <= 10 True || False == True 1 k != „a‟ || i < j && k < i True || False && False 0 == True && False == False k != „a‟ || i < j && k < i True || False && False 1 == True || False == True 34
  • 35.
     if  if…else  if  switch-case •  while loop  do…while loop  for loop • 35
  • 36.
    if C Syntax Flowchart if (condition) START { statement1; : true condition statementN; } false Statement • condition Statement int • {} END condition • 36
  • 37.
    if #include <stdio.h> if1.c int main() { I>J int i=101,j=100; if(i>j) printf("I > J"); getch(); return 0; } 37
  • 38.
    if…else Flowchart C Syntax START if (condition) { true false statementt1; condition statementt2; Statementt1 Statementf1 } else Statementt2 Statementf2 { statementf1; statementf2; END } 38
  • 39.
    if…else #include <stdio.h> ifelse1.c int main() { I <= J int i=101,j=102; if(i>j) printf("I > J"); else printf("I <= J"); getch(); return 0; } 39
  • 40.
    if if (x==1) true Action1; x==1 Action1; false else if (x==2) x==2 true Action2; Action2; false else if (x==3) true x==3 Action3; Action3; false true else if (x==4) x==4 Action4; false Action4; Default_Action; else Default_Action; 40
  • 41.
    if #include <stdio.h> ifelse2.c int main() { >6 int i=7; if(i>7) printf("> 7"); else if(i>6) printf("> 6"); else if(i>5) printf("i> 5"); else printf("1 , 2 , 3"); getch(); return 0; } 41
  • 42.
    switch-case switch (x) x==1 true Action1; { case 1: Action1; false true break; x==2 Action2; case 2: Action2; false true break; x==3 Action3; case 3: Action3; false true break; x==4 Action4; case 4: Action4; false break; Default_Action; default: Default_Action; break; } 42
  • 43.
    switch-case #include <stdio.h> int main() switch1.c { int i=2; switch(i) { 2 case 2 : printf("2"); break; case 1 : printf("1"); break; default : printf("NO MATCH"); break; } getch(); return 0; } 43
  • 44.
    i++ = i = i--1 = i+ i = i- 1 i+=5 = i= i+i-=5 = 5 i = i- 5 44
  • 45.
    while while (condition) START { stmt1; stmt2; : false condition stmtN; } true Statement • stmt1 stmtN Statement condition END 45
  • 46.
    Counting Loop) • • int i, sum = 0; i = 1; while (i <= 10) { sum = sum + i; i = i + 1; } printf("Sum = %dn", sum); 46
  • 47.
    while #include <stdio.h> int main() while1.c { Hello 1 Hello 2 int i=1; Hello 3 while(i<=10) Hello 4 { Hello 5 Hello 6 printf("Hello %dn",i); Hello 7 i++; Hello 8 } Hello 9 Hello 10 getch(); return 0; } 47
  • 48.
    while (INFINITY LOOP) #include <stdio.h> int main() while2.c { Hello 1 int i=1; Hello 2 while(1) Hello 3 { Hello 4 printf("Hello %dn",i); Hello 5 if(i==10) Hello 6 Hello 7 break; Hello 8 i++; Hello 9 } Hello 10 getch(); return 0; } 48
  • 49.
    do…while do START { stmt1; stmt2; : Statement1 stmtN; } while (condition); StatementN • stmt1...stmtN true condition condition false • END stmt1...stmtN 49
  • 50.
    do…while #include <stdio.h> dowhile1.c int main() { Hello 1 int i=1; Hello 2 do Hello 3 Hello 4 { Hello 5 printf("Hello %dn",i); Hello 6 i++; Hello 7 } Hello 8 while(i<=10); Hello 9 getch(); Hello 10 return 0; } 50
  • 51.
    for • for (init_stmt; condition; update_stmt) { statement1; statement2; : statementN; } • 1. init_stmt 2. condition statement1...statementN 51
  • 52.
    for START init_stmt for (init_stmt; condition; update_stmt) { statement1; false statement2; condition : statementN; } true Statement1 StatementN update_stmt END 52
  • 53.
    for #include <stdio.h> int main() for1.c { Hello 1 Hello 2 int i; Hello 3 for(i=1;i<=10;i++) Hello 4 { Hello 5 Hello 6 printf("Hello %d",i); Hello 7 printf("n"); Hello 8 } Hello 9 Hello 10 getch(); return 0; } 53
  • 54.
    (Subroutine) • (Function) • •     54
  • 55.
    (Standard Functions)   printf(), scanf(), ... • (User Defined Functions)   main() 55
  • 56.
    scanf, printf, stdio.h gets, puts math.h sin, cos, exp, pow isalpha, isdigit, ctype.h islower, isupper string.h strlen, strcpy, strcmp stdlib.h rand, atoi, atof 56
  • 57.
    void say_hi(char *name) {  printf("Hi, %sn", name); void }  return int max(int a, int b) { • if (a > b) return a; else  return b; }  return 57
  • 58.
    #include <stdio.h> int incr(inti) { int j; function1.c j = i + 1; return j; } int main() { int k, m = 4; k = incr(m); printf ("k = %d, m = %dn", k, m); getch(); return 0; } 58
  • 59.
    (Function) #include<stdio.h> void print1() { printf(“Hello”); function2.c printf(“n”); } int main() { print1(); print1(); getch(); return 0; } 59
  • 60.
    (Function) #include <stdio.h> float cal_tax(floati) { function3.c float ctax; ctax = i*0.07; return ctax; } int main() { float money=7290,ff; ff = cal_tax(money); printf(“%f”,ff); getch(); return 0; } 60
  • 61.
  • 62.
    Enter N: 3 Enter N: 5 * * ** ** *** *** **** ***** 62
  • 63.
    #include <stdio.h> int main() { i scanf int i; scanf("%d", i); if (i = 0) puts("false"); (=) else puts("true"); (==) return 0; } 63