SlideShare una empresa de Scribd logo
1 de 56
 What is c?
 Do you tell  us about c, perhaps you thing that
  is a programming language but……
  now……….
 What is z?
 You tell us it is an alphabets. In the same way
  c is also an alphabets.
 Now when some one asking you about c
  language then tell him about c language.
 This type of answer make an impression on
  interviewer, which is beneficial for us.
 History   of c language –
                       algol

   (kenthomsan) B              BCPL (Mortin)

                          c (Denice Richi)
(At & t bell laboratory in U.S.A.)
C  language developed in 1972 at & t bell
  laboratory in U.S.A.
 First time c language written in Unix, but in
  further it written in it self.
 Unix O.S. is also written in c language.
Basic element of c languages.
 Every language have some elements which help
  us to understand and working with that language.
 So there are some element in c also …..
 Alphabets -
 a, b………?
 A, B………z.
 Numeric values – 0,1,2………9.
 Special symbols –
 # , ; : ( ) [ ] { } / * + - %...............
 Key words –
 There are 32 keywords in c language.
Some predefine function in c
 print f ( )
 scan f ( )
 getch ( )
 clrscr ( )
 getche ( )
 printf  – it is a predefine function which is use
  to print something on the screen at runtime.
 printf (“Namaste”);
 In above example what we write down in
  double quarts that is printed same an screen.
int x;
x = 10;
printf (“ % d “, x);
In ex printf print the value of x.
 scanf   – it is also a predefine function
  which is use to take user input at runtime
  (execution time)
   int x;
   scanf (“ % d”, f x)
 In above example we take value for x
  variable integer type.
 getch  ( ) – It is also predefine function
  which hold the screen, till it dose not get a
  character.
 As it get the character it release the
  screen.


 getche( ) – getche ( ) is also work same
 as getch ( ), but difference it first print the
 taken character then release the screen.
Inclucle <stdio.h>
 vaid maine ( )
  {
    Print f (“vandematram”);
    Getche ( );
    Getch ( );
   }
 Hear first getche ( ) hold the screen, when he
 get a character then it release, then getch()
 hold;
# include <stdio.h>
  void main ( )
  {
   Print f (“vandematram”);
   getch ( );
   getche ( );
   }
  Hear first getch ( ) hold the screen, when
  he get a character then it release, then
  getche() hold;
 Identifiers – Identifiers are such type of entity
  through which we uniquely identified any thing.
 ex- variable name, painter name, array name,
  function name, structure name, union name etc.
 Rule for identifiers name –
 An identifier contain only alphabets, numeric
  values and under score (-).
 An identifiers name always start with alphabets or
  under score.
 No special symbols or white space use instead of
  under score. (-).
 Variable  – variable are those identifiers
  which value change during the program.
 ex –
     int x;
     char y;
 Constant – constant are those identifiers
  which value never change during in
  program.
 Data  type – it tell us about the type of are
  identifiers.
 ex -
      int a;
 In above ex- a is an integer type variable, it
  hold the integer value the key word int tell
  s us.
 Type   of data type – There are manly two
  type of data type in c.
 Primary data type.
 Secondary data type.
Primary data type secondary data type
    int                       string
   float                       array
  char                         painter
 double                       structure
                             union
                             function
 int– int is a key word which is used to
  create a integer type variable.
 ex –
     int x
     x = 10;
 x hold integer type value.
 char   – It is also a key word which is used
      to create a character type variable it
    always hold a single character, which is
         denoted by „ ‟ (single a uates)
 char a;
  a =„m‟;
 In above a is a character type variable
  which hold a single character.
 float – it is also a key word which is used
  to create a float type variable.
 ex-
 float b;
  b = 2.35;
 In above, b is a float type variable hold a
  decimal value.
   Operators in c-
   C support a number of built-in operators. we have already
    used several of them,
   Some are =,+,-,*,&and <.An operator is a symbol that tells the
    computer to perform some manipulation to manipulate data
    and variables.
   C operators can be classified in to a
   i) number of categories.
   ii) relational operators.
   iii) logical operators.
   iv) assignment operators.
   v) increment & decrement operators
   vi) arithmetic operators
   vii) conditional operators
   viii) bitwise operators
   ix) special operators.
 Arithmetic operators-
 C provides all the basic arithmetic operators.
  They are listed in table.


    Operators         Meaning
    +                 Addition or unary plus
    -                 Subtraction or unary minus
    *                 Multiplication
    /                 Division
    %                 Modulo division
   ex-1.
   int a, b, c;
        b = 10;
       c = 12;
   ex- 2. a + b + c;
    float b = 2.5;
          c = 3.2;
          a = b + c;
   ex-3.
     int a;
     float b, c;
          a = 10;
          c = 3.5
          b = a + b;
 Relation  operators-
 We often compare two quantities and
  depending on their relation. Take certain
  decisions. For this type of comparisons we
  use relation operators.
 those are- Operator           Meaning
             <                 is less than
             <=                is less than or equal to
             >                 is greater than
             <=                is greater than or equal
             to
             ==                is equal to
 Logical operators-
 In addition to the relational
                             operators. C has
 these following logical operators.
    Operator            Meaning
    &&                  logical AND
    ||                  logical OR
    !                   logical NOT

 Assignment  operators-
 Assignment  operators are used to assign an
  opropriate value to the variable.
 We use „=‟ as assignment operator.
 Increment   and decrement operators-
 C allows two very use full operators these
  are increment and decrement operators.
 ++ and --
 *The operators ++ adds 1 to the operand,
  while – subtracts 1. * both are unary
  operators and (such operators which work
  with single operand (variable).
 ex-       int a;
           a + +;
 They are implemented in two ways
 Prefix.
 Pastfis.
 Prefix- first perform in crement decrement
  then assigne the value.
     int a;
    ++ a;
    int b;
    -- b;
 Postfix – first assigne the the value then
  perferm increment decrement.
 Conditional   operator-
 There is an   operator pair “?” is available in C,
  to construct conditional expressions of the
  form.
 A1 ? A2 : A3
 A1, A2, A3 are expressions .
 in above first expressions A, evaluated.
 a = 10;
 b = 15;
 m = (a > b) ? a : b;
 It is use to replace if use.
 Bit   wise operators-
   If ……. else
   This is a bi-direction conditional control statement. This
    statement is used to test a condition and take one of the two
    possible actions.
   If the condition is true then a single statement or block is
    executed, other wish another single statement or block is
    executed.
   if (condition)
   {
   Statement 1
   }
   Else
   {
   Statement 2
   }
Nesting       of if ……. else-
 We  can have another if….. else statement
 in the if block or the else block if….. else
 statement.
   Switch –
   This is a multi-directional conditional control statement some time there is a
    need in program to make choice among number of alter natives.
   For making this choice, we use the switch statement.
   switch (expression)
   {
   case 1:
   statement 1;
   Break; ………..
   case 2:
   statement 2;
   … Break; ………
   case 3:
   statement 3;
   …… Break; ……
   default :
   statement 4;
   ………..
   }
   Now we will see the same valid invalid ways of writing switch
    expression and case expression.
   int a, b, c; char d, e; float f;
   Valid –
   Switch (a) switch (a>b) switch (d+e-3) switch (a>b && b>c)
    switch cfine (a,b,)
   Invalid –
   switch (f) switch (a+4.5)
   Valid case 4: case „a‟ : case 2+4
   case „a‟ > „b‟ :
   Invalid –
   case ”second” : case 2.3 : case a :
   case a>b : case a+2 :
   case 2, 3, 4 : case 2 : 4 : 3 :
   Loop - loops are used when we want to execute a part of program or a
    block of statement several times.
   There are three loop statement in C-
   for loop
   while loop
   do while loop
   for – the for loop is very usefull in C programming.
   It has three expressions and semicolons are used for separating these
    expression.
   for (initialization; condition; increment)
   {
   statement;
   }
   ex-
   int a;
   for (a=0; a<3; a++)
   {
   printf (“Namuste”);
   }
   While –
   It is written as –
   initialization;
   while (condition)
   {
   statement :
   Increment /Decrement;
   }
   ex- int a;
         a=0;
   while (a<3)
   {
   printf (“ Vande Matram”);
   a ++;
   }
   do while – it is different from for and while loop. it first execute the
    statement then check the condition.
   initialization :
   do
   {
   statement :
   increment /Decrenet)
   }
   while 9condition);
   ex-
   int a;
   a = 0;
   do
   {
   printf (“ jai Hanuman”);
   a ++;
   }
   while (a < 5);
   * in do while condition is either true or false statement must executed once.
 Nested loop-
 When we use a loop inside the another loop body
  (both are same) it is known as nested loop.
 ex-
 for (x = 0 ; x < 5 ; x + +)
{
 for (y = 1 ; y < 5 : y + +)
{
 printf (“% d % d ‟‟ x, y) ;
}
}
 In above this the example of nested for loop.
 Function – function is an entity which perform
  some specific.
 A function is a self-contained subprogram that is
  meant to do some specific, well-define task.
 *A program consists of one or more function.
 *If a program has only one function then it must be
  the main ( ) function .
 *function always return a value.
 C program have two types of function –
 1. Library function
 2. User define function
   Library function –
   C has the facility to provide library functions for
    performing some operations. These function are present
    in the C library and they are predefined.

          Function Name        Operation
          Sgrt ( )             find squre root of nuber
          scanf ( )            take input
          printf ( )           for print on screen
          strlen ( )           lenth of string
          strcmp ( )           comparision
          clrscr ( )           for clear the screen
          getch ( )            for hold the screen
   User- define function-
   User can create their own functions for performing any specific
    task of the program. These type of function are called user
    define function.
   User define function have these three parts-
   1. Function declaration
   2. Function definition
   3. Function calling
   Function definition-
   The function definition consist of the whole description and
    code of a function. It tells what the function is doing and what
    are its input and output.
   Function calling-
   A function is called by simply writing its name followed by the
    argument list inside the parentheses (if any).
   Function declaration-
   Function declaration give the information to calling function
    about called function.
   If called function is placed before calling function then there no
    need for declaration.
   ex- #includi <stdioh>
   valid ram ( ) ;                 declaration
   valid main ( ) ;               of function
   {
    ram ( ) ;                      calling offention
   }
   Void ram ( )
   {
   printf (“ vande matram ‟‟) ;
   }
   Type of user define function –
   1. function with no argument and no return type.
   2. function with no argument and a return type.
   3. function with argument and no return type.
   4. function with argument and a return type.
   Function with no argument and no return type-
   A function which has no argument and no return type………..
   #include<stdio.h>
   void func ( ) ;
   void main ( )
   {
   func ( ) ;
   }
   void func ( )
   {
   statement ;
   }
   In above program func ( ) has no argument and it does not return any value.
   Function with no argument and a return type –
   These type of function do not recene any argument but return
    a value.
   int func ( ) ;
   void main ( )
   {
   int n ;
   n = func ( ) ;
   }
   int func ( )
   {
   int a ;
   ………
   ………
   return a ;
   }
   function with argument and no return type.-These types of
    function have arguments, hence calling function send data to
    the calling function but function does not return a value.
   void func (int a) ;
   void main ( )
   {
   int m ;
   func (m);
   }
   void func (int x)
   {
   ……………….
   ……………….
   ……………….
   }
   Function with argument and a return type-
   These type function have arguments, so the calling function can send data
    to the called function. It can also return any value to the calling function
    using return statement.
   int func (int, int)
   {
   void main ( )
   {
   int r ;
   …….
   r = func (a, b) ;
   ……….
   }
   int func (int a, int b)
   {
   ………….
   ………….
   return (expression) ;
   }
   Arrays –
   The variables that we have used till now are capable of storing
    only one value at a time.
   So we have an array that can hold more than one value of
    some type.
   “ Array is a collection of similar type of data.‟‟
   ex -
   int a [10] ;
   a [10] = {1, 2, 5, 3, 2…...} ;
   In above example a is an array of size 10, it can hold 10
    values of same time of data type.
   ex-2- int a [3] 0, c‟ ;
   for (c‟ = 0 ; c‟ < 3 ; c‟ ++)
   {
   scanf (“ % d‟‟, & a [c‟] ) ;
   }
 ex-1- int a [3] ;
 a [0] = 10 ;
 a [1] = 22 ;
 a [2] = 11 ;
 /* The size of array is 3, it hold   three value */
 Print the value of an array –
 int a [3] 0, c‟ ;
 for ( I = 0 ; c‟ < 3 ; c‟ ++ )
{
 printf ( “ % d”, a [i] ) ;
   Passing array to a function –
   We know that an array element is treated as any other simple variable in the
    program. So we can simply pass an individual array element to the function
    as argument.
   void funct ( int a ) ;
   void main ( )
   {
   int arr [10], i ;
   for ( i = 0 ; c‟ < 10 ; c‟ ++ )
   {
   scanf ( “ % d‟‟, & arr [i] ) ;
   funct ( arr [i] ) ;
   }
   void funct ( int num )
   {
   ……………
   ……………
   …………..
   …………..
   }
   2- D Array –
   The syntax of 2-d array is similar to 1-d array, but here we
    have two subscripts.
   Data type array- name [ row size ] [ Colum size ] ;
   Here row sixe specifies number rows and colum size specifies
    number of calumn.
   Reading value in 2-d Array –
   int a [2] [2] 0, c‟, j ;
   for ( c‟ = 0 ; c‟ < 2 ; c‟ ++ )
   {
   for ( j = 0 ; j < 2 ; j ++ )
   {
   scanf ( “ % d‟‟, & a [i] [ j ] ) ;
   }
   }
 Displaying    values of array –
 int a [2] [2] 0, c‟, j ;
 for (c‟ = 0 ; c‟ < 2 ; c‟ ++ )
{
 for ( j = 0 ; j < 2 ; j ++ )
{
 printf ( “ % d‟‟, a [i] [ j ] ) ;
}
}
   Introduction to string –
   In C string are treated as array of char type and are
    terminated by a rull character („0‟)
   There are the two forms of initialization of a string variable –
   char str [10] = {„I‟, „n‟ , „d‟ , „I‟ , „a‟ , „10‟ } ;
   char str [10] = “ India „‟ ;
   In second case rull character automatically placed in the end
    of string.
   Input of output of string –
   # include < stdio‟h >
   void main ( )
   {
   char str [10] ;
   scanf (“ % s ”, str) ;
   printf (“ % s ‟‟, str) ;
   }
 Pointer   –
 Pointer is an identier which hold the address
  of any variable which data type is similar to
  pointer.
 ex-
 int x = 10 ;
 int * p ;
P = & x ;
 In above example p is a pointer which hold
  the address of x variable.
   Example to understand the painte ?
   # include < stdio.h>
   void main ( )
   {
   int a, * b ;
   a = 10 ;
   b=&a;
   printf (“ % d % d % d % d‟‟ , a, &a, b, * b);
   }
   Output –
   value a - 10
   address of a ………
   address of a ………
   value of a - 10
 Pointer  to pointer –
 A pointer may be hold the address of
  another pointer.
 int *a, **b, c‟ ;
 c‟ = 10 ;
 a = & c‟ ;
b = & a ;
 In above case a hold the address of c‟
  variable and double pointer b (**) hold the
  address of a.
 Increment decrement in pointer –
 Pointer variable also perform increment /
  decrement operation ;
 int a, * b ;
a=5;
b=&a;
 b ++ ;
 printf (“ % d ‟‟, b) ;
 In above example pointer increase two by test be
  couse increment perform in the address of
  variable.
 We can also perform arithmatic operation in
  pointer.
   Pointer and function –
   The argument to the function can be passed in two ways –
   1. call by value.
   2. call by reference.
   In call by value, only values of argument send to the function.
   But in call by reference address of argument send to the
    function.
   Structure –
   Array is a collection of same type of elements, but in real word
    application we may need to group different types of logically
    related data.
   So for that we use structure.
   “ structure is a collection of different type of corelated data.
   Syntax –
   struct tag name
   {
   data type member 1;
   data type member 2;
   ………………..
   ……………..
   data type member x ;
   };
   Here struct is a keyword.
   ex- struct student
   {
   char name [20] ;
   int age ;
   }
   void main ( ) {
   Struct student 51 ;
   51. name = “ arpit ‟‟ ;
   51. age ;
   printf ( “ % s % d ‟‟, 51. name, 51. age) ; }
    Union –
   Union is a derived data type like structure, and it can also contain
    members of different data types.
   It‟s declaration and accessing of member element is same to
    structure only one different in it, use keyword union instead of struct.
   Union union-name
   {
   data type member 1 ;
   data type member 2 ;
   …………………
   };
   main ( )
   }
   Union union-name x ;
   ………………..
   ……………….
   }

Más contenido relacionado

La actualidad más candente (20)

C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
 
Cbasic
CbasicCbasic
Cbasic
 
Cpp17 and Beyond
Cpp17 and BeyondCpp17 and Beyond
Cpp17 and Beyond
 
Cpp reference card
Cpp reference cardCpp reference card
Cpp reference card
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and Functions
 
Lecture 18 - Pointers
Lecture 18 - PointersLecture 18 - Pointers
Lecture 18 - Pointers
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
Learning C programming - from lynxbee.com
Learning C programming - from lynxbee.comLearning C programming - from lynxbee.com
Learning C programming - from lynxbee.com
 
Web application architecture
Web application architectureWeb application architecture
Web application architecture
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Effective Modern C++
Effective Modern C++Effective Modern C++
Effective Modern C++
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
What is c
What is cWhat is c
What is c
 

Similar a What is c

C operators
C operatorsC operators
C operatorsGPERI
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptxAnisZahirahAzman
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2yasir_cesc
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cppsharvivek
 
B.sc CSIT 2nd semester C++ Unit2
B.sc CSIT  2nd semester C++ Unit2B.sc CSIT  2nd semester C++ Unit2
B.sc CSIT 2nd semester C++ Unit2Tekendra Nath Yogi
 
Types of c operators ppt
Types of c operators pptTypes of c operators ppt
Types of c operators pptViraj Shah
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdfMaryJacob24
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++Aahwini Esware gowda
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxLikhil181
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013amanabr
 

Similar a What is c (20)

C fundamental
C fundamentalC fundamental
C fundamental
 
C operators
C operatorsC operators
C operators
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
 
B.sc CSIT 2nd semester C++ Unit2
B.sc CSIT  2nd semester C++ Unit2B.sc CSIT  2nd semester C++ Unit2
B.sc CSIT 2nd semester C++ Unit2
 
Types of c operators ppt
Types of c operators pptTypes of c operators ppt
Types of c operators ppt
 
C program
C programC program
C program
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
Unit 1
Unit 1Unit 1
Unit 1
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
C basics
C basicsC basics
C basics
 
C basics
C basicsC basics
C basics
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptxUnit - 2 CAP.pptx
Unit - 2 CAP.pptx
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 

Más de pacatarpit

Más de pacatarpit (9)

Ado.net
Ado.netAdo.net
Ado.net
 
Sql slid
Sql slidSql slid
Sql slid
 
C# slid
C# slidC# slid
C# slid
 
.Net slid
.Net slid.Net slid
.Net slid
 
Paca oops slid
Paca oops slidPaca oops slid
Paca oops slid
 
Perl slid
Perl slidPerl slid
Perl slid
 
Paca java script slid
Paca java script slidPaca java script slid
Paca java script slid
 
Internet
InternetInternet
Internet
 
html tutorial
html tutorialhtml tutorial
html tutorial
 

Último

General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 

Último (20)

General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

What is c

  • 1.  What is c?  Do you tell us about c, perhaps you thing that is a programming language but…… now……….  What is z?  You tell us it is an alphabets. In the same way c is also an alphabets.  Now when some one asking you about c language then tell him about c language.  This type of answer make an impression on interviewer, which is beneficial for us.
  • 2.  History of c language – algol (kenthomsan) B BCPL (Mortin) c (Denice Richi) (At & t bell laboratory in U.S.A.)
  • 3. C language developed in 1972 at & t bell laboratory in U.S.A.  First time c language written in Unix, but in further it written in it self.  Unix O.S. is also written in c language.
  • 4. Basic element of c languages.  Every language have some elements which help us to understand and working with that language.  So there are some element in c also …..  Alphabets -  a, b………?  A, B………z.  Numeric values – 0,1,2………9.  Special symbols –  # , ; : ( ) [ ] { } / * + - %...............  Key words –  There are 32 keywords in c language.
  • 5.
  • 6. Some predefine function in c  print f ( )  scan f ( )  getch ( )  clrscr ( )  getche ( )
  • 7.  printf – it is a predefine function which is use to print something on the screen at runtime.  printf (“Namaste”);  In above example what we write down in double quarts that is printed same an screen. int x; x = 10; printf (“ % d “, x); In ex printf print the value of x.
  • 8.  scanf – it is also a predefine function which is use to take user input at runtime (execution time) int x; scanf (“ % d”, f x)  In above example we take value for x variable integer type.
  • 9.  getch ( ) – It is also predefine function which hold the screen, till it dose not get a character.  As it get the character it release the screen.  getche( ) – getche ( ) is also work same as getch ( ), but difference it first print the taken character then release the screen.
  • 10. Inclucle <stdio.h> vaid maine ( ) { Print f (“vandematram”); Getche ( ); Getch ( ); }  Hear first getche ( ) hold the screen, when he get a character then it release, then getch() hold;
  • 11. # include <stdio.h> void main ( ) { Print f (“vandematram”); getch ( ); getche ( ); } Hear first getch ( ) hold the screen, when he get a character then it release, then getche() hold;
  • 12.  Identifiers – Identifiers are such type of entity through which we uniquely identified any thing.  ex- variable name, painter name, array name, function name, structure name, union name etc.  Rule for identifiers name –  An identifier contain only alphabets, numeric values and under score (-).  An identifiers name always start with alphabets or under score.  No special symbols or white space use instead of under score. (-).
  • 13.  Variable – variable are those identifiers which value change during the program.  ex – int x; char y;  Constant – constant are those identifiers which value never change during in program.
  • 14.  Data type – it tell us about the type of are identifiers.  ex - int a;  In above ex- a is an integer type variable, it hold the integer value the key word int tell s us.
  • 15.  Type of data type – There are manly two type of data type in c.  Primary data type.  Secondary data type. Primary data type secondary data type int string float array char painter double structure union function
  • 16.  int– int is a key word which is used to create a integer type variable.  ex – int x x = 10;  x hold integer type value.
  • 17.  char – It is also a key word which is used to create a character type variable it always hold a single character, which is denoted by „ ‟ (single a uates)  char a; a =„m‟;  In above a is a character type variable which hold a single character.
  • 18.  float – it is also a key word which is used to create a float type variable.  ex-  float b; b = 2.35;  In above, b is a float type variable hold a decimal value.
  • 19. Operators in c-  C support a number of built-in operators. we have already used several of them,  Some are =,+,-,*,&and <.An operator is a symbol that tells the computer to perform some manipulation to manipulate data and variables.  C operators can be classified in to a  i) number of categories.  ii) relational operators.  iii) logical operators.  iv) assignment operators.  v) increment & decrement operators  vi) arithmetic operators  vii) conditional operators  viii) bitwise operators  ix) special operators.
  • 20.  Arithmetic operators-  C provides all the basic arithmetic operators. They are listed in table.  Operators Meaning + Addition or unary plus - Subtraction or unary minus * Multiplication / Division % Modulo division
  • 21. ex-1.  int a, b, c;  b = 10;  c = 12;  ex- 2. a + b + c; float b = 2.5; c = 3.2; a = b + c;  ex-3. int a; float b, c; a = 10; c = 3.5 b = a + b;
  • 22.  Relation operators-  We often compare two quantities and depending on their relation. Take certain decisions. For this type of comparisons we use relation operators.  those are- Operator Meaning < is less than <= is less than or equal to > is greater than <= is greater than or equal to == is equal to
  • 23.  Logical operators-  In addition to the relational operators. C has these following logical operators. Operator Meaning && logical AND || logical OR ! logical NOT  Assignment operators-  Assignment operators are used to assign an opropriate value to the variable.  We use „=‟ as assignment operator.
  • 24.  Increment and decrement operators-  C allows two very use full operators these are increment and decrement operators.  ++ and --  *The operators ++ adds 1 to the operand, while – subtracts 1. * both are unary operators and (such operators which work with single operand (variable).  ex- int a; a + +;
  • 25.  They are implemented in two ways  Prefix.  Pastfis.  Prefix- first perform in crement decrement then assigne the value.  int a;  ++ a;  int b;  -- b;  Postfix – first assigne the the value then perferm increment decrement.
  • 26.  Conditional operator-  There is an operator pair “?” is available in C, to construct conditional expressions of the form.  A1 ? A2 : A3  A1, A2, A3 are expressions .  in above first expressions A, evaluated.  a = 10;  b = 15;  m = (a > b) ? a : b;  It is use to replace if use.
  • 27.  Bit wise operators-
  • 28. If ……. else  This is a bi-direction conditional control statement. This statement is used to test a condition and take one of the two possible actions.  If the condition is true then a single statement or block is executed, other wish another single statement or block is executed.  if (condition)  {  Statement 1  }  Else  {  Statement 2  }
  • 29. Nesting of if ……. else-  We can have another if….. else statement in the if block or the else block if….. else statement.
  • 30. Switch –  This is a multi-directional conditional control statement some time there is a need in program to make choice among number of alter natives.  For making this choice, we use the switch statement.  switch (expression)  {  case 1:  statement 1;  Break; ………..  case 2:  statement 2;  … Break; ………  case 3:  statement 3;  …… Break; ……  default :  statement 4;  ………..  }
  • 31. Now we will see the same valid invalid ways of writing switch expression and case expression.  int a, b, c; char d, e; float f;  Valid –  Switch (a) switch (a>b) switch (d+e-3) switch (a>b && b>c) switch cfine (a,b,)  Invalid –  switch (f) switch (a+4.5)  Valid case 4: case „a‟ : case 2+4  case „a‟ > „b‟ :  Invalid –  case ”second” : case 2.3 : case a :  case a>b : case a+2 :  case 2, 3, 4 : case 2 : 4 : 3 :
  • 32. Loop - loops are used when we want to execute a part of program or a block of statement several times.  There are three loop statement in C-  for loop  while loop  do while loop  for – the for loop is very usefull in C programming.  It has three expressions and semicolons are used for separating these expression.  for (initialization; condition; increment)  {  statement;  }  ex-  int a;  for (a=0; a<3; a++)  {  printf (“Namuste”);  }
  • 33. While –  It is written as –  initialization;  while (condition)  {  statement :  Increment /Decrement;  }  ex- int a;  a=0;  while (a<3)  {  printf (“ Vande Matram”);  a ++;  }
  • 34. do while – it is different from for and while loop. it first execute the statement then check the condition.  initialization :  do  {  statement :  increment /Decrenet)  }  while 9condition);  ex-  int a;  a = 0;  do  {  printf (“ jai Hanuman”);  a ++;  }  while (a < 5);  * in do while condition is either true or false statement must executed once.
  • 35.  Nested loop-  When we use a loop inside the another loop body (both are same) it is known as nested loop.  ex-  for (x = 0 ; x < 5 ; x + +) {  for (y = 1 ; y < 5 : y + +) {  printf (“% d % d ‟‟ x, y) ; } }  In above this the example of nested for loop.
  • 36.  Function – function is an entity which perform some specific.  A function is a self-contained subprogram that is meant to do some specific, well-define task.  *A program consists of one or more function.  *If a program has only one function then it must be the main ( ) function .  *function always return a value.  C program have two types of function –  1. Library function  2. User define function
  • 37. Library function –  C has the facility to provide library functions for performing some operations. These function are present in the C library and they are predefined. Function Name Operation Sgrt ( ) find squre root of nuber scanf ( ) take input printf ( ) for print on screen strlen ( ) lenth of string strcmp ( ) comparision clrscr ( ) for clear the screen getch ( ) for hold the screen
  • 38. User- define function-  User can create their own functions for performing any specific task of the program. These type of function are called user define function.  User define function have these three parts-  1. Function declaration  2. Function definition  3. Function calling  Function definition-  The function definition consist of the whole description and code of a function. It tells what the function is doing and what are its input and output.  Function calling-  A function is called by simply writing its name followed by the argument list inside the parentheses (if any).
  • 39. Function declaration-  Function declaration give the information to calling function about called function.  If called function is placed before calling function then there no need for declaration.  ex- #includi <stdioh>  valid ram ( ) ; declaration  valid main ( ) ; of function  {  ram ( ) ; calling offention  }  Void ram ( )  {  printf (“ vande matram ‟‟) ;  }
  • 40. Type of user define function –  1. function with no argument and no return type.  2. function with no argument and a return type.  3. function with argument and no return type.  4. function with argument and a return type.  Function with no argument and no return type-  A function which has no argument and no return type………..  #include<stdio.h>  void func ( ) ;  void main ( )  {  func ( ) ;  }  void func ( )  {  statement ;  }  In above program func ( ) has no argument and it does not return any value.
  • 41. Function with no argument and a return type –  These type of function do not recene any argument but return a value.  int func ( ) ;  void main ( )  {  int n ;  n = func ( ) ;  }  int func ( )  {  int a ;  ………  ………  return a ;  }
  • 42. function with argument and no return type.-These types of function have arguments, hence calling function send data to the calling function but function does not return a value.  void func (int a) ;  void main ( )  {  int m ;  func (m);  }  void func (int x)  {  ……………….  ……………….  ……………….  }
  • 43. Function with argument and a return type-  These type function have arguments, so the calling function can send data to the called function. It can also return any value to the calling function using return statement.  int func (int, int)  {  void main ( )  {  int r ;  …….  r = func (a, b) ;  ……….  }  int func (int a, int b)  {  ………….  ………….  return (expression) ;  }
  • 44. Arrays –  The variables that we have used till now are capable of storing only one value at a time.  So we have an array that can hold more than one value of some type.  “ Array is a collection of similar type of data.‟‟  ex -  int a [10] ;  a [10] = {1, 2, 5, 3, 2…...} ;  In above example a is an array of size 10, it can hold 10 values of same time of data type.  ex-2- int a [3] 0, c‟ ;  for (c‟ = 0 ; c‟ < 3 ; c‟ ++)  {  scanf (“ % d‟‟, & a [c‟] ) ;  }
  • 45.  ex-1- int a [3] ;  a [0] = 10 ;  a [1] = 22 ;  a [2] = 11 ;  /* The size of array is 3, it hold three value */  Print the value of an array –  int a [3] 0, c‟ ;  for ( I = 0 ; c‟ < 3 ; c‟ ++ ) {  printf ( “ % d”, a [i] ) ;
  • 46. Passing array to a function –  We know that an array element is treated as any other simple variable in the program. So we can simply pass an individual array element to the function as argument.  void funct ( int a ) ;  void main ( )  {  int arr [10], i ;  for ( i = 0 ; c‟ < 10 ; c‟ ++ )  {  scanf ( “ % d‟‟, & arr [i] ) ;  funct ( arr [i] ) ;  }  void funct ( int num )  {  ……………  ……………  …………..  …………..  }
  • 47. 2- D Array –  The syntax of 2-d array is similar to 1-d array, but here we have two subscripts.  Data type array- name [ row size ] [ Colum size ] ;  Here row sixe specifies number rows and colum size specifies number of calumn.  Reading value in 2-d Array –  int a [2] [2] 0, c‟, j ;  for ( c‟ = 0 ; c‟ < 2 ; c‟ ++ )  {  for ( j = 0 ; j < 2 ; j ++ )  {  scanf ( “ % d‟‟, & a [i] [ j ] ) ;  }  }
  • 48.  Displaying values of array –  int a [2] [2] 0, c‟, j ;  for (c‟ = 0 ; c‟ < 2 ; c‟ ++ ) {  for ( j = 0 ; j < 2 ; j ++ ) {  printf ( “ % d‟‟, a [i] [ j ] ) ; } }
  • 49. Introduction to string –  In C string are treated as array of char type and are terminated by a rull character („0‟)  There are the two forms of initialization of a string variable –  char str [10] = {„I‟, „n‟ , „d‟ , „I‟ , „a‟ , „10‟ } ;  char str [10] = “ India „‟ ;  In second case rull character automatically placed in the end of string.  Input of output of string –  # include < stdio‟h >  void main ( )  {  char str [10] ;  scanf (“ % s ”, str) ;  printf (“ % s ‟‟, str) ;  }
  • 50.  Pointer –  Pointer is an identier which hold the address of any variable which data type is similar to pointer.  ex-  int x = 10 ;  int * p ; P = & x ;  In above example p is a pointer which hold the address of x variable.
  • 51. Example to understand the painte ?  # include < stdio.h>  void main ( )  {  int a, * b ;  a = 10 ;  b=&a;  printf (“ % d % d % d % d‟‟ , a, &a, b, * b);  }  Output –  value a - 10  address of a ………  address of a ………  value of a - 10
  • 52.  Pointer to pointer –  A pointer may be hold the address of another pointer.  int *a, **b, c‟ ;  c‟ = 10 ;  a = & c‟ ; b = & a ;  In above case a hold the address of c‟ variable and double pointer b (**) hold the address of a.
  • 53.  Increment decrement in pointer –  Pointer variable also perform increment / decrement operation ;  int a, * b ; a=5; b=&a;  b ++ ;  printf (“ % d ‟‟, b) ;  In above example pointer increase two by test be couse increment perform in the address of variable.  We can also perform arithmatic operation in pointer.
  • 54. Pointer and function –  The argument to the function can be passed in two ways –  1. call by value.  2. call by reference.  In call by value, only values of argument send to the function.  But in call by reference address of argument send to the function.  Structure –  Array is a collection of same type of elements, but in real word application we may need to group different types of logically related data.  So for that we use structure.  “ structure is a collection of different type of corelated data.
  • 55. Syntax –  struct tag name  {  data type member 1;  data type member 2;  ………………..  ……………..  data type member x ;  };  Here struct is a keyword.  ex- struct student  {  char name [20] ;  int age ;  }  void main ( ) {  Struct student 51 ;  51. name = “ arpit ‟‟ ;  51. age ;  printf ( “ % s % d ‟‟, 51. name, 51. age) ; }
  • 56. Union –  Union is a derived data type like structure, and it can also contain members of different data types.  It‟s declaration and accessing of member element is same to structure only one different in it, use keyword union instead of struct.  Union union-name  {  data type member 1 ;  data type member 2 ;  …………………  };  main ( )  }  Union union-name x ;  ………………..  ……………….  }