SlideShare a Scribd company logo
C Programming - Functions

Organized By: Vinay Arora
               Assistant Professor, CSED
               Thapar University, Patiala
Main program & its sub parts

   Function is also known as sub-program or module.

   Function is a self contained block of statements that perform coherent task of
   some kind.




                                     Vinay Arora
                                        CSED
Program-1

      #include<stdio.h>
      #include<conio.h>

      void main()
       {
        clrscr();

       printf("n Message for You");
       printf("n Department of Civil Engineering");

        getch();
       }




                              Vinay Arora
                                 CSED
Program-1 (output)




                     Vinay Arora
                        CSED
Program-2
       #include<stdio.h>
       #include<conio.h>

       void main()
        {
         clrscr();

        message();
        printf("n Department of Civil Engineering");

         getch();
        }

       message()
       {
        printf("n Message for You");
       }
                             Vinay Arora
                                CSED
Program-2 (output)




                     Vinay Arora
                        CSED
Program-3
      #include<stdio.h>
      #include<conio.h>

      void message();
      void main()
       {
        clrscr();

       message();
       printf("n Department of Civil Engineering");

        getch();
       }
      void message()
       {
        printf("n Message for You");
       }
                              Vinay Arora
                                 CSED
Program-3 (output)




                     Vinay Arora
                        CSED
Program-4
  #include<stdio.h>                          void civil()
  #include<conio.h>                           {
                                               printf("nCivil Engg.");
  void civil();                               }
  void computer();
  void electronics();                         void computer()
                                               {
  void main()                                   printf("nComputer Engg.");
   {                                           }
    clrscr();
                                              void electronics()
    civil();                                   {
    computer();                                 printf("nElectronics Engg.");
    electronics();                             }
    printf("nnDepartments at Thapar");
    getch();
   }
                                     Vinay Arora
                                        CSED
Program-4
  #include<stdio.h>                          void civil()
  #include<conio.h>                           {
                                               printf("nCivil Engg.");
  void civil();                               }
  void computer();
  void electronics();                         void computer()
                                               {
  void main()                                   printf("nComputer Engg.");
   {                                           }
    clrscr();
                                              void electronics()
    civil();                                   {
    computer();                                 printf("nElectronics Engg.");
    electronics();                             }
    printf("nnDepartments at Thapar");
    getch();
   }
                                     Vinay Arora
                                        CSED
Program-4 (output)




                     Vinay Arora
                        CSED
Program-5
  #include<stdio.h>                            void civil()
  #include<conio.h>                             {
                                                 printf("nCivil Engg.");
  void civil();                                  computer();
  void computer();                              }
  void electronics();
                                               void computer()
  void main()                                   {
   {                                             printf("nComputer Engg.");
    clrscr();                                    electronics();
                                                }
   civil();
                                               void electronics()
   printf("nnDepartments at Thapar");         {
                                                 printf("nElectronics Engg.");
    getch();                                    }
   }
                                     Vinay Arora
                                        CSED
Program-5
  #include<stdio.h>                            void civil()
  #include<conio.h>                             {
                                                 printf("nCivil Engg.");
  void civil();                                  computer();
  void computer();                              }
  void electronics();
                                               void computer()
  void main()                                   {
   {                                             printf("nComputer Engg.");
    clrscr();                                    electronics();
                                                }
   civil();
                                               void electronics()
   printf("nnDepartments at Thapar");         {
                                                 printf("nElectronics Engg.");
    getch();                                    }
   }
                                     Vinay Arora
                                        CSED
Program-5 (output)




                     Vinay Arora
                        CSED
Program-6
  #include<stdio.h>                          void civil()
  #include<conio.h>                           {
                                               printf("nCivil Engg.");
  void civil();                               }

  void main()
   {
    clrscr();

   civil();
   civil();

   printf("nnDepartments at Thapar");

    getch();
   }

                                     Vinay Arora
                                        CSED
Program-6
  #include<stdio.h>                          void civil()
  #include<conio.h>                           {
                                               printf("nCivil Engg.");
  void civil();                               }

  void main()
   {
    clrscr();

   civil();
   civil();

   printf("nnDepartments at Thapar");

    getch();
   }

                                     Vinay Arora
                                        CSED
Program-6 (output)




                     Vinay Arora
                        CSED
Program-7
       #include<stdio.h>
       #include<conio.h>

       void main()
        {
         int a,b,c;
         clrscr();

        printf("Enter Numbers for Additionn");
        printf("Enter 1st Number:t");
        scanf("%d",&a);
        printf("Enter 2nd Number:t");
        scanf("%d",&b);

         c=a+b;
         printf("Result after Addition is:%d",c);
         getch();
        }

                              Vinay Arora
                                 CSED
Program-7 (output)




                Vinay Arora
                   CSED
Program-8

    #include<stdio.h>      void sum()
    #include<conio.h>       {
                            int a,b,c;
    void sum();             printf("Enter Numbers for Additionn");
    void main()             printf("Enter 1st Number:t");
     {                      scanf("%d",&a);
      clrscr();             printf("Enter 2nd Number:t");
      sum();                scanf("%d",&b);
      getch();
     }                     c=a+b;
                           printf("Result after Addition is:%d",c);
                           }




                        Vinay Arora
                           CSED
Program-8 (output)




                Vinay Arora
                   CSED
Program-9
  #include<stdio.h>                            void sum(int x,int y)
  #include<conio.h>                              {
                                                  int z;
  void sum();                                     z=x+y;
  void main()                                     printf("Result after Addition is:%d",z);
   {                                             }
    int a,b,c;
    clrscr();

   printf("Enter Numbers for Additionn");
   printf("Enter 1st Number:t");
   scanf("%d",&a);
   printf("Enter 2nd Number:t");
   scanf("%d",&b);

   sum(a,b);

    getch();
   }
                                      Vinay Arora
                                         CSED
Program-9 (output)




                Vinay Arora
                   CSED
Program-10
  #include<stdio.h>                                  int sum(int x,int y)
  #include<conio.h>                                    {
                                                        int z;
  int sum();                                            z=x+y;
  void main()                                           return (z);
   {                                                   }
    int a,b,c;
    clrscr();

   printf("Enter Numbers for Additionn");
   printf("Enter 1st Number:t");
   scanf("%d",&a);
   printf("Enter 2nd Number:t");
   scanf("%d",&b);

   c=sum(a,b);

    printf("Result after Addition is:%d",c);
    getch();
   }
                                       Vinay Arora
                                          CSED
Program-10 (output)




                Vinay Arora
                   CSED
Program-11
   #include<stdio.h>                            int increment(int x)
   #include<conio.h>                             {
                                                  x++;
   int increment();                               return (x);
   void main()                                   }
    {
     int a,b,c;
     clrscr();

    printf("Enter Numbert");
    scanf("%d",&a);

    c=increment(a);

    printf("Result after Increment will be:%d",c);

     getch();
    }

                                      Vinay Arora
                                         CSED
Program-11 (output)




                Vinay Arora
                   CSED
Program-12
    #include<stdio.h>
    #include<conio.h>

    void display();
    void main()
     {
      int a=20;
      clrscr();

     display(a);

      getch();
     }

     void display(int x)
      {
       int y=27;
       printf("Value passed from main function is %dn",x);
       printf("Value present in display function is %d",y);
      }

                                        Vinay Arora
                                           CSED
Program-12 (output)




                Vinay Arora
                   CSED
Program-13
 #include<stdio.h>                         void display()
 #include<conio.h>                          {
                                             int x=25;
  void display();
  void main()                                printf("Value of x in display function is %d",x);
   {                                        }
    int x=20;
    clrscr();

   printf("Value of x in main function %dn",x);

   display();

   getch();
  }




                                        Vinay Arora
                                           CSED
Program-13 (output)




                Vinay Arora
                   CSED
Program-14
  #include<stdio.h>                    void display(int x)
  #include<conio.h>                     {
                                         x=77;
  void display();
  void main()                            printf("Value of x in display function is %d",x);
   {                                    }
    int x=20;
    clrscr();

   printf("Value of x in main function %dn",x);

   display();

    getch();
   }




                                       Vinay Arora
                                          CSED
Program-14 (output)




                Vinay Arora
                   CSED
Program-15
  #include<stdio.h>                                  int increment(int a)
  #include<conio.h>                                   {
                                                       a++;
  void display();                                      return (a);
  void main()                                         }
   {
    int a,b;                                         int decrement(int a)
    clrscr();                                         {
                                                       a--;
   printf("Enter Numbert");                           return (a);
   scanf("%d",&a);                                    }

    b=increment(a);
    printf("nValue after increment is %dt",b);
    b=decrement(a);
    printf("nValue after decrement is %dt",b);
    getch();
   }

                                       Vinay Arora
                                          CSED
Program-15 (output)




                Vinay Arora
                   CSED
Program-17

      #include<stdio.h>
      #include<conio.h>

       int increment();
       void main()
        {
         int i=10,j=20,k=30;
         clrscr();

        printf("%dt%dt%dn",i,j,k);
        printf("%dt%dt%dn",i,j);
        printf("%dn",i,j);

        getch();
       }

                           Vinay Arora
                              CSED
Program-17 (output)




                Vinay Arora
                   CSED
Program-18
  #include<stdio.h>
                                                float square(float x)
  #include<conio.h>
                                                  {
                                                   float y;
  float square(float);
                                                   y=x*x;
  void main()
                                                   return(y);
   {
                                                  }
    float a,b;
    clrscr();

   printf("Enter any Number:");
   scanf("%f",&a);

   b=square(a);
   printf("Square of number entered is %ft",b);

    getch();
   }
                                  Vinay Arora
                                     CSED
Program-18 (output)




                Vinay Arora
                   CSED
Program-19
 #include<stdio.h>                                 int factorial(int x)
 #include<conio.h>                                  {
                                                     int f=1,i;
  void main()
   {                                                 for(i=x;i>=1;i--)
    int a,fact;                                       f=f*i;
    clrscr();
                                                        return(f);
   printf("Enter any Number:");                     }
   scanf("%d",&a);

   fact=factorial(a);
   printf("Factorial Value is = %dn",fact);
   getch();
  }


                                     Vinay Arora
                                        CSED
Program-19 (output)




                Vinay Arora
                   CSED
Program-20 (Recursion in C)
    #include<stdio.h>                            int rec(int x)
    #include<conio.h>                             {
                                                   int f;
    int rec(int);
    void main()                                    if(x==1)
     {                                              return(1);
      int a,fact;                                  else
      clrscr();                                     f=x*rec(x-1);

     printf("Enter any Number:");                   return(f);
     scanf("%d",&a);                               }

     fact=rec(a);
     printf("Factorial Value is = %dn",fact);

      getch();
     }
                                 Vinay Arora
                                    CSED
Recursion




            Vinay Arora
               CSED
Program-20 (output)




                Vinay Arora
                   CSED
Program-21

        #include<stdio.h>
        #include<conio.h>

        void main()
         {
          int i;
          clrscr();

          for(i=0;i<=50000;i++)
            printf("%dn",i);
          getch();
         }




                        Vinay Arora
                           CSED
Program-21 (output)




                Vinay Arora
                   CSED
Program-22
   #include<stdio.h>                       void val()
   #include<conio.h>                        {
                                             i=100;
   int i=0;                                  printf("Val's i=%dn",i);
   void val();                               i++;
                                            }
   void main()
    {
     clrscr();
     printf("Main's i=%dn",i);
     i++;
     val();
     printf("Main's i=%dn",i);
     val();

     getch();
    }
                                  Vinay Arora
                                     CSED
Program-22 (output)




                Vinay Arora
                   CSED
Program-23
       #include<stdio.h>
       #include<conio.h>

       void main()
        {
         int count=5;
         clrscr();
         printf("Count=%dn",count);
         count--;

        if(count>0)
         main();
        else
         exit();

         getch();
        }
                           Vinay Arora
                              CSED
Program-23 (output)



          INFINITE LOOP




                Vinay Arora
                   CSED
Program-24
   #include<stdio.h>               int g(int x)
   #include<conio.h>                 {
                                      int v=1;
   int g(int);                        int b=3;
   void main()
    {                                    v+=x;
     int i,j;                            return(v+x+b);
     clrscr();                          }

    for(i=1;i<5;i++)
     {
      j=g(i);
      printf("%dn",j);
     }
    getch();
    }

                          Vinay Arora
                             CSED
Program-24 (output)




                Vinay Arora
                   CSED
Program-25
       #include<stdio.h>
       #include<conio.h>

       int x=10;
       void main()
        {
         int x=20;
         clrscr();
          {
           int x=30;
           printf("%dn",x);
          }
           printf("%dn",x);

            getch();
        }

                           Vinay Arora
                              CSED
Program-25 (output)




                Vinay Arora
                   CSED
Program-26
    #include<stdio.h>        void func()
    #include<conio.h>         {
                               int i,j,k;
    void func();               i=j=k=0;
    void main()
     {                         i++;j++;k++;
      clrscr();                printf("%d%d%dn",i,j,k);
      func();                 }
      func();
      getch();
     }




                        Vinay Arora
                           CSED
Program-26 (output)




                Vinay Arora
                   CSED
Thnx…



  Vinay Arora
     CSED

More Related Content

What's hot

Function in c program
Function in c programFunction in c program
Function in c program
umesh patil
 
Function in c
Function in cFunction in c
Function in c
savitamhaske
 
Functions in C
Functions in CFunctions in C
Functions in C
Princy Nelson
 
C and C++ functions
C and C++ functionsC and C++ functions
C and C++ functions
kavitha muneeshwaran
 
C programming function
C  programming functionC  programming function
C programming function
argusacademy
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
functions in C and types
functions in C and typesfunctions in C and types
functions in C and types
mubashir farooq
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
home
 
Function in c language(defination and declaration)
Function in c language(defination and declaration)Function in c language(defination and declaration)
Function in c language(defination and declaration)
VC Infotech
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
Sampath Kumar
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
imtiazalijoono
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
v_jk
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
UMA PARAMESWARI
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions
imtiazalijoono
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
AmIt Prasad
 
Types of function call
Types of function callTypes of function call
Types of function call
ArijitDhali
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
Dharma Kshetri
 
Functions in c
Functions in cFunctions in c
Functions in c
KavithaMuralidharan2
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2

What's hot (20)

Function in c program
Function in c programFunction in c program
Function in c program
 
Function in c
Function in cFunction in c
Function in c
 
Functions in C
Functions in CFunctions in C
Functions in C
 
C and C++ functions
C and C++ functionsC and C++ functions
C and C++ functions
 
C programming function
C  programming functionC  programming function
C programming function
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Function
FunctionFunction
Function
 
functions in C and types
functions in C and typesfunctions in C and types
functions in C and types
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Function in c language(defination and declaration)
Function in c language(defination and declaration)Function in c language(defination and declaration)
Function in c language(defination and declaration)
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Types of function call
Types of function callTypes of function call
Types of function call
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
Advanced C - Part 2
 

Viewers also liked

C Tutorial
C TutorialC Tutorial
C Tutorial
biochelo
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
hossam nassar
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structuresvinay arora
 
C Prog. - ASCII Values, Break, Continue
C Prog. -  ASCII Values, Break, ContinueC Prog. -  ASCII Values, Break, Continue
C Prog. - ASCII Values, Break, Continuevinay arora
 
C Prog. - Data Types, Variables and Constants
C Prog. - Data Types, Variables and ConstantsC Prog. - Data Types, Variables and Constants
C Prog. - Data Types, Variables and Constantsvinay arora
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)vinay arora
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointersvinay arora
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controlsvinay arora
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphicsvinay arora
 
Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawler
vinay arora
 
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & FlowchartC Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchartvinay arora
 
Advanced SQL - Lecture 6 - Introduction to Databases (1007156ANR)
Advanced SQL - Lecture 6 - Introduction to Databases (1007156ANR)Advanced SQL - Lecture 6 - Introduction to Databases (1007156ANR)
Advanced SQL - Lecture 6 - Introduction to Databases (1007156ANR)
Beat Signer
 
Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)
Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)
Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)
Beat Signer
 
08. Numeral Systems
08. Numeral Systems08. Numeral Systems
08. Numeral Systems
Intro C# Book
 
Top 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and AnswersTop 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and Answers
iimjobs and hirist
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 

Viewers also liked (20)

C Tutorial
C TutorialC Tutorial
C Tutorial
 
C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structures
 
C Prog. - ASCII Values, Break, Continue
C Prog. -  ASCII Values, Break, ContinueC Prog. -  ASCII Values, Break, Continue
C Prog. - ASCII Values, Break, Continue
 
C Prog. - Data Types, Variables and Constants
C Prog. - Data Types, Variables and ConstantsC Prog. - Data Types, Variables and Constants
C Prog. - Data Types, Variables and Constants
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
 
C programming slide-6
C programming slide-6C programming slide-6
C programming slide-6
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphics
 
Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawler
 
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & FlowchartC Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
 
Advanced SQL - Lecture 6 - Introduction to Databases (1007156ANR)
Advanced SQL - Lecture 6 - Introduction to Databases (1007156ANR)Advanced SQL - Lecture 6 - Introduction to Databases (1007156ANR)
Advanced SQL - Lecture 6 - Introduction to Databases (1007156ANR)
 
Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)
Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)
Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)
 
08. Numeral Systems
08. Numeral Systems08. Numeral Systems
08. Numeral Systems
 
Top 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and AnswersTop 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and Answers
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 

Similar to C Prog - Functions

C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
Dr.M.Karthika parthasarathy
 
C Prog - Strings
C Prog - StringsC Prog - Strings
C Prog - Stringsvinay arora
 
C lab
C labC lab
C basics
C basicsC basics
C basicsMSc CST
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
loyola ICAM college of engineering and technology
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
Zaibi Gondal
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
AMIT SINGH
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
Jaydip JK
 
Cpds lab
Cpds labCpds lab
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
Kandarp Tiwari
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1Little Tukta Lita
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
Compiler design lab
Compiler design labCompiler design lab
Compiler design lab
ilias ahmed
 

Similar to C Prog - Functions (20)

C Programming
C ProgrammingC Programming
C Programming
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
 
C Prog - Strings
C Prog - StringsC Prog - Strings
C Prog - Strings
 
C lab
C labC lab
C lab
 
C basics
C basicsC basics
C basics
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
week-8x
week-8xweek-8x
week-8x
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Compiler design lab
Compiler design labCompiler design lab
Compiler design lab
 

More from vinay arora

Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)
vinay arora
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
vinay arora
 
Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)
vinay arora
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)
vinay arora
 
6 java - loop
6  java - loop6  java - loop
6 java - loop
vinay arora
 
4 java - decision
4  java - decision4  java - decision
4 java - decision
vinay arora
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
vinay arora
 
2 java - operators
2  java - operators2  java - operators
2 java - operators
vinay arora
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
vinay arora
 
Uta005 lecture3
Uta005 lecture3Uta005 lecture3
Uta005 lecture3
vinay arora
 
Uta005 lecture1
Uta005 lecture1Uta005 lecture1
Uta005 lecture1
vinay arora
 
Uta005 lecture2
Uta005 lecture2Uta005 lecture2
Uta005 lecture2
vinay arora
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protectionvinay arora
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronizationvinay arora
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitivesvinay arora
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devicesvinay arora
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devicesvinay arora
 
A&D - Object Oriented Design using UML
A&D - Object Oriented Design using UMLA&D - Object Oriented Design using UML
A&D - Object Oriented Design using UMLvinay arora
 

More from vinay arora (20)

Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
 
Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)
 
6 java - loop
6  java - loop6  java - loop
6 java - loop
 
4 java - decision
4  java - decision4  java - decision
4 java - decision
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
 
2 java - operators
2  java - operators2  java - operators
2 java - operators
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
 
Uta005 lecture3
Uta005 lecture3Uta005 lecture3
Uta005 lecture3
 
Uta005 lecture1
Uta005 lecture1Uta005 lecture1
Uta005 lecture1
 
Uta005 lecture2
Uta005 lecture2Uta005 lecture2
Uta005 lecture2
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protection
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitives
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devices
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devices
 
A&D - UML
A&D - UMLA&D - UML
A&D - UML
 
A&D - Object Oriented Design using UML
A&D - Object Oriented Design using UMLA&D - Object Oriented Design using UML
A&D - Object Oriented Design using UML
 
C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
 

Recently uploaded

哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
9u08k0x
 
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docxThe Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
Xtreame HDTV
 
A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024
Indira Srivatsa
 
Skeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on ForumSkeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on Forum
Isaac More
 
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and SafetyModern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
AITIX LLC
 
Christina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptxChristina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptx
madeline604788
 
Treasure Hunt Puzzles, Treasure Hunt Puzzles online
Treasure Hunt Puzzles, Treasure Hunt Puzzles onlineTreasure Hunt Puzzles, Treasure Hunt Puzzles online
Treasure Hunt Puzzles, Treasure Hunt Puzzles online
Hidden Treasure Hunts
 
Scandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.zaScandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.za
Isaac More
 
Tom Selleck Net Worth: A Comprehensive Analysis
Tom Selleck Net Worth: A Comprehensive AnalysisTom Selleck Net Worth: A Comprehensive Analysis
Tom Selleck Net Worth: A Comprehensive Analysis
greendigital
 
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdfMaximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Xtreame HDTV
 
The Journey of an Indie Film - Mark Murphy Director
The Journey of an Indie Film - Mark Murphy DirectorThe Journey of an Indie Film - Mark Murphy Director
The Journey of an Indie Film - Mark Murphy Director
Mark Murphy Director
 
Reimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a SuccessReimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a Success
Mark Murphy Director
 
Meet Dinah Mattingly – Larry Bird’s Partner in Life and Love
Meet Dinah Mattingly – Larry Bird’s Partner in Life and LoveMeet Dinah Mattingly – Larry Bird’s Partner in Life and Love
Meet Dinah Mattingly – Larry Bird’s Partner in Life and Love
get joys
 
Snoopy boards the big bow wow musical __
Snoopy boards the big bow wow musical __Snoopy boards the big bow wow musical __
Snoopy boards the big bow wow musical __
catcabrera
 
240529_Teleprotection Global Market Report 2024.pdf
240529_Teleprotection Global Market Report 2024.pdf240529_Teleprotection Global Market Report 2024.pdf
240529_Teleprotection Global Market Report 2024.pdf
Madhura TBRC
 
Young Tom Selleck: A Journey Through His Early Years and Rise to Stardom
Young Tom Selleck: A Journey Through His Early Years and Rise to StardomYoung Tom Selleck: A Journey Through His Early Years and Rise to Stardom
Young Tom Selleck: A Journey Through His Early Years and Rise to Stardom
greendigital
 
This Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I MadeThis Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I Made
Aarush Ghate
 
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdfMatt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Azura Everhart
 
Hollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest galleryHollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest gallery
Zsolt Nemeth
 
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
9u08k0x
 

Recently uploaded (20)

哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
 
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docxThe Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
 
A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024
 
Skeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on ForumSkeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on Forum
 
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and SafetyModern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
 
Christina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptxChristina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptx
 
Treasure Hunt Puzzles, Treasure Hunt Puzzles online
Treasure Hunt Puzzles, Treasure Hunt Puzzles onlineTreasure Hunt Puzzles, Treasure Hunt Puzzles online
Treasure Hunt Puzzles, Treasure Hunt Puzzles online
 
Scandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.zaScandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.za
 
Tom Selleck Net Worth: A Comprehensive Analysis
Tom Selleck Net Worth: A Comprehensive AnalysisTom Selleck Net Worth: A Comprehensive Analysis
Tom Selleck Net Worth: A Comprehensive Analysis
 
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdfMaximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
 
The Journey of an Indie Film - Mark Murphy Director
The Journey of an Indie Film - Mark Murphy DirectorThe Journey of an Indie Film - Mark Murphy Director
The Journey of an Indie Film - Mark Murphy Director
 
Reimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a SuccessReimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a Success
 
Meet Dinah Mattingly – Larry Bird’s Partner in Life and Love
Meet Dinah Mattingly – Larry Bird’s Partner in Life and LoveMeet Dinah Mattingly – Larry Bird’s Partner in Life and Love
Meet Dinah Mattingly – Larry Bird’s Partner in Life and Love
 
Snoopy boards the big bow wow musical __
Snoopy boards the big bow wow musical __Snoopy boards the big bow wow musical __
Snoopy boards the big bow wow musical __
 
240529_Teleprotection Global Market Report 2024.pdf
240529_Teleprotection Global Market Report 2024.pdf240529_Teleprotection Global Market Report 2024.pdf
240529_Teleprotection Global Market Report 2024.pdf
 
Young Tom Selleck: A Journey Through His Early Years and Rise to Stardom
Young Tom Selleck: A Journey Through His Early Years and Rise to StardomYoung Tom Selleck: A Journey Through His Early Years and Rise to Stardom
Young Tom Selleck: A Journey Through His Early Years and Rise to Stardom
 
This Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I MadeThis Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I Made
 
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdfMatt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
 
Hollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest galleryHollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest gallery
 
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
 

C Prog - Functions

  • 1. C Programming - Functions Organized By: Vinay Arora Assistant Professor, CSED Thapar University, Patiala
  • 2. Main program & its sub parts Function is also known as sub-program or module. Function is a self contained block of statements that perform coherent task of some kind. Vinay Arora CSED
  • 3. Program-1 #include<stdio.h> #include<conio.h> void main() { clrscr(); printf("n Message for You"); printf("n Department of Civil Engineering"); getch(); } Vinay Arora CSED
  • 4. Program-1 (output) Vinay Arora CSED
  • 5. Program-2 #include<stdio.h> #include<conio.h> void main() { clrscr(); message(); printf("n Department of Civil Engineering"); getch(); } message() { printf("n Message for You"); } Vinay Arora CSED
  • 6. Program-2 (output) Vinay Arora CSED
  • 7. Program-3 #include<stdio.h> #include<conio.h> void message(); void main() { clrscr(); message(); printf("n Department of Civil Engineering"); getch(); } void message() { printf("n Message for You"); } Vinay Arora CSED
  • 8. Program-3 (output) Vinay Arora CSED
  • 9. Program-4 #include<stdio.h> void civil() #include<conio.h> { printf("nCivil Engg."); void civil(); } void computer(); void electronics(); void computer() { void main() printf("nComputer Engg."); { } clrscr(); void electronics() civil(); { computer(); printf("nElectronics Engg."); electronics(); } printf("nnDepartments at Thapar"); getch(); } Vinay Arora CSED
  • 10. Program-4 #include<stdio.h> void civil() #include<conio.h> { printf("nCivil Engg."); void civil(); } void computer(); void electronics(); void computer() { void main() printf("nComputer Engg."); { } clrscr(); void electronics() civil(); { computer(); printf("nElectronics Engg."); electronics(); } printf("nnDepartments at Thapar"); getch(); } Vinay Arora CSED
  • 11. Program-4 (output) Vinay Arora CSED
  • 12. Program-5 #include<stdio.h> void civil() #include<conio.h> { printf("nCivil Engg."); void civil(); computer(); void computer(); } void electronics(); void computer() void main() { { printf("nComputer Engg."); clrscr(); electronics(); } civil(); void electronics() printf("nnDepartments at Thapar"); { printf("nElectronics Engg."); getch(); } } Vinay Arora CSED
  • 13. Program-5 #include<stdio.h> void civil() #include<conio.h> { printf("nCivil Engg."); void civil(); computer(); void computer(); } void electronics(); void computer() void main() { { printf("nComputer Engg."); clrscr(); electronics(); } civil(); void electronics() printf("nnDepartments at Thapar"); { printf("nElectronics Engg."); getch(); } } Vinay Arora CSED
  • 14. Program-5 (output) Vinay Arora CSED
  • 15. Program-6 #include<stdio.h> void civil() #include<conio.h> { printf("nCivil Engg."); void civil(); } void main() { clrscr(); civil(); civil(); printf("nnDepartments at Thapar"); getch(); } Vinay Arora CSED
  • 16. Program-6 #include<stdio.h> void civil() #include<conio.h> { printf("nCivil Engg."); void civil(); } void main() { clrscr(); civil(); civil(); printf("nnDepartments at Thapar"); getch(); } Vinay Arora CSED
  • 17. Program-6 (output) Vinay Arora CSED
  • 18. Program-7 #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("Enter Numbers for Additionn"); printf("Enter 1st Number:t"); scanf("%d",&a); printf("Enter 2nd Number:t"); scanf("%d",&b); c=a+b; printf("Result after Addition is:%d",c); getch(); } Vinay Arora CSED
  • 19. Program-7 (output) Vinay Arora CSED
  • 20. Program-8 #include<stdio.h> void sum() #include<conio.h> { int a,b,c; void sum(); printf("Enter Numbers for Additionn"); void main() printf("Enter 1st Number:t"); { scanf("%d",&a); clrscr(); printf("Enter 2nd Number:t"); sum(); scanf("%d",&b); getch(); } c=a+b; printf("Result after Addition is:%d",c); } Vinay Arora CSED
  • 21. Program-8 (output) Vinay Arora CSED
  • 22. Program-9 #include<stdio.h> void sum(int x,int y) #include<conio.h> { int z; void sum(); z=x+y; void main() printf("Result after Addition is:%d",z); { } int a,b,c; clrscr(); printf("Enter Numbers for Additionn"); printf("Enter 1st Number:t"); scanf("%d",&a); printf("Enter 2nd Number:t"); scanf("%d",&b); sum(a,b); getch(); } Vinay Arora CSED
  • 23. Program-9 (output) Vinay Arora CSED
  • 24. Program-10 #include<stdio.h> int sum(int x,int y) #include<conio.h> { int z; int sum(); z=x+y; void main() return (z); { } int a,b,c; clrscr(); printf("Enter Numbers for Additionn"); printf("Enter 1st Number:t"); scanf("%d",&a); printf("Enter 2nd Number:t"); scanf("%d",&b); c=sum(a,b); printf("Result after Addition is:%d",c); getch(); } Vinay Arora CSED
  • 25. Program-10 (output) Vinay Arora CSED
  • 26. Program-11 #include<stdio.h> int increment(int x) #include<conio.h> { x++; int increment(); return (x); void main() } { int a,b,c; clrscr(); printf("Enter Numbert"); scanf("%d",&a); c=increment(a); printf("Result after Increment will be:%d",c); getch(); } Vinay Arora CSED
  • 27. Program-11 (output) Vinay Arora CSED
  • 28. Program-12 #include<stdio.h> #include<conio.h> void display(); void main() { int a=20; clrscr(); display(a); getch(); } void display(int x) { int y=27; printf("Value passed from main function is %dn",x); printf("Value present in display function is %d",y); } Vinay Arora CSED
  • 29. Program-12 (output) Vinay Arora CSED
  • 30. Program-13 #include<stdio.h> void display() #include<conio.h> { int x=25; void display(); void main() printf("Value of x in display function is %d",x); { } int x=20; clrscr(); printf("Value of x in main function %dn",x); display(); getch(); } Vinay Arora CSED
  • 31. Program-13 (output) Vinay Arora CSED
  • 32. Program-14 #include<stdio.h> void display(int x) #include<conio.h> { x=77; void display(); void main() printf("Value of x in display function is %d",x); { } int x=20; clrscr(); printf("Value of x in main function %dn",x); display(); getch(); } Vinay Arora CSED
  • 33. Program-14 (output) Vinay Arora CSED
  • 34. Program-15 #include<stdio.h> int increment(int a) #include<conio.h> { a++; void display(); return (a); void main() } { int a,b; int decrement(int a) clrscr(); { a--; printf("Enter Numbert"); return (a); scanf("%d",&a); } b=increment(a); printf("nValue after increment is %dt",b); b=decrement(a); printf("nValue after decrement is %dt",b); getch(); } Vinay Arora CSED
  • 35. Program-15 (output) Vinay Arora CSED
  • 36. Program-17 #include<stdio.h> #include<conio.h> int increment(); void main() { int i=10,j=20,k=30; clrscr(); printf("%dt%dt%dn",i,j,k); printf("%dt%dt%dn",i,j); printf("%dn",i,j); getch(); } Vinay Arora CSED
  • 37. Program-17 (output) Vinay Arora CSED
  • 38. Program-18 #include<stdio.h> float square(float x) #include<conio.h> { float y; float square(float); y=x*x; void main() return(y); { } float a,b; clrscr(); printf("Enter any Number:"); scanf("%f",&a); b=square(a); printf("Square of number entered is %ft",b); getch(); } Vinay Arora CSED
  • 39. Program-18 (output) Vinay Arora CSED
  • 40. Program-19 #include<stdio.h> int factorial(int x) #include<conio.h> { int f=1,i; void main() { for(i=x;i>=1;i--) int a,fact; f=f*i; clrscr(); return(f); printf("Enter any Number:"); } scanf("%d",&a); fact=factorial(a); printf("Factorial Value is = %dn",fact); getch(); } Vinay Arora CSED
  • 41. Program-19 (output) Vinay Arora CSED
  • 42. Program-20 (Recursion in C) #include<stdio.h> int rec(int x) #include<conio.h> { int f; int rec(int); void main() if(x==1) { return(1); int a,fact; else clrscr(); f=x*rec(x-1); printf("Enter any Number:"); return(f); scanf("%d",&a); } fact=rec(a); printf("Factorial Value is = %dn",fact); getch(); } Vinay Arora CSED
  • 43. Recursion Vinay Arora CSED
  • 44. Program-20 (output) Vinay Arora CSED
  • 45. Program-21 #include<stdio.h> #include<conio.h> void main() { int i; clrscr(); for(i=0;i<=50000;i++) printf("%dn",i); getch(); } Vinay Arora CSED
  • 46. Program-21 (output) Vinay Arora CSED
  • 47. Program-22 #include<stdio.h> void val() #include<conio.h> { i=100; int i=0; printf("Val's i=%dn",i); void val(); i++; } void main() { clrscr(); printf("Main's i=%dn",i); i++; val(); printf("Main's i=%dn",i); val(); getch(); } Vinay Arora CSED
  • 48. Program-22 (output) Vinay Arora CSED
  • 49. Program-23 #include<stdio.h> #include<conio.h> void main() { int count=5; clrscr(); printf("Count=%dn",count); count--; if(count>0) main(); else exit(); getch(); } Vinay Arora CSED
  • 50. Program-23 (output) INFINITE LOOP Vinay Arora CSED
  • 51. Program-24 #include<stdio.h> int g(int x) #include<conio.h> { int v=1; int g(int); int b=3; void main() { v+=x; int i,j; return(v+x+b); clrscr(); } for(i=1;i<5;i++) { j=g(i); printf("%dn",j); } getch(); } Vinay Arora CSED
  • 52. Program-24 (output) Vinay Arora CSED
  • 53. Program-25 #include<stdio.h> #include<conio.h> int x=10; void main() { int x=20; clrscr(); { int x=30; printf("%dn",x); } printf("%dn",x); getch(); } Vinay Arora CSED
  • 54. Program-25 (output) Vinay Arora CSED
  • 55. Program-26 #include<stdio.h> void func() #include<conio.h> { int i,j,k; void func(); i=j=k=0; void main() { i++;j++;k++; clrscr(); printf("%d%d%dn",i,j,k); func(); } func(); getch(); } Vinay Arora CSED
  • 56. Program-26 (output) Vinay Arora CSED
  • 57. Thnx… Vinay Arora CSED