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
Ad

More Related Content

What's hot (20)

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
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
Gilbert NZABONITEGEKA
 
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 language
Kumar 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
 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - language
Jussi Pohjolainen
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
gajendra singh
 
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
 
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
 
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
 
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
 
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
Kumar Gaurav
 
OpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
Open Gurukul
 
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
 

Viewers also liked (20)

week-20x
week-20xweek-20x
week-20x
KITE www.kitecolleges.com
 
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
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
Tony Kurishingal
 
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 programs
Minu 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
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
Function in C program
Function in C programFunction in C program
Function in C program
Nurul Zakiah Zamri Tan
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
CSS ppt
CSS pptCSS ppt
CSS ppt
Sanmuga Nathan
 
Ad

Similar to C programming language (20)

Unit No 2.pptx Basic s of C Programming
Unit No 2.pptx   Basic s of C ProgrammingUnit No 2.pptx   Basic s of C Programming
Unit No 2.pptx Basic s of C Programming
Vaibhav Parjane
 
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
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
 
Fundamentals of computers - C Programming
Fundamentals of computers - C ProgrammingFundamentals of computers - C Programming
Fundamentals of computers - C Programming
MSridhar18
 
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
 
datypes , operators in c,variables in clanguage formatting input and out put
datypes , operators in c,variables in clanguage formatting input  and out putdatypes , operators in c,variables in clanguage formatting input  and out put
datypes , operators in c,variables in clanguage formatting input and out put
MdAmreen
 
programming for problem solving in C and C++.pptx
programming for problem solving in C and C++.pptxprogramming for problem solving in C and C++.pptx
programming for problem solving in C and C++.pptx
BamaSivasubramanianP
 
Module_1_Introduction-to-Problem-Solving.pdf
Module_1_Introduction-to-Problem-Solving.pdfModule_1_Introduction-to-Problem-Solving.pdf
Module_1_Introduction-to-Problem-Solving.pdf
MaheshKini3
 
#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 concepts
Walepak Ubi
 
The New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of theThe New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of the
shubhamgupta7133
 
C Programming Language Introduction and C Tokens.pdf
C Programming Language Introduction and C Tokens.pdfC Programming Language Introduction and C Tokens.pdf
C Programming Language Introduction and C Tokens.pdf
poongothai11
 
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
RutviBaraiya
 
C notes
C notesC notes
C notes
Raunak Sodhi
 
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
 
Unit No 2.pptx Basic s of C Programming
Unit No 2.pptx   Basic s of C ProgrammingUnit No 2.pptx   Basic s of C Programming
Unit No 2.pptx Basic s of C Programming
Vaibhav Parjane
 
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
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
 
Fundamentals of computers - C Programming
Fundamentals of computers - C ProgrammingFundamentals of computers - C Programming
Fundamentals of computers - C Programming
MSridhar18
 
datypes , operators in c,variables in clanguage formatting input and out put
datypes , operators in c,variables in clanguage formatting input  and out putdatypes , operators in c,variables in clanguage formatting input  and out put
datypes , operators in c,variables in clanguage formatting input and out put
MdAmreen
 
programming for problem solving in C and C++.pptx
programming for problem solving in C and C++.pptxprogramming for problem solving in C and C++.pptx
programming for problem solving in C and C++.pptx
BamaSivasubramanianP
 
Module_1_Introduction-to-Problem-Solving.pdf
Module_1_Introduction-to-Problem-Solving.pdfModule_1_Introduction-to-Problem-Solving.pdf
Module_1_Introduction-to-Problem-Solving.pdf
MaheshKini3
 
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 concepts
Walepak Ubi
 
The New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of theThe New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of the
shubhamgupta7133
 
C Programming Language Introduction and C Tokens.pdf
C Programming Language Introduction and C Tokens.pdfC Programming Language Introduction and C Tokens.pdf
C Programming Language Introduction and C Tokens.pdf
poongothai11
 
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
RutviBaraiya
 
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
 
Ad

Recently uploaded (20)

Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 

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= −𝒃±𝒃 𝟐−𝟒𝒂𝒄 𝟐𝒂
  翻译: