SlideShare a Scribd company logo
Introduction to C
     Workshop India
     Wilson Wingston Sharon
     wingston.sharon@gmail.com
Writing the first program
#include<stdio.h>
int main()
{
   printf(“Hello”);
   return 0;
}

   This program prints Hello on the screen when we
    execute it
Header files
   The files that are specified in the include section is
    called as header file
   These are precompiled files that has some functions
    defined in them
   We can call those functions in our program by
    supplying parameters
   Header file is given an extension .h
   C Source file is given an extension .c
Main function

   This is the entry point of a program
   When a file is executed, the start point is the main
    function
   From main function the flow goes as per the
    programmers choice.
   There may or may not be other functions written by
    user in a program
   Main function is compulsory for any c program
Comments in C
   Single line comment
     // (double slash)
     Termination of comment is by pressing enter key

   Multi line comment
    /*….
    …….*/
    This can span over to multiple lines
Data types in C
   Primitive data types
     int,   float, double, char
   Aggregate data types
     Arrays come under this category
     Arrays can contain collection of int or float or char or
      double data
   User defined data types
     Structures   and enum fall under this category.
Variables
   Variables are data that will keep on changing
   Declaration
    <<Data type>> <<variable name>>;
    int a;
   Definition
    <<varname>>=<<value>>;
    a=10;
   Usage
    <<varname>>
    a=a+1;   //increments the value of a by 1
Operators

   Arithmetic (+,-,*,/,%)
   Relational (<,>,<=,>=,==,!=)
   Logical (&&,||,!)
   Bitwise (&,|)
   Assignment (=)
   Compound assignment(+=,*=,-=,/=,%=,&=,|=)
   Shift (right shift >>, left shift <<)
Variable names- Rules
   Should not be a reserved word like int etc..
   Should start with a letter or an underscore(_)
   Can contain letters, numbers or underscore.
   No other special characters are allowed including
    space
   Variable names are case sensitive
    A   and a are different.
Input and Output
   Input
     scanf(“%d”,&a);

     Gets an integer value from the user and stores it under
      the name “a”
   Output
     printf(“%d”,a)

     Prints   the value present in variable a on the screen
Task01- I/O
Write a program to accept 3 numbers a , b and c as
coefficients of the quadratic equation
              ax2 + bx + c = 0
And output the solution.

Hint:
6.There will be two answers for every input combination.

7.Look in a math textbook for the solution formula.
For loops
   The syntax of for loop is
    for(initialisation;condition checking;increment)
    {
      set of statements
    }
    Eg: Program to print Hello 10 times
    for(I=0;I<10;I++)
    {
      printf(“Hello”);
    }
While loop
     The syntax for while loop
      while(condn)
      {
            statements;
      }
Eg:
      a=10;
      while(a != 0)               Output: 10987654321
      {
            printf(“%d”,a);
            a--;
      }
Do While loop
   The syntax of do while loop
    do
    {
       set of statements
    }while(condn);

    Eg:
    i=10;                         Output:
    do                            10987654321
    {
       printf(“%d”,i);
       i--;
    }while(i!=0)
Task02 - loops
   Write a program to identify which day ( sat – fri) a
    particular given date (e.g. : 3/3/2015) falls upon.

   Hint:
    http://en.wikipedia.org/wiki/Zeller%27s_congruence

   Read through the algorithm and implement it.
   You can make your own algorithm and get bonus
    marks.
Conditional statements
if (condition)
{
   stmt 1;       //Executes if Condition is true
}
else
{
   stmt 2;       //Executes if condition is false
}
Conditional statement

switch(var)
{
case 1: //if var=1 this case executes
                stmt;
                break;
case 2: //if var=2 this case executes
                stmt;
                break;
default:        //if var is something else this will execute
                stmt;
}
Functions and Parameters
 Syntax of function
Declaration section
<<Returntype>> funname(parameter list);
Definition section
<<Returntype>> funname(parameter list)
{
  body of the function
}
Function Call
Funname(parameter);
Example function
#include<stdio.h>
void fun(int a);     //declaration
int main()
{
   fun(10);                 //Call
}
void fun(int x)      //definition
{
   printf(“%d”,x);
}
Task03 - Primality
   Write a function to check if a given number is prime
    or not.

   http://en.wikipedia.org/wiki/Prime_number

   Try and implement at least 2 algorithms and check
    which one returns faster.
   Use this for time stamping :
    http://www.chemie.fu-berlin.de/chemnet/use/info/libc/
Arrays
   Arrays fall under aggregate data type
   Aggregate – More than 1
   Arrays are collection of data that belong to same
    data type
   Arrays are collection of homogeneous data
   Array elements can be accessed by its position in
    the array called as index
Arrays
   Array index starts with zero
   The last index in an array is num – 1 where num is the
    no of elements in a array
   int a[5] is an array that stores 5 integers
   a[0] is the first element where as a[4] is the fifth
    element
   We can also have arrays with more than one
    dimension
   float a[5][5] is a two dimensional array. It can store
    5x5 = 25 floating point numbers
   The bounds are a[0][0] to a[4][4]
Task04 - Arrays
Produce a spiral array. A spiral array is a square arrangement
of the first N2 natural numbers, where the numbers increase
sequentially as you go around the edges of the array spiralling
inwards.
For example, given 5, produce this array:

 0 1 2 3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10 9 8
Ad

More Related Content

What's hot (20)

constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
sneha2494
 
C fundamental
C fundamentalC fundamental
C fundamental
Selvam Edwin
 
String functions in C
String functions in CString functions in C
String functions in C
baabtra.com - No. 1 supplier of quality freshers
 
Features of c language 1
Features of c language 1Features of c language 1
Features of c language 1
srmohan06
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
Harshita Yadav
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
Dipta Saha
 
Manipulators in c++
Manipulators in c++Manipulators in c++
Manipulators in c++
Ashok Raj
 
Datatypes in c
Datatypes in cDatatypes in c
Datatypes in c
CGC Technical campus,Mohali
 
C language ppt
C language pptC language ppt
C language ppt
Ğäùråv Júñêjå
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
Nitesh Kumar Pandey
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
Mansi Tyagi
 
Structure in C
Structure in CStructure in C
Structure in C
Kamal Acharya
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
David Livingston J
 
Call by value
Call by valueCall by value
Call by value
Dharani G
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 

Viewers also liked (20)

3 intro basic_elements
3 intro basic_elements3 intro basic_elements
3 intro basic_elements
Docent Education
 
Semiconductors summary
Semiconductors summarySemiconductors summary
Semiconductors summary
radebethapi
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
shaheed benazeer bhutto university (shaheed benazeerabad)
 
Physics 2 (Modern Physics)
Physics 2 (Modern Physics)Physics 2 (Modern Physics)
Physics 2 (Modern Physics)
Czarina Nedamo
 
What is c
What is cWhat is c
What is c
Nitesh Saitwal
 
Basic Elements of Java
Basic Elements of JavaBasic Elements of Java
Basic Elements of Java
Prof. Erwin Globio
 
61739515 functional-english-grammar
61739515 functional-english-grammar61739515 functional-english-grammar
61739515 functional-english-grammar
Hina Honey
 
Computer Applications - The Basic Computer Networking
Computer Applications - The Basic Computer NetworkingComputer Applications - The Basic Computer Networking
Computer Applications - The Basic Computer Networking
Faindra Jabbar
 
Changing structure of family
Changing structure of familyChanging structure of family
Changing structure of family
Polytechnic University of the Philippines
 
How to improve english writing skill
How to improve english writing skillHow to improve english writing skill
How to improve english writing skill
Nusrat Jahan
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
Bharat Kalia
 
Modern Physics
Modern PhysicsModern Physics
Modern Physics
Keith Carson
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
Semiconductors
SemiconductorsSemiconductors
Semiconductors
Self-employed
 
PART II.3 - Modern Physics
PART II.3 - Modern PhysicsPART II.3 - Modern Physics
PART II.3 - Modern Physics
Maurice R. TREMBLAY
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
harman kaur
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
Rumman Ansari
 
How to Develop Writing Skill
How to Develop Writing SkillHow to Develop Writing Skill
How to Develop Writing Skill
Rajeev Ranjan
 
Electricity
ElectricityElectricity
Electricity
Karl Coelho
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Ad

Similar to Introduction to Basic C programming 01 (20)

C intro
C introC intro
C intro
Kamran
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
Dr. SURBHI SAROHA
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
CHAPTER 5
CHAPTER 5CHAPTER 5
CHAPTER 5
mohd_mizan
 
Each n Every topic of C Programming.pptx
Each n Every topic of C Programming.pptxEach n Every topic of C Programming.pptx
Each n Every topic of C Programming.pptx
snnbarot
 
2. operator
2. operator2. operator
2. operator
Shankar Gangaju
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
Vikram Nandini
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
UMA PARAMESWARI
 
1584503386 1st chap
1584503386 1st chap1584503386 1st chap
1584503386 1st chap
thuhiendtk4
 
Functions.pptx, programming language in c
Functions.pptx, programming language in cFunctions.pptx, programming language in c
Functions.pptx, programming language in c
floraaluoch3
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.Sivakumar
Sivakumar R D .
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
Don Dooley
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
Introduction to C Programming -Lecture 3
Introduction to C Programming -Lecture 3Introduction to C Programming -Lecture 3
Introduction to C Programming -Lecture 3
Faculty of Computers and Informatics, Suez Canal University, Ismailia, Egypt
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
AnkitaVerma776806
 
Lecture 9- Control Structures 1
Lecture 9- Control Structures 1Lecture 9- Control Structures 1
Lecture 9- Control Structures 1
Md. Imran Hossain Showrov
 
C and C++ programming basics for Beginners.pptx
C and C++ programming basics for Beginners.pptxC and C++ programming basics for Beginners.pptx
C and C++ programming basics for Beginners.pptx
renuvprajapati
 
Unit 1
Unit 1Unit 1
Unit 1
Sowri Rajan
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
MKalpanaDevi
 
Storage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageStorage classes arrays & functions in C Language
Storage classes arrays & functions in C Language
Jenish Bhavsar
 
C intro
C introC intro
C intro
Kamran
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
Each n Every topic of C Programming.pptx
Each n Every topic of C Programming.pptxEach n Every topic of C Programming.pptx
Each n Every topic of C Programming.pptx
snnbarot
 
1584503386 1st chap
1584503386 1st chap1584503386 1st chap
1584503386 1st chap
thuhiendtk4
 
Functions.pptx, programming language in c
Functions.pptx, programming language in cFunctions.pptx, programming language in c
Functions.pptx, programming language in c
floraaluoch3
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.Sivakumar
Sivakumar R D .
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
Don Dooley
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
AnkitaVerma776806
 
C and C++ programming basics for Beginners.pptx
C and C++ programming basics for Beginners.pptxC and C++ programming basics for Beginners.pptx
C and C++ programming basics for Beginners.pptx
renuvprajapati
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
MKalpanaDevi
 
Storage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageStorage classes arrays & functions in C Language
Storage classes arrays & functions in C Language
Jenish Bhavsar
 
Ad

More from Wingston (20)

OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012
Wingston
 
05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - Android
Wingston
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
Wingston
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - Android
Wingston
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - Android
Wingston
 
01 introduction & setup - Android
01   introduction & setup - Android01   introduction & setup - Android
01 introduction & setup - Android
Wingston
 
OpenCV with android
OpenCV with androidOpenCV with android
OpenCV with android
Wingston
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
Wingston
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
Wingston
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introduction
Wingston
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linux
Wingston
 
04 Arduino Peripheral Interfacing
04   Arduino Peripheral Interfacing04   Arduino Peripheral Interfacing
04 Arduino Peripheral Interfacing
Wingston
 
03 analogue anrduino fundamentals
03   analogue anrduino fundamentals03   analogue anrduino fundamentals
03 analogue anrduino fundamentals
Wingston
 
02 General Purpose Input - Output on the Arduino
02   General Purpose Input -  Output on the Arduino02   General Purpose Input -  Output on the Arduino
02 General Purpose Input - Output on the Arduino
Wingston
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
4.content mgmt
4.content mgmt4.content mgmt
4.content mgmt
Wingston
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for Drupal
Wingston
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
Wingston
 
6 Special Howtos for Drupal
6 Special Howtos for Drupal6 Special Howtos for Drupal
6 Special Howtos for Drupal
Wingston
 
5 User Mgmt in Drupal
5 User Mgmt in Drupal5 User Mgmt in Drupal
5 User Mgmt in Drupal
Wingston
 
OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012
Wingston
 
05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - Android
Wingston
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
Wingston
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - Android
Wingston
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - Android
Wingston
 
01 introduction & setup - Android
01   introduction & setup - Android01   introduction & setup - Android
01 introduction & setup - Android
Wingston
 
OpenCV with android
OpenCV with androidOpenCV with android
OpenCV with android
Wingston
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
Wingston
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
Wingston
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introduction
Wingston
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linux
Wingston
 
04 Arduino Peripheral Interfacing
04   Arduino Peripheral Interfacing04   Arduino Peripheral Interfacing
04 Arduino Peripheral Interfacing
Wingston
 
03 analogue anrduino fundamentals
03   analogue anrduino fundamentals03   analogue anrduino fundamentals
03 analogue anrduino fundamentals
Wingston
 
02 General Purpose Input - Output on the Arduino
02   General Purpose Input -  Output on the Arduino02   General Purpose Input -  Output on the Arduino
02 General Purpose Input - Output on the Arduino
Wingston
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
4.content mgmt
4.content mgmt4.content mgmt
4.content mgmt
Wingston
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for Drupal
Wingston
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
Wingston
 
6 Special Howtos for Drupal
6 Special Howtos for Drupal6 Special Howtos for Drupal
6 Special Howtos for Drupal
Wingston
 
5 User Mgmt in Drupal
5 User Mgmt in Drupal5 User Mgmt in Drupal
5 User Mgmt in Drupal
Wingston
 

Recently uploaded (20)

Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 

Introduction to Basic C programming 01

  • 1. Introduction to C Workshop India Wilson Wingston Sharon [email protected]
  • 2. Writing the first program #include<stdio.h> int main() { printf(“Hello”); return 0; }  This program prints Hello on the screen when we execute it
  • 3. Header files  The files that are specified in the include section is called as header file  These are precompiled files that has some functions defined in them  We can call those functions in our program by supplying parameters  Header file is given an extension .h  C Source file is given an extension .c
  • 4. Main function  This is the entry point of a program  When a file is executed, the start point is the main function  From main function the flow goes as per the programmers choice.  There may or may not be other functions written by user in a program  Main function is compulsory for any c program
  • 5. Comments in C  Single line comment  // (double slash)  Termination of comment is by pressing enter key  Multi line comment /*…. …….*/ This can span over to multiple lines
  • 6. Data types in C  Primitive data types  int, float, double, char  Aggregate data types  Arrays come under this category  Arrays can contain collection of int or float or char or double data  User defined data types  Structures and enum fall under this category.
  • 7. Variables  Variables are data that will keep on changing  Declaration <<Data type>> <<variable name>>; int a;  Definition <<varname>>=<<value>>; a=10;  Usage <<varname>> a=a+1; //increments the value of a by 1
  • 8. Operators  Arithmetic (+,-,*,/,%)  Relational (<,>,<=,>=,==,!=)  Logical (&&,||,!)  Bitwise (&,|)  Assignment (=)  Compound assignment(+=,*=,-=,/=,%=,&=,|=)  Shift (right shift >>, left shift <<)
  • 9. Variable names- Rules  Should not be a reserved word like int etc..  Should start with a letter or an underscore(_)  Can contain letters, numbers or underscore.  No other special characters are allowed including space  Variable names are case sensitive A and a are different.
  • 10. Input and Output  Input  scanf(“%d”,&a);  Gets an integer value from the user and stores it under the name “a”  Output  printf(“%d”,a)  Prints the value present in variable a on the screen
  • 11. Task01- I/O Write a program to accept 3 numbers a , b and c as coefficients of the quadratic equation ax2 + bx + c = 0 And output the solution. Hint: 6.There will be two answers for every input combination. 7.Look in a math textbook for the solution formula.
  • 12. For loops  The syntax of for loop is for(initialisation;condition checking;increment) { set of statements } Eg: Program to print Hello 10 times for(I=0;I<10;I++) { printf(“Hello”); }
  • 13. While loop  The syntax for while loop while(condn) { statements; } Eg: a=10; while(a != 0) Output: 10987654321 { printf(“%d”,a); a--; }
  • 14. Do While loop  The syntax of do while loop do { set of statements }while(condn); Eg: i=10; Output: do 10987654321 { printf(“%d”,i); i--; }while(i!=0)
  • 15. Task02 - loops  Write a program to identify which day ( sat – fri) a particular given date (e.g. : 3/3/2015) falls upon.  Hint: http://en.wikipedia.org/wiki/Zeller%27s_congruence  Read through the algorithm and implement it.  You can make your own algorithm and get bonus marks.
  • 16. Conditional statements if (condition) { stmt 1; //Executes if Condition is true } else { stmt 2; //Executes if condition is false }
  • 17. Conditional statement switch(var) { case 1: //if var=1 this case executes stmt; break; case 2: //if var=2 this case executes stmt; break; default: //if var is something else this will execute stmt; }
  • 18. Functions and Parameters  Syntax of function Declaration section <<Returntype>> funname(parameter list); Definition section <<Returntype>> funname(parameter list) { body of the function } Function Call Funname(parameter);
  • 19. Example function #include<stdio.h> void fun(int a); //declaration int main() { fun(10); //Call } void fun(int x) //definition { printf(“%d”,x); }
  • 20. Task03 - Primality  Write a function to check if a given number is prime or not.  http://en.wikipedia.org/wiki/Prime_number  Try and implement at least 2 algorithms and check which one returns faster.  Use this for time stamping : http://www.chemie.fu-berlin.de/chemnet/use/info/libc/
  • 21. Arrays  Arrays fall under aggregate data type  Aggregate – More than 1  Arrays are collection of data that belong to same data type  Arrays are collection of homogeneous data  Array elements can be accessed by its position in the array called as index
  • 22. Arrays  Array index starts with zero  The last index in an array is num – 1 where num is the no of elements in a array  int a[5] is an array that stores 5 integers  a[0] is the first element where as a[4] is the fifth element  We can also have arrays with more than one dimension  float a[5][5] is a two dimensional array. It can store 5x5 = 25 floating point numbers  The bounds are a[0][0] to a[4][4]
  • 23. Task04 - Arrays Produce a spiral array. A spiral array is a square arrangement of the first N2 natural numbers, where the numbers increase sequentially as you go around the edges of the array spiralling inwards. For example, given 5, produce this array: 0 1 2 3 4 15 16 17 18 5 14 23 24 19 6 13 22 21 20 7 12 11 10 9 8

Editor's Notes

  • #8: We can also declare and define a variable in single shot like this. int a=10;
  • #11: Format specifiers %d is the format specifier. This informs to the compiler that the incoming value is an integer value. Other data types can be specified as follows: %c – character %f – float %lf – double %s – character array (string) Printf and scanf are defined under the header file stdio.h
  • #15: While – Entry controlled loop Do While – Exit controlled loop