SlideShare a Scribd company logo
C PROGRAMMING LANGUAGE
INTRODUCTION TO C
• It is a structured programming language used to develop operating
system, business system, word processing, database system e.t.c
• Developed by Dennis Ritchie at the Bell Laboratories in 1972 to develop
the UNIX operating system.
• At the time, Bell Labs had a programming language named B — B for
Bell. The next language they created was C — one up on B.
• C is the offspring of both the B programming language and a
language named BCPL, which stood for Basic Combined Programming
Language.
• It is modular language. C code can be written in routines called
functions. These functions can be reused in other applications or
programs.
• It is case sensitive language.
C LANGUAGE PIECES PARTS
1. #include is known as a preprocessor directive. It tells
the compiler to “include” text from another file,
stuffing it right into source code. Doing this avoids lots
of little, annoying errors.
2. <stdio.h> is a filename surrounded by angle brackets.
The whole statement #include <stdio.h> tells the
compiler to take text from the file STDIO.H and stick it
into source code before the source code is compiled.
The STDIO.H file itself contains information about the
Standard Input/output functions required by most C
programs. The H means “header.”
3. The int identifies the function main as an integer
function, meaning that main() must return an
integer value when it’s done. The function main,
which also identifies the first and primary function
inside the program.
4. Two empty parentheses follow the function name.
5. All functions in C have their contents encased by
curly braces.
6. printf() job is to display information(output) on the
screen. The added f means “formatted,”.
7. printf() has a set of parentheses, which consists of text, or a
“string” of characters. Everything between the double quote
characters (“) is part of printf’s text string.
8. ‘n’ called a newline in C are called wildcard characters.
9. The printf line, or statement, ends with a semicolon. The
semicolon tells the C compiler where one statement ends and
another begins. Note that all statements require semicolons in
C, even if only one statement is in a program or function.
10. The return command sends the value 0 (zero) back to the
operating system when the main() function is done. Returning a
value is required as part of the main() function. This statement
ends in a semicolon.
QUIZ!
1. The core function in every C language program is called
A. numero_uno().
B. main().
C. primus().
D. core().
2. Functions require parentheses because
A. They talk in whispers.
B. The parentheses keep the function warm.
C. The parentheses hold various things required by or belonging to
the function.
D. None
C PROGRAMMING LANGUAGE
SESSION 2
VARIABLES
• A variable is a named data storage location on computers memory. By
using variable name on our program we are, in effect referring to the
data stored there.
• For many compilers, a variable name can be up to 31 character long. But
it can be actually longer than that)
• Rules for naming a variable:-
• The name can contain letters, digit and the underscore character(_).
• The first character of the name must be a letter. The underscore is also
legal but it’s not recommended.
• Case matters.
• C keywords cannot be used as a variable name.
• It should not contain any other special character than underscore(_).
• A variable name mustn’t have any embedded space.
• Declaring a variable:-
• A variable declaration tells the compiler the name and the type of a variable and
optionally initializes the variable to a specific value.
• A variable declaration has following form:-
Data_type_name variable name;
Eg: int roll,num;
float percentage;
• Data Type:
• The data type defines the values that needs to be stored in a program.
• C supports mainly two type of data types:
1. Primary data types
2. Derived data types
3. User defined data type
PRIMARY DATA TYPE
Data type Data sub_type Bytes Format Range
Character
Signed 1 %c -128 to 127
Unsigned 1 %c 0 to 255
Numeric
Sort Signed int 2 %d -32768 to 32767
Sort Unsigned int 2 %d 0 to 65535
Long Signed int 4 %1d -2147483648 to
2147483647
Long Unsigned int 4 %1d 0 to 4294967295
Float 4 %f 3.4E-38 to 3.4E+38
Double 8 %1f 3.7E-308 to
3.4E+308
Long double 10 %1f 3.4E-4932 to
3.4E + 4932
• Derived Data Types:
• Functions, arrays and pointers are derived data type.
• User Defined Data Type:
• The user defined datatype identifier can later be used to
declare variables.
• The user defined data types are:
• Structure
• Union
• Enumeration
CONSTANT
• A constant is the fixed value that do not change during the execution
of the program.
• C supports four constants:-
• Character
• String
• Integer
• floating-point constants.
• The numeric constants(integer and floating-point) must adhere
following rules:-
1. Commas and blank spaces cannot be included within the
constants.
2. The constant can be preceded by a minus(-) sign if desired.
3. The value of constant cannot exceed specified minimum and
maximum bounds
QUIZ
1. Which of the following variable name is not a valid variable name?
a) Annual_profit
b) _2009_tax
c) Saving#account
d) Year2x5_abc
2. How many bytes of memory does a double data type take ?
a) -32768 to 32767
b) 0 to 255
c) 4
d) 8
1. Which of the valid format specifier for string type value?
a) %d
b) %c
c) %st
d) %s
2. What is the range of short signed Integer?
a) -32768 to 32767
b) 0 to 255
c) 0 to 65535
d) 3.7E-308 to 3.4E+308
C PROGRAMMING LANGUAGE
SESSION 3
OPERATOR
• Operator is a symbol which helps the user to command the computer
to do certain mathematical or logical manipulation.
• Types of operator
• Arithmetic Operator
• Assignment Operator
• Unary Operator
• Relational Operator
• Logical Operator
• Ternary operator
• Comma Operator
• Bitwise Operator
• Size of Operator
1) Arithmetic Operator
Basic mathematical operation.
Operator Symbol
Addition +
Subtraction -
Multiplication *
Division /
Modulus %
(Returns Reminder)
2) Assignment Operator
Is used to assign Values.
Some of them are =,+=,-=,*=,/=,%=
3. Unary Operator:
• It is so called because they take a single operand. It acts upon
single operand to be increased or decreased by one.
• Operator Symbol action Example
Increment ++ Increments the operand by one x++,++x
Decrement -- Decrements the operand by one x--,--x
• They differ in which mode they are used.
• When used in prefix mode, the increment and decrement
operators modify their operand before it’s used.
• When Used in postfix mode, the increment and decrement
operators modify their operand after it’s use.
4. Relational Operator:-
It is used to compare expressions. An expression containing a relational
operator evaluates to either true or false.
Operator Symbol
Equal ==
Greater than >
Less than <
Grater than or equal to >=
Less than or equal to <=
Not Equal !=
5. Logical Operator:-
It let’s us to combine two or more relational expression into a single expression
that evaluates to either true or false.
Operator Symbol
AND &&
OR ||
NOT !
6. Ternary Operator:-
It is used to check certain relational expression and execute the true statement if
the condition is true and display if the condition is false.
Syntax:
[condition] ? [true statement]:[false statement]
Example:
a>b ? printf (“a is greater”) : printf (“b is greater”);
7. Bitwise Operator:-
These operators are used for having bit level computations of different values.
Operator Meaning
& bitwise AND
| bitwise OR
^ bitwise exclusive OR
>> shift cells right
>> shift cells left
- one’s complement
6. Size of () Operator:-
Returns the number of bytes occupied in the memory
Syntax:
sizeof(datatype/variable);
Example:
sizeof(int);
ESCAPE SEQUENCE
• These are characters not printed when used but provide various
functions. These are always started with a backslash ‘’. Commonly
Used are:-
• Constant Meaning
‘a’ Audible Alert
‘b’ backspace
‘f’ Form feed
‘n’ New Line
‘r’ Carriage Return
‘t’ Horizontal Tab
‘V’ Vertical Tab
‘’’ Single quote
‘”’ Double quote
‘?’ Question mark
‘’ Back slash
‘0’ Null
HEADER FILES
• Header File contains definition of functions and variables which
can be incorporated into any c program by using the preprocessor
#include statement. All header files have the extension .h.
• Some commonly used Header files:
• Stdio.h : It contains the standard input and output functions like
printf(), scanf(),gets(),puts() etc.
• Conio.h : It contains some of the functions like getch(), clrscr()
etc.
• Math.h : It contains the mathematical functions like strlen(),
strcpy(), strcmp(), strrev() etc.
• Ctype.h : it contains some validating functions like isdigit(),
isalnum(), isalpha() and some converting functions like
toupper(), tolower() etc.
SEQUENCE
Programming I
• WAP to calculate the area and circumference of a circle . Where radius of a
circle is input by user and define pi as constant.
• WAP to read principle, time and rate to calculate the simple interest and total
amount .
• WAP to convert temperature in Fahrenheit into centigrade and vice versa.
• WAP to ask cost of pen in Paisa. Convert it into nearest rupees and paisa.
• WAP to enter distance between two cities in KM and convert it into meter,
centimeter, inch and feet.
• WAP to enter any 4 digit number and find the sum of the first and last digit of the
number.[e.g. Any four digit number =4567, sum =4+7].
• WAP to supply length and breadth of a rectangle. Find out area and perimeter.
• WAP to find total and percentage of the students whose marks are as follows:
• WAP to enter 4 digit number and find the sum of them.[e.g.
1234=1+2+3+4=10].
• WAP to interchange the contents of x and y after entering the value of x and
y
• WAP to read the radius of the sphere and find the volume and area of it.
Subjects Marks
English 65
Nepali 75
Computer Science 70
Math 80
Account 60
• WAP to find the area of triangle after reading the value of base and
height.
• WAP to find the compound interest. The value principle, time and
interest rate is given by user.
• WAP to find the area of a triangle, if the length of the side of a triangle
are denoted by a, b, c then area of triangle id given by
Area= 𝒔 𝒔 − 𝒂 𝒔 − 𝒃 𝒔 − 𝒄 𝐰𝐡𝐞𝐫𝐞 𝒔 =
(𝒂+𝒃+𝒄)
𝟐
.
• Basic salary of Sabin is input through keyboard. His medical
allowance is 10% of the basic salary and provident fund is 10% of the
basic salary. WAP to find his net salary.
• WAP to solve the quadratic equation a𝒙 𝟐
+ b𝒙 + 𝒄 = 𝟎 , 𝒘𝒉𝒆𝒓𝒆
x=
−𝒃±𝒃 𝟐−𝟒𝒂𝒄
𝟐𝒂
C programming language

More Related Content

What's hot

Chapter3
Chapter3Chapter3
Chapter3
Kamran
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
MalikaJoya
 
C language
C languageC language
C language
spatidar0
 
Hands-on Introduction to the C Programming Language
Hands-on Introduction to the C Programming LanguageHands-on Introduction to the C Programming Language
Hands-on Introduction to the C Programming Language
Vincenzo De Florio
 
Sachin kumar ppt on programming in c
Sachin kumar ppt on programming in cSachin kumar ppt on programming in c
Sachin kumar ppt on programming in c
Sachin Kumar
 
# And ## operators in c
# And ## operators in c# And ## operators in c
# And ## operators in c
Dr. Prashant Vats
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
Basic c
Basic cBasic c
Basic c
Veera Karthi
 
Features of c language 1
Features of c language 1Features of c language 1
Features of c language 1
srmohan06
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
Bharat Kalia
 
Features of c
Features of cFeatures of c
Features of c
Hitesh Kumar
 
Brief introduction to the c programming language
Brief introduction to the c programming languageBrief introduction to the c programming language
Brief introduction to the c programming languageKumar Gaurav
 
C programming language
C programming languageC programming language
C programming language
Mahmoud Eladawi
 
OpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
Open Gurukul
 
The smartpath information systems c pro
The smartpath information systems c proThe smartpath information systems c pro
The smartpath information systems c pro
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
vampugani
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
gajendra singh
 

What's hot (20)

Chapter3
Chapter3Chapter3
Chapter3
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
C language
C languageC language
C language
 
Hands-on Introduction to the C Programming Language
Hands-on Introduction to the C Programming LanguageHands-on Introduction to the C Programming Language
Hands-on Introduction to the C Programming Language
 
Sachin kumar ppt on programming in c
Sachin kumar ppt on programming in cSachin kumar ppt on programming in c
Sachin kumar ppt on programming in c
 
# And ## operators in c
# And ## operators in c# And ## operators in c
# And ## operators in c
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
Basic c
Basic cBasic c
Basic c
 
Features of c language 1
Features of c language 1Features of c language 1
Features of c language 1
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
Features of c
Features of cFeatures of c
Features of c
 
Brief introduction to the c programming language
Brief introduction to the c programming languageBrief introduction to the c programming language
Brief introduction to the c programming language
 
C programming language
C programming languageC programming language
C programming language
 
OpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
 
The smartpath information systems c pro
The smartpath information systems c proThe smartpath information systems c pro
The smartpath information systems c pro
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - language
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 

Viewers also liked

All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
sandeep kumbhkar
 
Palindrome number program in c
Palindrome number program in cPalindrome number program in c
Palindrome number program in c
mohdshanu
 
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
Syed Mustafa
 
Module 03 File Handling in C
Module 03 File Handling in CModule 03 File Handling in C
Module 03 File Handling in C
Tushar B Kute
 
Structure c
Structure cStructure c
Structure c
thirumalaikumar3
 
File in c
File in cFile in c
File in c
Prabhu Govind
 
File handling in c
File handling in c File handling in c
File handling in c
Vikash Dhal
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in C
Ashim Lamichhane
 
C programs
C programsC programs
C programsMinu S
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
File handling in c
File handling in cFile handling in c
File handling in c
aakanksha s
 
Structure in c
Structure in cStructure in c
Structure in c
Prabhu Govind
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
Amit Tyagi
 
Array in C
Array in CArray in C
Array in C
Kamal Acharya
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 

Viewers also liked (20)

week-20x
week-20xweek-20x
week-20x
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
Palindrome number program in c
Palindrome number program in cPalindrome number program in c
Palindrome number program in c
 
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
 
Module 03 File Handling in C
Module 03 File Handling in CModule 03 File Handling in C
Module 03 File Handling in C
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Structure c
Structure cStructure c
Structure c
 
File in c
File in cFile in c
File in c
 
File handling in c
File handling in c File handling in c
File handling in c
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in C
 
C programs
C programsC programs
C programs
 
C Programming
C ProgrammingC Programming
C Programming
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Structure in c
Structure in cStructure in c
Structure in c
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Array in C
Array in CArray in C
Array in C
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Function in C program
Function in C programFunction in C program
Function in C program
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 

Similar to C programming language

C programming
C programmingC programming
C programming
PralhadKhanal1
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
Vigneshkumar Ponnusamy
 
C material
C materialC material
C material
tarique472
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
Vikram Nandini
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
GDGKuwaitGoogleDevel
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
Dr.Florence Dayana
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
JAYA
 
introductory concepts
introductory conceptsintroductory concepts
introductory conceptsWalepak Ubi
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
Likhil181
 
Basic Information About C language PDF
Basic Information About C language PDFBasic Information About C language PDF
Basic Information About C language PDF
Suraj Das
 
C language
C language C language
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
Muthuselvam RS
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
20EUEE018DEEPAKM
 
c-programming
c-programmingc-programming
c-programming
Zulhazmi Harith
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
sophoeutsen2
 
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
 
CSE 1201: Structured Programming Language
CSE 1201: Structured Programming LanguageCSE 1201: Structured Programming Language
CSE 1201: Structured Programming Language
Zubayer Farazi
 
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit DubeyMCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
kiranrajat
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
Janani Satheshkumar
 

Similar to C programming language (20)

C programming
C programmingC programming
C programming
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
 
C material
C materialC material
C material
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
introductory concepts
introductory conceptsintroductory concepts
introductory concepts
 
C notes
C notesC notes
C notes
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
Basic Information About C language PDF
Basic Information About C language PDFBasic Information About C language PDF
Basic Information About C language PDF
 
C language
C language C language
C language
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
c-programming
c-programmingc-programming
c-programming
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
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
 
CSE 1201: Structured Programming Language
CSE 1201: Structured Programming LanguageCSE 1201: Structured Programming Language
CSE 1201: Structured Programming Language
 
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit DubeyMCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
 

Recently uploaded

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 

Recently uploaded (20)

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 

C programming language

  • 2. INTRODUCTION TO C • It is a structured programming language used to develop operating system, business system, word processing, database system e.t.c • Developed by Dennis Ritchie at the Bell Laboratories in 1972 to develop the UNIX operating system. • At the time, Bell Labs had a programming language named B — B for Bell. The next language they created was C — one up on B. • C is the offspring of both the B programming language and a language named BCPL, which stood for Basic Combined Programming Language. • It is modular language. C code can be written in routines called functions. These functions can be reused in other applications or programs. • It is case sensitive language.
  • 4. 1. #include is known as a preprocessor directive. It tells the compiler to “include” text from another file, stuffing it right into source code. Doing this avoids lots of little, annoying errors. 2. <stdio.h> is a filename surrounded by angle brackets. The whole statement #include <stdio.h> tells the compiler to take text from the file STDIO.H and stick it into source code before the source code is compiled. The STDIO.H file itself contains information about the Standard Input/output functions required by most C programs. The H means “header.”
  • 5. 3. The int identifies the function main as an integer function, meaning that main() must return an integer value when it’s done. The function main, which also identifies the first and primary function inside the program. 4. Two empty parentheses follow the function name. 5. All functions in C have their contents encased by curly braces. 6. printf() job is to display information(output) on the screen. The added f means “formatted,”.
  • 6. 7. printf() has a set of parentheses, which consists of text, or a “string” of characters. Everything between the double quote characters (“) is part of printf’s text string. 8. ‘n’ called a newline in C are called wildcard characters. 9. The printf line, or statement, ends with a semicolon. The semicolon tells the C compiler where one statement ends and another begins. Note that all statements require semicolons in C, even if only one statement is in a program or function. 10. The return command sends the value 0 (zero) back to the operating system when the main() function is done. Returning a value is required as part of the main() function. This statement ends in a semicolon.
  • 7. QUIZ! 1. The core function in every C language program is called A. numero_uno(). B. main(). C. primus(). D. core(). 2. Functions require parentheses because A. They talk in whispers. B. The parentheses keep the function warm. C. The parentheses hold various things required by or belonging to the function. D. None
  • 9. VARIABLES • A variable is a named data storage location on computers memory. By using variable name on our program we are, in effect referring to the data stored there. • For many compilers, a variable name can be up to 31 character long. But it can be actually longer than that) • Rules for naming a variable:- • The name can contain letters, digit and the underscore character(_). • The first character of the name must be a letter. The underscore is also legal but it’s not recommended. • Case matters. • C keywords cannot be used as a variable name. • It should not contain any other special character than underscore(_). • A variable name mustn’t have any embedded space.
  • 10. • Declaring a variable:- • A variable declaration tells the compiler the name and the type of a variable and optionally initializes the variable to a specific value. • A variable declaration has following form:- Data_type_name variable name; Eg: int roll,num; float percentage; • Data Type: • The data type defines the values that needs to be stored in a program. • C supports mainly two type of data types: 1. Primary data types 2. Derived data types 3. User defined data type
  • 11. PRIMARY DATA TYPE Data type Data sub_type Bytes Format Range Character Signed 1 %c -128 to 127 Unsigned 1 %c 0 to 255 Numeric Sort Signed int 2 %d -32768 to 32767 Sort Unsigned int 2 %d 0 to 65535 Long Signed int 4 %1d -2147483648 to 2147483647 Long Unsigned int 4 %1d 0 to 4294967295 Float 4 %f 3.4E-38 to 3.4E+38 Double 8 %1f 3.7E-308 to 3.4E+308 Long double 10 %1f 3.4E-4932 to 3.4E + 4932
  • 12. • Derived Data Types: • Functions, arrays and pointers are derived data type. • User Defined Data Type: • The user defined datatype identifier can later be used to declare variables. • The user defined data types are: • Structure • Union • Enumeration
  • 13. CONSTANT • A constant is the fixed value that do not change during the execution of the program. • C supports four constants:- • Character • String • Integer • floating-point constants. • The numeric constants(integer and floating-point) must adhere following rules:- 1. Commas and blank spaces cannot be included within the constants. 2. The constant can be preceded by a minus(-) sign if desired. 3. The value of constant cannot exceed specified minimum and maximum bounds
  • 14. QUIZ 1. Which of the following variable name is not a valid variable name? a) Annual_profit b) _2009_tax c) Saving#account d) Year2x5_abc 2. How many bytes of memory does a double data type take ? a) -32768 to 32767 b) 0 to 255 c) 4 d) 8
  • 15. 1. Which of the valid format specifier for string type value? a) %d b) %c c) %st d) %s 2. What is the range of short signed Integer? a) -32768 to 32767 b) 0 to 255 c) 0 to 65535 d) 3.7E-308 to 3.4E+308
  • 17. OPERATOR • Operator is a symbol which helps the user to command the computer to do certain mathematical or logical manipulation. • Types of operator • Arithmetic Operator • Assignment Operator • Unary Operator • Relational Operator • Logical Operator • Ternary operator • Comma Operator • Bitwise Operator • Size of Operator
  • 18. 1) Arithmetic Operator Basic mathematical operation. Operator Symbol Addition + Subtraction - Multiplication * Division / Modulus % (Returns Reminder) 2) Assignment Operator Is used to assign Values. Some of them are =,+=,-=,*=,/=,%=
  • 19. 3. Unary Operator: • It is so called because they take a single operand. It acts upon single operand to be increased or decreased by one. • Operator Symbol action Example Increment ++ Increments the operand by one x++,++x Decrement -- Decrements the operand by one x--,--x • They differ in which mode they are used. • When used in prefix mode, the increment and decrement operators modify their operand before it’s used. • When Used in postfix mode, the increment and decrement operators modify their operand after it’s use.
  • 20. 4. Relational Operator:- It is used to compare expressions. An expression containing a relational operator evaluates to either true or false. Operator Symbol Equal == Greater than > Less than < Grater than or equal to >= Less than or equal to <= Not Equal !=
  • 21. 5. Logical Operator:- It let’s us to combine two or more relational expression into a single expression that evaluates to either true or false. Operator Symbol AND && OR || NOT ! 6. Ternary Operator:- It is used to check certain relational expression and execute the true statement if the condition is true and display if the condition is false. Syntax: [condition] ? [true statement]:[false statement] Example: a>b ? printf (“a is greater”) : printf (“b is greater”);
  • 22. 7. Bitwise Operator:- These operators are used for having bit level computations of different values. Operator Meaning & bitwise AND | bitwise OR ^ bitwise exclusive OR >> shift cells right >> shift cells left - one’s complement 6. Size of () Operator:- Returns the number of bytes occupied in the memory Syntax: sizeof(datatype/variable); Example: sizeof(int);
  • 23. ESCAPE SEQUENCE • These are characters not printed when used but provide various functions. These are always started with a backslash ‘’. Commonly Used are:- • Constant Meaning ‘a’ Audible Alert ‘b’ backspace ‘f’ Form feed ‘n’ New Line ‘r’ Carriage Return ‘t’ Horizontal Tab ‘V’ Vertical Tab ‘’’ Single quote ‘”’ Double quote ‘?’ Question mark ‘’ Back slash ‘0’ Null
  • 24. HEADER FILES • Header File contains definition of functions and variables which can be incorporated into any c program by using the preprocessor #include statement. All header files have the extension .h. • Some commonly used Header files: • Stdio.h : It contains the standard input and output functions like printf(), scanf(),gets(),puts() etc. • Conio.h : It contains some of the functions like getch(), clrscr() etc. • Math.h : It contains the mathematical functions like strlen(), strcpy(), strcmp(), strrev() etc. • Ctype.h : it contains some validating functions like isdigit(), isalnum(), isalpha() and some converting functions like toupper(), tolower() etc.
  • 26. • WAP to calculate the area and circumference of a circle . Where radius of a circle is input by user and define pi as constant. • WAP to read principle, time and rate to calculate the simple interest and total amount . • WAP to convert temperature in Fahrenheit into centigrade and vice versa. • WAP to ask cost of pen in Paisa. Convert it into nearest rupees and paisa. • WAP to enter distance between two cities in KM and convert it into meter, centimeter, inch and feet. • WAP to enter any 4 digit number and find the sum of the first and last digit of the number.[e.g. Any four digit number =4567, sum =4+7]. • WAP to supply length and breadth of a rectangle. Find out area and perimeter.
  • 27. • WAP to find total and percentage of the students whose marks are as follows: • WAP to enter 4 digit number and find the sum of them.[e.g. 1234=1+2+3+4=10]. • WAP to interchange the contents of x and y after entering the value of x and y • WAP to read the radius of the sphere and find the volume and area of it. Subjects Marks English 65 Nepali 75 Computer Science 70 Math 80 Account 60
  • 28. • WAP to find the area of triangle after reading the value of base and height. • WAP to find the compound interest. The value principle, time and interest rate is given by user. • WAP to find the area of a triangle, if the length of the side of a triangle are denoted by a, b, c then area of triangle id given by Area= 𝒔 𝒔 − 𝒂 𝒔 − 𝒃 𝒔 − 𝒄 𝐰𝐡𝐞𝐫𝐞 𝒔 = (𝒂+𝒃+𝒄) 𝟐 . • Basic salary of Sabin is input through keyboard. His medical allowance is 10% of the basic salary and provident fund is 10% of the basic salary. WAP to find his net salary. • WAP to solve the quadratic equation a𝒙 𝟐 + b𝒙 + 𝒄 = 𝟎 , 𝒘𝒉𝒆𝒓𝒆 x= −𝒃±𝒃 𝟐−𝟒𝒂𝒄 𝟐𝒂