SlideShare a Scribd company logo
Computer programming
INTRODUCTION TO C PROGRAMMING
C language :
 Is system programming language.
 Is procedure-oriented programming language.
 Is also called mid level programming language.
 was developed in 1972 by Dennis Ritchie at bell laboratories of
 AT&T(American Telephone & Telegraph), located in U.S.A.
 was developed to be used in UNIX Operating system.
FEATURES
• Simple
• Machine Independent or Portable
• Mid-level programming language
• structured programming language
• Rich Library
• Memory Management
• Fast Speed
• Pointers
• Recursion
• Extensible
Structure of a C program
FIRST PROGRAM OF LANGUAGE
PROGRAM :
#include <stdio.h>
#include <conio.h>
void main()
{
printf("Hello World");
getch();
}
OUTPUT :
Hello World
DESCRIBING THE PROGRAM
#include <stdio.h>
includes the standard input output library functions. The printf() function is defined in
stdio.h
#include <conio.h>
includes the console input output library functions. The getch() function is defined in
conio.h file
void main()
The main() function is the entry point of every program in C language. The void keyword
specifies that it returns no value
printf()
The printf() function is used to print data on the console.
getch()
The getch() function asks for a single character. Until you press any key, it blocks the
screen
INPUT OUTPUT FUNCTION
 Used to send data to the standard output (usually the monitor) to be printed according
to specific format
There are two input output function of c language.
Printf():
 printf() is used for output.
 It prints the given statement to the console.
 Syntax of printf() is given below:
 printf(“control string”,variables);
 Sample Format strings : %d(integer), %c(character), %s(string), %f(float) etc.
 Control string is a combination of text, format specifier
and escape sequence.
scanf()
 Reads data from the standard input device (usually keyboard)and store it in a variable. The
General format is:
– scanf(“Control string”, &variable);
 The general format is pretty much the same as printf() except that it passes the address
of the variable (notice the & sign) instead of the variable itself to the second function
argument.
Example:
int age;
printf(“Enter your age: “);
scanf(“%d”, &age);
getchar() and putchar()
getchar() - reads a character from standard input
putchar() - writes a character to standard output
• Example:
#include <stdio.h>
void main(void)
{
char my_char;
printf(“Please type a character: “);
my_char = getchar();
printf(“nYou have typed this character: “);
putchar(my_char);
}
Preprocessor Directives
The first statement to be checked by the compiler
• Preprocessor Directives always preceded with ‘#’ sign
• They contain information to the compiler which are required by the compiler during
compilation.
• There are a few compiler directives. But only 2 of them will be
discussed here.
#include <stdio.h>
• Tells the compiler to include the file stdio.h during compilation
• Anything in the header file will be included a part of the program
#define VALUE 10
• Tells the compiler to substitute the word VALUE with 10 during compilation
Comments
 Comment means explanations or annotations that are included in a
program for documentation and clarification purpose.
• Comments are completely ignored by the compiler during compilation
and have no effect on program execution.
• Comments starts with ‘/*’ and ends with ‘*/’
• Some compiler support comments starting with ‘//’
Variable
 A variable can be declared globally or locally.
 A globally declared variable can be accessed from any part of the
program.
 A locally declared variable can only be accessed from inside the function
in which the variable is declared.
Statements
 A specification of an action to be taken by the computer as the program executes is
called a Statement.
 In the previous example, there are 2 lines following
 variable declaration that terminate with semicolon ‘;’ are statements:
global_var = local_var + VALUE;
 printf (“Total sum is: %dn”, global_var);
 Each line is a statement that end with a semicolon is a statement.
Basic Functions
 A C program consists of one or more functions that contain a group of statements
which perform a specific task.
 A C program must at least have one function: the function main.
 We can create our own function or use the functions that has been declared in C
library (called Predefined function).
 In order to use Predefined functions, we have to include the appropriate header file
(example: stdio.h).
[continue…]
 In this section, we will learn a few functions that are pre-defined in the header file
stdio.h
• These functions are:
– printf()
– scanf()
– getchar() & putchar()
• In addition to those functions, we will also learn about Format Specifier and Escape
Sequence which are used with printf() and scanf().
DATA TYPES & KEYWORDS
4 types of data types
A keyword is a reserved word. You cannot use it as a variable name, constant name etc.
Operators
 Arithmetic Operators
 Relational Operators
 Shift Operators
 Logical Operators
 Bitwise Operators
 Ternary or Conditional Operators
 Assignment Operator
CONTROL STATEMENTS
• if-else
 If statement
 If-else statement
 If else-if ladder
 Nested if
 switch
 loops
 do-while loop
 while loop
 for loop
 break
 continue
IF-ELSE IN C

More Related Content

What's hot (20)

PPTX
C programming language tutorial
javaTpoint s
 
PDF
C Programming Tutorial - www.infomtec.com
M-TEC Computer Education
 
PDF
C Prog. - Decision & Loop Controls
vinay arora
 
PPTX
Programming Fundamentals lecture 5
REHAN IJAZ
 
PPTX
Structure of C program
Pavan prasad
 
PPT
Introduction to c language by nitesh
niteshcongreja321
 
PPTX
C programming language
Abin Rimal
 
PPT
C the basic concepts
Abhinav Vatsa
 
PPTX
Overview of c language
shalini392
 
PPTX
C Programming Unit-2
Vikram Nandini
 
PPTX
Preprocessor directives in c language
tanmaymodi4
 
PPTX
Preprocessor
Võ Hòa
 
PDF
File Handling in C Programming
RavindraSalunke3
 
DOCX
Programming in c
Ashutosh Srivasatava
 
PPT
Lecture01
Xafran
 
PDF
Reduce course notes class xii
Syed Zaid Irshad
 
PPTX
Storage class in C Language
Nitesh Kumar Pandey
 
PPTX
Cpu
Mohit Jain
 
C programming language tutorial
javaTpoint s
 
C Programming Tutorial - www.infomtec.com
M-TEC Computer Education
 
C Prog. - Decision & Loop Controls
vinay arora
 
Programming Fundamentals lecture 5
REHAN IJAZ
 
Structure of C program
Pavan prasad
 
Introduction to c language by nitesh
niteshcongreja321
 
C programming language
Abin Rimal
 
C the basic concepts
Abhinav Vatsa
 
Overview of c language
shalini392
 
C Programming Unit-2
Vikram Nandini
 
Preprocessor directives in c language
tanmaymodi4
 
Preprocessor
Võ Hòa
 
File Handling in C Programming
RavindraSalunke3
 
Programming in c
Ashutosh Srivasatava
 
Lecture01
Xafran
 
Reduce course notes class xii
Syed Zaid Irshad
 
Storage class in C Language
Nitesh Kumar Pandey
 

Similar to Basics of c Nisarg Patel (20)

PPT
Structure of a C program
David Livingston J
 
PPTX
C basics
thirumalaikumar3
 
PDF
Module 1_Chapter 2_PPT (1)sasaddsdsds.pdf
anilcsbs
 
PPTX
Introduction to C Unit 1
Dr. SURBHI SAROHA
 
PPTX
C introduction by thooyavan
Thooyavan Venkatachalam
 
PPTX
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
PPT
(Lect. 2 & 3) Introduction to C.ppt
atulchaudhary821
 
PPT
Lecture#5 c lang new
Zeeshan Ahmad
 
PPT
Chap 1 and 2
Selva Arrunaa Mathavan
 
PPTX
Unit No 2.pptx Basic s of C Programming
Vaibhav Parjane
 
PPTX
C for Engineers
Julie Iskander
 
DOCX
UNIT-II CP DOC.docx
JavvajiVenkat
 
PPT
lec 1 for ITC Introduction to computing and AI
FatimaAijaz6
 
PPTX
1_Introduction of programming language C.pptx
b221382
 
PDF
Introduction of c language
farishah
 
PPT
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
PPTX
C programming
Rohan Gajre
 
PDF
C for Java programmers (part 1)
Dmitry Zinoviev
 
DOC
1. introduction to computer
Shankar Gangaju
 
PPTX
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
MUHUMUZAONAN1
 
Structure of a C program
David Livingston J
 
Module 1_Chapter 2_PPT (1)sasaddsdsds.pdf
anilcsbs
 
Introduction to C Unit 1
Dr. SURBHI SAROHA
 
C introduction by thooyavan
Thooyavan Venkatachalam
 
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
(Lect. 2 & 3) Introduction to C.ppt
atulchaudhary821
 
Lecture#5 c lang new
Zeeshan Ahmad
 
Unit No 2.pptx Basic s of C Programming
Vaibhav Parjane
 
C for Engineers
Julie Iskander
 
UNIT-II CP DOC.docx
JavvajiVenkat
 
lec 1 for ITC Introduction to computing and AI
FatimaAijaz6
 
1_Introduction of programming language C.pptx
b221382
 
Introduction of c language
farishah
 
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
C programming
Rohan Gajre
 
C for Java programmers (part 1)
Dmitry Zinoviev
 
1. introduction to computer
Shankar Gangaju
 
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
MUHUMUZAONAN1
 
Ad

Recently uploaded (20)

PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Complete Network Protection with Real-Time Security
L4RGINDIA
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
July Patch Tuesday
Ivanti
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Complete Network Protection with Real-Time Security
L4RGINDIA
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Ad

Basics of c Nisarg Patel

  • 2. INTRODUCTION TO C PROGRAMMING C language :  Is system programming language.  Is procedure-oriented programming language.  Is also called mid level programming language.  was developed in 1972 by Dennis Ritchie at bell laboratories of  AT&T(American Telephone & Telegraph), located in U.S.A.  was developed to be used in UNIX Operating system.
  • 3. FEATURES • Simple • Machine Independent or Portable • Mid-level programming language • structured programming language • Rich Library • Memory Management • Fast Speed • Pointers • Recursion • Extensible
  • 4. Structure of a C program
  • 5. FIRST PROGRAM OF LANGUAGE PROGRAM : #include <stdio.h> #include <conio.h> void main() { printf("Hello World"); getch(); } OUTPUT : Hello World
  • 6. DESCRIBING THE PROGRAM #include <stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h #include <conio.h> includes the console input output library functions. The getch() function is defined in conio.h file void main() The main() function is the entry point of every program in C language. The void keyword specifies that it returns no value printf() The printf() function is used to print data on the console. getch() The getch() function asks for a single character. Until you press any key, it blocks the screen
  • 7. INPUT OUTPUT FUNCTION  Used to send data to the standard output (usually the monitor) to be printed according to specific format There are two input output function of c language. Printf():  printf() is used for output.  It prints the given statement to the console.  Syntax of printf() is given below:  printf(“control string”,variables);  Sample Format strings : %d(integer), %c(character), %s(string), %f(float) etc.  Control string is a combination of text, format specifier and escape sequence.
  • 8. scanf()  Reads data from the standard input device (usually keyboard)and store it in a variable. The General format is: – scanf(“Control string”, &variable);  The general format is pretty much the same as printf() except that it passes the address of the variable (notice the & sign) instead of the variable itself to the second function argument. Example: int age; printf(“Enter your age: “); scanf(“%d”, &age);
  • 9. getchar() and putchar() getchar() - reads a character from standard input putchar() - writes a character to standard output • Example: #include <stdio.h> void main(void) { char my_char; printf(“Please type a character: “); my_char = getchar(); printf(“nYou have typed this character: “); putchar(my_char); }
  • 10. Preprocessor Directives The first statement to be checked by the compiler • Preprocessor Directives always preceded with ‘#’ sign • They contain information to the compiler which are required by the compiler during compilation. • There are a few compiler directives. But only 2 of them will be discussed here. #include <stdio.h> • Tells the compiler to include the file stdio.h during compilation • Anything in the header file will be included a part of the program #define VALUE 10 • Tells the compiler to substitute the word VALUE with 10 during compilation
  • 11. Comments  Comment means explanations or annotations that are included in a program for documentation and clarification purpose. • Comments are completely ignored by the compiler during compilation and have no effect on program execution. • Comments starts with ‘/*’ and ends with ‘*/’ • Some compiler support comments starting with ‘//’
  • 12. Variable  A variable can be declared globally or locally.  A globally declared variable can be accessed from any part of the program.  A locally declared variable can only be accessed from inside the function in which the variable is declared.
  • 13. Statements  A specification of an action to be taken by the computer as the program executes is called a Statement.  In the previous example, there are 2 lines following  variable declaration that terminate with semicolon ‘;’ are statements: global_var = local_var + VALUE;  printf (“Total sum is: %dn”, global_var);  Each line is a statement that end with a semicolon is a statement.
  • 14. Basic Functions  A C program consists of one or more functions that contain a group of statements which perform a specific task.  A C program must at least have one function: the function main.  We can create our own function or use the functions that has been declared in C library (called Predefined function).  In order to use Predefined functions, we have to include the appropriate header file (example: stdio.h). [continue…]
  • 15.  In this section, we will learn a few functions that are pre-defined in the header file stdio.h • These functions are: – printf() – scanf() – getchar() & putchar() • In addition to those functions, we will also learn about Format Specifier and Escape Sequence which are used with printf() and scanf().
  • 16. DATA TYPES & KEYWORDS 4 types of data types A keyword is a reserved word. You cannot use it as a variable name, constant name etc.
  • 17. Operators  Arithmetic Operators  Relational Operators  Shift Operators  Logical Operators  Bitwise Operators  Ternary or Conditional Operators  Assignment Operator
  • 18. CONTROL STATEMENTS • if-else  If statement  If-else statement  If else-if ladder  Nested if  switch  loops  do-while loop  while loop  for loop  break  continue