SlideShare a Scribd company logo
1 of 20
JEENA SARA VIJU
ASSISTANT PROFESSOR
DEPARTMENT OF COMPUTER APPLICATIONS
MACFAST
INTRODUCTION TO
PROGRAMMING IN C-
PART2
1 JEENA SARA VIJU, ASST. PROF OF MCA
JEENA SARA VIJU, ASST. PROF OF MCA2
Operators and expressions: Arithmetic operators,
unary operator, relational and logical operator,
assignment operators, the conditional operator, type
conversion, Library function
Data input and output: Single character input, single
character output, scanf, printf, puts gets functions,
interactive programming.
Control statement: Branching: if else statement,
Looping, nested control structure, switch statement,
break statement, continue statement, comma
operator, goto statement.
OPERATORS & EXPRESSIONS
JEENA SARA VIJU, ASST. PROF OF MCA3
 An operator is a symbol that tells the computer to
perform certain mathematical or logical manipulations.
 Operators are used in programs to manipulate data &
variables.
 The data items that operators act upon are called
operands.
 An expression is the sequence of operands &
operators.
 Arithmetic operators
 Unary operators
 Relational and logical operators
 Assignment operators
JEENA SARA VIJU, ASST. PROF OF MCA4
ARITHMETIC OPERATOR
 There are five arithmetic operators in C. They are
OPERATOR PURPOSE
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder after integer
division (modulus operator)
JEENA SARA VIJU, ASST. PROF OF MCA5
INTEGER ARITHMETIC
 If both the operands in a single arithmetic expression
are integers, then the operation is called integer
arithmetic.
 It always yield integer value.
 Eg. -14%3 -16+7 etc
REAL ARITHMETIC
 An arithmetic operation involving only real operands is
called real arithmetic.
 A real operand will have values either in decimal or
exponential notation.
 Eg. 6.0/7.0 -2.0/3.0 etc
JEENA SARA VIJU, ASST. PROF OF MCA6
MIXED MODE ARITHMETIC
 When one of the operand is real and the other is
integer, the expression is called mixed-mode arithmetic.
UNARY OPERATOR
 C includes a class of operators that act upon a single
operand to produce a new value. Such operators are
known as unary operators.
 The most common unary operation is unary minus,
where a numerical constant, variable or expression is
preceded by a minus sign.
 There are two other commonly used unary operators:
The increment operator, ++, and the decrement
operator, --. The increment operator causes its operand
to be increased by 1, whereas the decrement operator
causes its operand to be decreased by 1. The operand
JEENA SARA VIJU, ASST. PROF OF MCA7
 If the operator precedes the operand (e.g., ++i), then
the operand will be altered in value before it is utilized
for its intended purpose within the program.
 If the operator follows the operand (e.g., i++), then the
value of the operand will be altered after it is utilized.
RELATIONAL & LOGICAL OPERATORS
 There are four relational operators in C.
OPERATOR MEANING
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
JEENA SARA VIJU, ASST. PROF OF MCA8
 Closely associated with the relational operators are
the following two equality operators.
 C contains three logical operators (also called logical
connectives).
OPERATOR MEANING
== Equal to
!= Not equal to
OPERATOR MEANING
&& And
|| Or
! Not
JEENA SARA VIJU, ASST. PROF OF MCA9
 The result of a logical and operation will be true only if
both operands are true.
 The result of a logical or operation will be true if either
operand is true or if both operands are true.
ASSIGNMENT OPERATORS
 Used to assign the result of an expression to a
variable.
 identifier = expression
 Remember that the assignment operator = and the
equality operator == are distinctly different.
CONDITIONAL OPERATOR
 Simple conditional operations can be carried out with
the conditional operator (? :). An expression that
makes use of the conditional operator is called a
conditional expression.
JEENA SARA VIJU, ASST. PROF OF MCA10
expression 7 ? expression 2 : expression 3
 Eg.
a = 10;
b = 15;
x = (a>b) ? a : b;
LIBRARY FUNCTIONS
 The C language is accompanied by a number of
library functions that carry out various commonly used
operations or calculations.
 Some functions return a data item to their access
point; others indicate whether a condition is true or
false by returning a 1 or a 0, respectively; still others
carry out specific operations on data items but do not
return anything.
JEENA SARA VIJU, ASST. PROF OF MCA11
 Library functions in C language are inbuilt functions
which are grouped together and placed in a common
place called library.
 Each library function in C performs specific operation.
 All C standard library functions are declared in many
header files which are saved as file_name.h
 We are including these header files in our C program
using “#include<file_name.h>” command to make use
of the functions those are declared in the header files.
 A library function is accessed simply by writing the
function name, followed by a list of arguments that
represent information being passed to the function.
 The arguments must be enclosed in parentheses and
separated by commas. The parentheses must be
present, even if there are no arguments.
JEENA SARA VIJU, ASST. PROF OF MCA12
 There are library functions that carry out standard
input/output operations (e.g., read and write
characters, read and write numbers, open and close
files, test for end of file, etc.), functions that perform
operations on characters (e.g., convert from lower- to
uppercase, test to see if a character is uppercase,
etc.), functions that perform operations on strings
(e.g., copy a string, compare strings, concatenate
strings, etc.), and functions that carry out various
mathematical calculations (e.g., evaluate
trigonometric, logarithmic and exponential functions,
compute absolute values, square roots, etc.).
JEENA SARA VIJU, ASST. PROF OF MCA13
DATA INPUT AND OUTPUT
JEENA SARA VIJU, ASST. PROF OF MCA14
 An input/output function can be accessed from
anywhere within a program simply by writing the
function name, followed by a list of arguments
enclosed in parentheses.
 getchar, putchar, scanf, printf, gets and puts
 getchar and putchar - allow single characters to be
transferred into and out of the computer
 scanf and printf - they permit the transfer of single
characters, numerical values and strings
 gets and puts - facilitate the input and output of
strings.
JEENA SARA VIJU, ASST. PROF OF MCA15
JEENA SARA VIJU, ASST. PROF OF MCA16
SINGLE CHARACTER INPUT
 Single characters can be entered into the computer
using the C library function getchar.
 It returns a single character from a standard input
device (typically a keyboard).
 The function does not require any arguments, though a
pair of empty parentheses must follow the word getchar.
Character_variable = getchar ( ) ;
SINGLE CHARACTER OUTPUT
 Single characters can be displayed (written out of the
computer) using the C library function putchar.
 It transmits a single character to a standard output
device.
JEENA SARA VIJU, ASST. PROF OF MCA17
putchar ( character variable);
ENTERING INPUT DATA
 Input data can be entered into the computer from a
standard input device by means of the C library
function scanf.
 This function can be used to enter any combination of
numerical values, single characters and strings.
scanf(contro1 string, argl, arg2, . . . , argn);
 The control string consists of individual groups of
characters, with one character group for each input
data item. Each character group must begin with a
percent sign (%).
 The arguments are written as variables or arrays,
whose types match the corresponding character
groups in the control string. Each variable name must
JEENA SARA VIJU, ASST. PROF OF MCA18
WRITING OUTPUT DATA
 Output data can be written from the computer onto a
standard output device using the library function printf.
 This function can be used to output any combination
of numerical values, single characters and strings.
printf ( control string, arg7, arg2, . . . , argn)
 In contrast to the scanf function, the arguments in a
printf function do not represent memory addresses
and therefore are not preceded by ampersands.
gets and puts function
JEENA SARA VIJU, ASST. PROF OF MCA19
#include <stdio.h>
/* read and write a line of text * /
main( )
{
char line[80] ;
gets(line);
puts(line);
}
INTERACTIVE (CONVERSATIONAL)
PROGRAMMING
JEENA SARA VIJU, ASST. PROF OF MCA20
 Many modern computer programs are designed to
create an interactive dialog between the computer and
the person using the program (the "user").
 These dialogs usually involve some form of question-
answer interaction, where the computer asks the
questions and the user provides the answers, or vice
versa.
 The computer and the user thus appear to be carrying
on some limited form of conversation.
 In C, such dialogs can be created by alternate use of
the scanf and printf functions.

More Related Content

What's hot

Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C ProgrammingShuvongkor Barman
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programmingTejaswiB4
 
Functions in C - Programming
Functions in C - Programming Functions in C - Programming
Functions in C - Programming GaurangVishnoi
 
User Defined Functions in MATLAB part 2
User Defined Functions in MATLAB part 2User Defined Functions in MATLAB part 2
User Defined Functions in MATLAB part 2Shameer Ahmed Koya
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and typesimtiazalijoono
 
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.SivakumarSivakumar R D .
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)Mansi Tyagi
 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in CSyed Mustafa
 
User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4Shameer Ahmed Koya
 
Functions assignment
Functions assignmentFunctions assignment
Functions assignmentAhmad Kamal
 
Matlab Programming Tips Part 1
Matlab Programming Tips Part 1Matlab Programming Tips Part 1
Matlab Programming Tips Part 1Shameer Ahmed Koya
 
15 functions
15 functions15 functions
15 functionsfyjordan9
 

What's hot (20)

Functions in C
Functions in CFunctions in C
Functions in C
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Functions in C - Programming
Functions in C - Programming Functions in C - Programming
Functions in C - Programming
 
User Defined Functions in MATLAB part 2
User Defined Functions in MATLAB part 2User Defined Functions in MATLAB part 2
User Defined Functions in MATLAB part 2
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
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
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Unit 7. Functions
Unit 7. FunctionsUnit 7. Functions
Unit 7. Functions
 
Functions
FunctionsFunctions
Functions
 
Functions
FunctionsFunctions
Functions
 
Function
FunctionFunction
Function
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in C
 
Functions
Functions Functions
Functions
 
User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4
 
C# programs
C# programsC# programs
C# programs
 
Functions assignment
Functions assignmentFunctions assignment
Functions assignment
 
Matlab Programming Tips Part 1
Matlab Programming Tips Part 1Matlab Programming Tips Part 1
Matlab Programming Tips Part 1
 
15 functions
15 functions15 functions
15 functions
 

Similar to INTRODUCTION TO C PROGRAMMING - PART 2

C operators
C operatorsC operators
C operatorsGPERI
 
Computer programming in C. Library functions in C.
Computer programming in C. Library functions in C.Computer programming in C. Library functions in C.
Computer programming in C. Library functions in C.LamiyQurbanlKomptert
 
Introduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John LadoIntroduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John LadoMark John Lado, MIT
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programmingprogramming9
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming languageVasavi College of Engg
 
Types of c operators ppt
Types of c operators pptTypes of c operators ppt
Types of c operators pptViraj Shah
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golangwww.ixxo.io
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
OPERATORS.pptx
OPERATORS.pptxOPERATORS.pptx
OPERATORS.pptxPMLAVANYA
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptxAnisZahirahAzman
 

Similar to INTRODUCTION TO C PROGRAMMING - PART 2 (20)

C operators
C operatorsC operators
C operators
 
Computer programming in C. Library functions in C.
Computer programming in C. Library functions in C.Computer programming in C. Library functions in C.
Computer programming in C. Library functions in C.
 
Introduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John LadoIntroduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John Lado
 
C interview questions
C interview  questionsC interview  questions
C interview questions
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
Programming-in-C
Programming-in-CProgramming-in-C
Programming-in-C
 
Unit 1
Unit 1Unit 1
Unit 1
 
2. operator
2. operator2. operator
2. operator
 
[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++
 
Types of c operators ppt
Types of c operators pptTypes of c operators ppt
Types of c operators ppt
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
 
Unit 2
Unit 2Unit 2
Unit 2
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golang
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
OPERATORS.pptx
OPERATORS.pptxOPERATORS.pptx
OPERATORS.pptx
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
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
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
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
 
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
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
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
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
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
 
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
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

INTRODUCTION TO C PROGRAMMING - PART 2

  • 1. JEENA SARA VIJU ASSISTANT PROFESSOR DEPARTMENT OF COMPUTER APPLICATIONS MACFAST INTRODUCTION TO PROGRAMMING IN C- PART2 1 JEENA SARA VIJU, ASST. PROF OF MCA
  • 2. JEENA SARA VIJU, ASST. PROF OF MCA2 Operators and expressions: Arithmetic operators, unary operator, relational and logical operator, assignment operators, the conditional operator, type conversion, Library function Data input and output: Single character input, single character output, scanf, printf, puts gets functions, interactive programming. Control statement: Branching: if else statement, Looping, nested control structure, switch statement, break statement, continue statement, comma operator, goto statement.
  • 3. OPERATORS & EXPRESSIONS JEENA SARA VIJU, ASST. PROF OF MCA3  An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations.  Operators are used in programs to manipulate data & variables.  The data items that operators act upon are called operands.  An expression is the sequence of operands & operators.  Arithmetic operators  Unary operators  Relational and logical operators  Assignment operators
  • 4. JEENA SARA VIJU, ASST. PROF OF MCA4 ARITHMETIC OPERATOR  There are five arithmetic operators in C. They are OPERATOR PURPOSE + Addition - Subtraction * Multiplication / Division % Remainder after integer division (modulus operator)
  • 5. JEENA SARA VIJU, ASST. PROF OF MCA5 INTEGER ARITHMETIC  If both the operands in a single arithmetic expression are integers, then the operation is called integer arithmetic.  It always yield integer value.  Eg. -14%3 -16+7 etc REAL ARITHMETIC  An arithmetic operation involving only real operands is called real arithmetic.  A real operand will have values either in decimal or exponential notation.  Eg. 6.0/7.0 -2.0/3.0 etc
  • 6. JEENA SARA VIJU, ASST. PROF OF MCA6 MIXED MODE ARITHMETIC  When one of the operand is real and the other is integer, the expression is called mixed-mode arithmetic. UNARY OPERATOR  C includes a class of operators that act upon a single operand to produce a new value. Such operators are known as unary operators.  The most common unary operation is unary minus, where a numerical constant, variable or expression is preceded by a minus sign.  There are two other commonly used unary operators: The increment operator, ++, and the decrement operator, --. The increment operator causes its operand to be increased by 1, whereas the decrement operator causes its operand to be decreased by 1. The operand
  • 7. JEENA SARA VIJU, ASST. PROF OF MCA7  If the operator precedes the operand (e.g., ++i), then the operand will be altered in value before it is utilized for its intended purpose within the program.  If the operator follows the operand (e.g., i++), then the value of the operand will be altered after it is utilized. RELATIONAL & LOGICAL OPERATORS  There are four relational operators in C. OPERATOR MEANING < Less than <= Less than or equal to > Greater than >= Greater than or equal to
  • 8. JEENA SARA VIJU, ASST. PROF OF MCA8  Closely associated with the relational operators are the following two equality operators.  C contains three logical operators (also called logical connectives). OPERATOR MEANING == Equal to != Not equal to OPERATOR MEANING && And || Or ! Not
  • 9. JEENA SARA VIJU, ASST. PROF OF MCA9  The result of a logical and operation will be true only if both operands are true.  The result of a logical or operation will be true if either operand is true or if both operands are true. ASSIGNMENT OPERATORS  Used to assign the result of an expression to a variable.  identifier = expression  Remember that the assignment operator = and the equality operator == are distinctly different. CONDITIONAL OPERATOR  Simple conditional operations can be carried out with the conditional operator (? :). An expression that makes use of the conditional operator is called a conditional expression.
  • 10. JEENA SARA VIJU, ASST. PROF OF MCA10 expression 7 ? expression 2 : expression 3  Eg. a = 10; b = 15; x = (a>b) ? a : b; LIBRARY FUNCTIONS  The C language is accompanied by a number of library functions that carry out various commonly used operations or calculations.  Some functions return a data item to their access point; others indicate whether a condition is true or false by returning a 1 or a 0, respectively; still others carry out specific operations on data items but do not return anything.
  • 11. JEENA SARA VIJU, ASST. PROF OF MCA11  Library functions in C language are inbuilt functions which are grouped together and placed in a common place called library.  Each library function in C performs specific operation.  All C standard library functions are declared in many header files which are saved as file_name.h  We are including these header files in our C program using “#include<file_name.h>” command to make use of the functions those are declared in the header files.  A library function is accessed simply by writing the function name, followed by a list of arguments that represent information being passed to the function.  The arguments must be enclosed in parentheses and separated by commas. The parentheses must be present, even if there are no arguments.
  • 12. JEENA SARA VIJU, ASST. PROF OF MCA12  There are library functions that carry out standard input/output operations (e.g., read and write characters, read and write numbers, open and close files, test for end of file, etc.), functions that perform operations on characters (e.g., convert from lower- to uppercase, test to see if a character is uppercase, etc.), functions that perform operations on strings (e.g., copy a string, compare strings, concatenate strings, etc.), and functions that carry out various mathematical calculations (e.g., evaluate trigonometric, logarithmic and exponential functions, compute absolute values, square roots, etc.).
  • 13. JEENA SARA VIJU, ASST. PROF OF MCA13
  • 14. DATA INPUT AND OUTPUT JEENA SARA VIJU, ASST. PROF OF MCA14  An input/output function can be accessed from anywhere within a program simply by writing the function name, followed by a list of arguments enclosed in parentheses.  getchar, putchar, scanf, printf, gets and puts  getchar and putchar - allow single characters to be transferred into and out of the computer  scanf and printf - they permit the transfer of single characters, numerical values and strings  gets and puts - facilitate the input and output of strings.
  • 15. JEENA SARA VIJU, ASST. PROF OF MCA15
  • 16. JEENA SARA VIJU, ASST. PROF OF MCA16 SINGLE CHARACTER INPUT  Single characters can be entered into the computer using the C library function getchar.  It returns a single character from a standard input device (typically a keyboard).  The function does not require any arguments, though a pair of empty parentheses must follow the word getchar. Character_variable = getchar ( ) ; SINGLE CHARACTER OUTPUT  Single characters can be displayed (written out of the computer) using the C library function putchar.  It transmits a single character to a standard output device.
  • 17. JEENA SARA VIJU, ASST. PROF OF MCA17 putchar ( character variable); ENTERING INPUT DATA  Input data can be entered into the computer from a standard input device by means of the C library function scanf.  This function can be used to enter any combination of numerical values, single characters and strings. scanf(contro1 string, argl, arg2, . . . , argn);  The control string consists of individual groups of characters, with one character group for each input data item. Each character group must begin with a percent sign (%).  The arguments are written as variables or arrays, whose types match the corresponding character groups in the control string. Each variable name must
  • 18. JEENA SARA VIJU, ASST. PROF OF MCA18 WRITING OUTPUT DATA  Output data can be written from the computer onto a standard output device using the library function printf.  This function can be used to output any combination of numerical values, single characters and strings. printf ( control string, arg7, arg2, . . . , argn)  In contrast to the scanf function, the arguments in a printf function do not represent memory addresses and therefore are not preceded by ampersands.
  • 19. gets and puts function JEENA SARA VIJU, ASST. PROF OF MCA19 #include <stdio.h> /* read and write a line of text * / main( ) { char line[80] ; gets(line); puts(line); }
  • 20. INTERACTIVE (CONVERSATIONAL) PROGRAMMING JEENA SARA VIJU, ASST. PROF OF MCA20  Many modern computer programs are designed to create an interactive dialog between the computer and the person using the program (the "user").  These dialogs usually involve some form of question- answer interaction, where the computer asks the questions and the user provides the answers, or vice versa.  The computer and the user thus appear to be carrying on some limited form of conversation.  In C, such dialogs can be created by alternate use of the scanf and printf functions.