SlideShare a Scribd company logo
1 of 49
ASWATHY B ANIL
LECTURER IN COMPUTER SCIENCE
RAJADHANI POLYTECHNIC COLLEGE
INTRODUCTION
 C is a structured programming language
 C supports functions that enables easy maintainability of code, by
breaking large file into smaller modules
 Comments in C provides easy readability
 C is a powerful language.
 C programs built from
 Variable and type declarations
 Functions
 Statements
 Expressions
Basic Structure Of “C”
Programs
include Header File
Global Declaration
/* comments */
/* Function name */
main( )
{
/* comments */
Declaration part
Executable part
Function call
}
User-defined Functions
PROGRAMMING RULES
 Every program should have main() function
 C statements should be terminated by a semi-colon.
 An unessential semi-colon if placed by the programmer is treated as an
empty statement.
 All statements should be written in lowercase letters. Generally, uppercase
letters are used only for symbolic constants.
 Blank spaces may be inserted between the words
 It is not necessary to fix the position of statement in the program;
i.e. a programmer can write the statement anywhere between the two braces
following the declaration part.
eg:- a=b+c; d=b*c; 4 or a=b+c; d=b*c;
HEADER FILES
stdio.h:
 Standard input and output files.
The most useful formatted printf() and scanf() are
defined in this file.
This file must be included at the top of the program.
Most useful functions from this header files are
printf(), scanf(), getchar(), gets(), putc() and putchar()
CONT………….
conio.h:
Console input and output.
This file contains input and output functions along
with a few graphic-supporting functions.
The getch(), getche() and clrscr() functions are
defined in this file.
math.h:
This file contains all mathematical and other useful
functions
The commonly useful functions from this files are
floor(), abs(), ceil(), pow(), sin(), cos() and tan().
Write a program to display message
“Hello! C Programmers”
#include<stdio.h>
#include<conio.h>
void main( )
{
Printf(“Hello! C Programmers”);
}
Output
Hello! C Programmers
Write a program to know about the use of
comments (how to use comments?)
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( ); /* Clear the screen */
Printf(“ This program is used to check comment options”); /* how to use
comments */
}
Output
This program is used to check comment options
THE “C” CHARACTER SET
SPECIAL CHARACTERS
DELIMITERS
“C” TOKENS
The tokens are as follows:
Keywords: Key words are reserved by the compiler.
There are 32 keywords (ANSI Standard).
 Variables: These are user defined. Any number of
variables can be defined.
Constants: Constants are assigned to variables.
Operators: Operators are of different types and are
used in expressions.
Special Characters: These characters are used in
different declarations in C.
Strings: A sequence of characters.
“C” KEYWORDS
“C” IDENTIFIERS
CONT……
Identifiers are user-defined names.
They are generally defined in lowercase letters.
However, the uppercase letters are also permitted.
The underscore (_) symbol can be used as an identifier
Valid identifiers are as follows:
length, area, volume, sUM, Average
Invalid identifiers are as follows:
Length of line, S+um, year’s
CONSTANTS
CONSTANT TYPES
Numerical Constants
Integer Constant : These constants are represented with
whole numbers. They require a minimum of 2 bytes and a
maximum of 4 bytes of memory
 Numerical constants are represented with numbers. At
least one digit is needed for representing the number.
 The decimal point, fractional part, or symbols are not
permitted. Neither blank spaces nor commas are
permitted.
 Integer constant could be either positive or negative or may
be zero.
 A number without a sign is assumed as positive.
CONT………
Some valid examples:
10, 20, +30, –15, etc.
Some invalid integer constants:
2.3, .235, $76, 3*^6, etc.
Examples of octal and hexadecimal numbers:
Octal numbers
– 027, 037, 072
Hexadecimal numbers
– 0X9, 0Xab, 0X4
Real Constants:
 Real constants are often known as floating point constants.
 Real constants can be represented in exponential or fractional
form.
 Integer constants are unfit to represent many quantities.
 Many parameters or quantities are defined not only in integers
but also in 11 real numbers.
 For example, length, height, price, distance, etc. are also
measured in real numbers.
 The decimal point is permitted.
 Neither blank spaces nor commas are permitted.
 Real numbers could be either positive or negative.
 The number without a sign is assumed as positive
 Examples of real numbers are 2.5, 5.521, 3.14, etc
Character constants
Single Character Constants:
A character constant is a single character.
It can also be represented with single digit or a single
special symbol or white space enclosed within a pair of
single quote marks or character constants are enclosed
within single quotation marks
Example: ‘a’, ‘8’, ‘−’
String Constants: String constants are a sequence of
characters enclosed within double quote marks. The
string may be a combination of all kinds of symbols.
Example: “Hello”, “India”, “444”, “a”.
VARIABLES
 A variable is a data name used for storing a data value.
 Its value may be changed during the program execution.
 The variable value keeps on changing during the execution of the
program. In other words, a variable can be assigned different
values at different times during the program execution.
 A variable name may be declared based on the meaning of the
operation.
 Variable names are made up of letters and digits. Some
meaningful variable names are as follows.
Example: height, average, sum, avg12
“C” DATA TYPES
C data type can be classified as
follows:
Basic Data Type: Integer (int), character (char),
floating point (float), double floating point (double).
Derived Data Type: Derived data types are pointers,
functions and arrays.
User-defined Type: Struct, union and typedef are user-
defined data types.
Void Data Type
1. Integer Data Type((int,short and
long)
2. Integers Signed and Unsigned
2. char, signed and unsigned:
3. Floats and Doubles
DATA TYPES AND THEIR
CONTROL STRINGS
DATA TYPES AND KEYWORD
TYPES OF OPERATORS
HIERARCHY OF OPERATIONS
OPERATOR PRECEDENCE
Precedence means priority.
Every operator in C has assigned precedence (priority).
An expression may contain a lot of operators.
The operations on the operands are carried out
according to the priority of the operators.
The operators having higher priority are evaluated first
and then lower priority.
Eg:- the operators *, / and % have assigned highest
priority and of similar precedence.
The operators + and − have the lowest priority as
compared to the above operators.
EXAMPLE
8+9*2−10
The operator * is the highest priority. Hence, the
multiplication operation is performed first.
The above expression becomes
8+18 −10
In the above expression, + and − have the same priority. In
such a situation, the left most operation is evaluated first.
With this the above expression becomes
26−10
At last the subtraction operation is performed and answer of
the expression will be as follows:
16
ARITHEMATIC OPERATORS
UNARY ARITHEMATIC OPERATORS
RELATIONAL OPERATORS
ASSIGNMENT OPERATORS
LOGICAL OPERATORS
The logical AND (&&) operator provides true result
when both expressions are true, otherwise 0.
 The logical OR (||) operator provides true result when
one of the expressions is true, otherwise 0.
The logical NOT operator (!) provides 0 if the
condition is true, otherwise 1.
BITWISE OPERATORS
C introduction

More Related Content

What's hot

Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++Shobi P P
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c languageRai University
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programmingprogramming9
 
What is token c programming
What is token c programmingWhat is token c programming
What is token c programmingRumman Ansari
 
Introduction of c programming unit-ii ppt
Introduction of  c programming unit-ii pptIntroduction of  c programming unit-ii ppt
Introduction of c programming unit-ii pptJStalinAsstProfessor
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centrejatin batra
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ LanguageWay2itech
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Fundamentals of c programming
Fundamentals of c programmingFundamentals of c programming
Fundamentals of c programmingChitrank Dixit
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGAbhishek Dwivedi
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_outputAnil Dutt
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 

What's hot (20)

C Tokens
C TokensC Tokens
C Tokens
 
Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
What is token c programming
What is token c programmingWhat is token c programming
What is token c programming
 
Introduction of c programming unit-ii ppt
Introduction of  c programming unit-ii pptIntroduction of  c programming unit-ii ppt
Introduction of c programming unit-ii ppt
 
Chap 1 and 2
Chap 1 and 2Chap 1 and 2
Chap 1 and 2
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Fundamentals of c programming
Fundamentals of c programmingFundamentals of c programming
Fundamentals of c programming
 
C Slides
C SlidesC Slides
C Slides
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Data type in c
Data type in cData type in c
Data type in c
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
5 introduction-to-c
5 introduction-to-c5 introduction-to-c
5 introduction-to-c
 
Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)
 

Similar to C introduction (20)

unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 
Cnotes
CnotesCnotes
Cnotes
 
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
 
C language ppt
C language pptC language ppt
C language ppt
 
Aniket tore
Aniket toreAniket tore
Aniket tore
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
 
C intro
C introC intro
C intro
 
Module 1 PCD.docx
Module 1 PCD.docxModule 1 PCD.docx
Module 1 PCD.docx
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
C
CC
C
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
 
Basics of c
Basics of cBasics of c
Basics of c
 
C presentation book
C presentation bookC presentation book
C presentation book
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
C programming notes
C programming notesC programming notes
C programming notes
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 

Recently uploaded

WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 

Recently uploaded (20)

WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in Uganda
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

C introduction

  • 1. ASWATHY B ANIL LECTURER IN COMPUTER SCIENCE RAJADHANI POLYTECHNIC COLLEGE
  • 2. INTRODUCTION  C is a structured programming language  C supports functions that enables easy maintainability of code, by breaking large file into smaller modules  Comments in C provides easy readability  C is a powerful language.  C programs built from  Variable and type declarations  Functions  Statements  Expressions
  • 3. Basic Structure Of “C” Programs include Header File Global Declaration /* comments */ /* Function name */ main( ) { /* comments */ Declaration part Executable part Function call } User-defined Functions
  • 4. PROGRAMMING RULES  Every program should have main() function  C statements should be terminated by a semi-colon.  An unessential semi-colon if placed by the programmer is treated as an empty statement.  All statements should be written in lowercase letters. Generally, uppercase letters are used only for symbolic constants.  Blank spaces may be inserted between the words  It is not necessary to fix the position of statement in the program; i.e. a programmer can write the statement anywhere between the two braces following the declaration part. eg:- a=b+c; d=b*c; 4 or a=b+c; d=b*c;
  • 5. HEADER FILES stdio.h:  Standard input and output files. The most useful formatted printf() and scanf() are defined in this file. This file must be included at the top of the program. Most useful functions from this header files are printf(), scanf(), getchar(), gets(), putc() and putchar()
  • 6. CONT…………. conio.h: Console input and output. This file contains input and output functions along with a few graphic-supporting functions. The getch(), getche() and clrscr() functions are defined in this file. math.h: This file contains all mathematical and other useful functions The commonly useful functions from this files are floor(), abs(), ceil(), pow(), sin(), cos() and tan().
  • 7.
  • 8. Write a program to display message “Hello! C Programmers” #include<stdio.h> #include<conio.h> void main( ) { Printf(“Hello! C Programmers”); } Output Hello! C Programmers
  • 9. Write a program to know about the use of comments (how to use comments?) #include<stdio.h> #include<conio.h> void main( ) { clrscr( ); /* Clear the screen */ Printf(“ This program is used to check comment options”); /* how to use comments */ } Output This program is used to check comment options
  • 11.
  • 15. The tokens are as follows: Keywords: Key words are reserved by the compiler. There are 32 keywords (ANSI Standard).  Variables: These are user defined. Any number of variables can be defined. Constants: Constants are assigned to variables. Operators: Operators are of different types and are used in expressions. Special Characters: These characters are used in different declarations in C. Strings: A sequence of characters.
  • 18. CONT…… Identifiers are user-defined names. They are generally defined in lowercase letters. However, the uppercase letters are also permitted. The underscore (_) symbol can be used as an identifier Valid identifiers are as follows: length, area, volume, sUM, Average Invalid identifiers are as follows: Length of line, S+um, year’s
  • 21. Numerical Constants Integer Constant : These constants are represented with whole numbers. They require a minimum of 2 bytes and a maximum of 4 bytes of memory  Numerical constants are represented with numbers. At least one digit is needed for representing the number.  The decimal point, fractional part, or symbols are not permitted. Neither blank spaces nor commas are permitted.  Integer constant could be either positive or negative or may be zero.  A number without a sign is assumed as positive.
  • 22. CONT……… Some valid examples: 10, 20, +30, –15, etc. Some invalid integer constants: 2.3, .235, $76, 3*^6, etc. Examples of octal and hexadecimal numbers: Octal numbers – 027, 037, 072 Hexadecimal numbers – 0X9, 0Xab, 0X4
  • 23. Real Constants:  Real constants are often known as floating point constants.  Real constants can be represented in exponential or fractional form.  Integer constants are unfit to represent many quantities.  Many parameters or quantities are defined not only in integers but also in 11 real numbers.  For example, length, height, price, distance, etc. are also measured in real numbers.
  • 24.  The decimal point is permitted.  Neither blank spaces nor commas are permitted.  Real numbers could be either positive or negative.  The number without a sign is assumed as positive  Examples of real numbers are 2.5, 5.521, 3.14, etc
  • 25. Character constants Single Character Constants: A character constant is a single character. It can also be represented with single digit or a single special symbol or white space enclosed within a pair of single quote marks or character constants are enclosed within single quotation marks Example: ‘a’, ‘8’, ‘−’
  • 26. String Constants: String constants are a sequence of characters enclosed within double quote marks. The string may be a combination of all kinds of symbols. Example: “Hello”, “India”, “444”, “a”.
  • 27. VARIABLES  A variable is a data name used for storing a data value.  Its value may be changed during the program execution.  The variable value keeps on changing during the execution of the program. In other words, a variable can be assigned different values at different times during the program execution.  A variable name may be declared based on the meaning of the operation.  Variable names are made up of letters and digits. Some meaningful variable names are as follows. Example: height, average, sum, avg12
  • 29. C data type can be classified as follows: Basic Data Type: Integer (int), character (char), floating point (float), double floating point (double). Derived Data Type: Derived data types are pointers, functions and arrays. User-defined Type: Struct, union and typedef are user- defined data types. Void Data Type
  • 30. 1. Integer Data Type((int,short and long)
  • 31. 2. Integers Signed and Unsigned
  • 32. 2. char, signed and unsigned:
  • 33. 3. Floats and Doubles
  • 34. DATA TYPES AND THEIR CONTROL STRINGS
  • 35. DATA TYPES AND KEYWORD
  • 37. HIERARCHY OF OPERATIONS OPERATOR PRECEDENCE Precedence means priority. Every operator in C has assigned precedence (priority). An expression may contain a lot of operators. The operations on the operands are carried out according to the priority of the operators. The operators having higher priority are evaluated first and then lower priority. Eg:- the operators *, / and % have assigned highest priority and of similar precedence. The operators + and − have the lowest priority as compared to the above operators.
  • 38. EXAMPLE 8+9*2−10 The operator * is the highest priority. Hence, the multiplication operation is performed first. The above expression becomes 8+18 −10 In the above expression, + and − have the same priority. In such a situation, the left most operation is evaluated first. With this the above expression becomes 26−10 At last the subtraction operation is performed and answer of the expression will be as follows: 16
  • 39.
  • 40.
  • 42.
  • 47. The logical AND (&&) operator provides true result when both expressions are true, otherwise 0.  The logical OR (||) operator provides true result when one of the expressions is true, otherwise 0. The logical NOT operator (!) provides 0 if the condition is true, otherwise 1.