SlideShare a Scribd company logo
1 of 40
Programming Basics
Introduction to C programming
How does a program run?
● Step 1 → Write lines of codes.
● Step 2 → Compile.
● Step 3 → Execute.
● Step 4 → Get the output.
IDE vs Compiler
● IDE – Integrated Development Environment
● Compiler → translates to machine level(01010)
A basic C program
Hello World in Detail :
● stdio.h is a header file
● #include is a preprocessor directive.
● int main() : where the program execution
begins.
● { and } symbols mark the beginning and end of
a block of code.
● return 0; terminates the main() function
Identifiers
● name given to entities such as variables,
functions.
● Example - int money ;
● int money;
Here, money is identifier.
● must be different from keywords
Keywords
● predefined, reserved words.
● Example : int money;
int is a keyword .
Variable
● a variable is a container to hold data.
● Example: int score = 95;
Rules for naming a variable
● can have letters , digits and underscore only.
● The first letter of a variable should be either a
letter or an underscore
Data Types in C
Integer
● positive and negative values but no decimal
values. Eg : 0, -5, 10 .
● Int id ;
● Here, id is a variable of type integer.
● Int id,age;
Floating types
● can hold real numbers such as: 2.34, -9.382,
5.0 etc.
● float price; // 4 bytes size
● double price; // 8 bytes size
● Both are floating types.
Character types
● Keyword char is used for declaring such
variables.
● char test = 'h';
● test is a character variable.
● The value of test is 'h'.
● No string type in C . alternative = char array
● Eg: char num[ ] = “hello”
I/O in C programming
● Two commonly used functions are printf() and
scanf().
● Function scanf() reads input.
● Function printf() prints output.
Format specifiers and ampersand
● scanf("%d”,&a); for int , &a means the address
of variable a
● scanf("%f”,&a); for float
● Scanf(“%c”,&ch);
● Scanf(“%s”,&word);
● printf("%d is value of a",a);
Operators
● to perform tasks including arithmetic, conditional and bitwise
operations
● Types :
1. Arithmetic Operators
2. Increment and Decrement Operators
3. Assignment Operators
4. Relational Operators
5. Logical Operators
6. Others (Conditional,Bitwise and Special Operators)
Arithmetic Operators
Increment and decrement operators
● Increment ++ increases the value by 1
● Decrement -- decreases the value by 1
● Example :
int a=5;
a++ . value of a is now 6
● Similarly, for a-- , a is 4
++ and -- operator as prefix and
postfix
● Postfix a++ → original value of a is returned
first then, a is incremented by 1.
● Prefix ++a → value of a is incremented by 1
then, it returns the value.
Assignment Operators
Relational Operators
Logical Operators
Decision Making
● If else
● Nested if else
● Loops
if and if else statement
1 . if (testExpression)
{
// statements
}
2 . if (testExpression) {
// codes inside the body of if
}
else {
// codes inside the body of else
}
Flowcharts of if and if else
Nested if...else statement
if (testExpression1)
{ // statements to be executed if testExpression1 is true
}
else if(testExpression2)
{ // to be executed if testExpression1 is false and testExpression2 is true
}
...
else
{ // statements to be executed if all test expressions are false
}
Loops
● are used to repeat a specific block of code.
● Types -
1 . for loop
2 . while loop
3 . do while loop
For loop
for (initializationStatement; testExpression;
updateStatement)
{
// codes
}
While loop
while (testExpression)
{
//codes
}
Do while loop
do
{
// codes
}
while (testExpression);
Break and continue statement
● Break→ terminates the loop
● Continue → skips some statement
● Syntax :
break;
continue;
Switch case
switch (n)
{
case constant1:
// code to be executed if n is equal to constant1;
break;
case constant2:
// code to be executed if n is equal to constant2;
break;
. . .
default:
// code to be executed if n doesn't match any constant
}
Functions
● a block of code that performs a specific task.
● Two types of functions :
1 . User defined functions
2 . Standard library functions
Standard library functions
● built-in functions
● handle tasks such as mathematical
computations, I/O processing, etc.
● Example : printf() and scanf()
User defined functions
Advantage of user defined functions
● Clean,easier to maintain.
● Reusability.
● Easy to debug.

More Related Content

What's hot

Spf Chapter5 Conditional Logics
Spf Chapter5 Conditional LogicsSpf Chapter5 Conditional Logics
Spf Chapter5 Conditional LogicsHock Leng PUAH
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage classkapil078
 
[C++ korea] effective modern c++ study item 3 understand decltype +이동우
[C++ korea] effective modern c++ study   item 3 understand decltype +이동우[C++ korea] effective modern c++ study   item 3 understand decltype +이동우
[C++ korea] effective modern c++ study item 3 understand decltype +이동우Seok-joon Yun
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3Ibrahim Reda
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C Self employed
 
04a intro while
04a intro while04a intro while
04a intro whilehasfaa1017
 
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYRajeshkumar Reddy
 
C program language tutorial for loop while loop do while loop
C program language tutorial for loop while loop do while loopC program language tutorial for loop while loop do while loop
C program language tutorial for loop while loop do while loopSourav Ganguly
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c languagesneha2494
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statementsSaad Sheikh
 
11 2. variable-scope rule,-storage_class
11 2. variable-scope rule,-storage_class11 2. variable-scope rule,-storage_class
11 2. variable-scope rule,-storage_class웅식 전
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13Chris Ohk
 
java in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariyajava in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariyaviratandodariya
 
Php Inspections (EA Extended): if-conditions optimization
Php Inspections (EA Extended): if-conditions optimizationPhp Inspections (EA Extended): if-conditions optimization
Php Inspections (EA Extended): if-conditions optimizationVladimir Reznichenko
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Muhammad Tahir Bashir
 
Spf Chapter4 Variables
Spf Chapter4 VariablesSpf Chapter4 Variables
Spf Chapter4 VariablesHock Leng PUAH
 

What's hot (19)

Spf Chapter5 Conditional Logics
Spf Chapter5 Conditional LogicsSpf Chapter5 Conditional Logics
Spf Chapter5 Conditional Logics
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
 
[C++ korea] effective modern c++ study item 3 understand decltype +이동우
[C++ korea] effective modern c++ study   item 3 understand decltype +이동우[C++ korea] effective modern c++ study   item 3 understand decltype +이동우
[C++ korea] effective modern c++ study item 3 understand decltype +이동우
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
Storage classes
Storage classesStorage classes
Storage classes
 
04a intro while
04a intro while04a intro while
04a intro while
 
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
 
Loops in c
Loops in cLoops in c
Loops in c
 
C program language tutorial for loop while loop do while loop
C program language tutorial for loop while loop do while loopC program language tutorial for loop while loop do while loop
C program language tutorial for loop while loop do while loop
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
11 2. variable-scope rule,-storage_class
11 2. variable-scope rule,-storage_class11 2. variable-scope rule,-storage_class
11 2. variable-scope rule,-storage_class
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
 
java in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariyajava in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariya
 
Php Inspections (EA Extended): if-conditions optimization
Php Inspections (EA Extended): if-conditions optimizationPhp Inspections (EA Extended): if-conditions optimization
Php Inspections (EA Extended): if-conditions optimization
 
Storage classes
Storage classesStorage classes
Storage classes
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
 
Spf Chapter4 Variables
Spf Chapter4 VariablesSpf Chapter4 Variables
Spf Chapter4 Variables
 

Similar to Programming basics

C programing Tutorial
C programing TutorialC programing Tutorial
C programing TutorialMahira Banu
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to cSadhanaParameswaran
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Rasan Samarasinghe
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxLikhil181
 
C_BASICS FOR C PROGRAMMER WITH SRIVATHS P
C_BASICS FOR C PROGRAMMER WITH  SRIVATHS PC_BASICS FOR C PROGRAMMER WITH  SRIVATHS P
C_BASICS FOR C PROGRAMMER WITH SRIVATHS Pamankr1234am
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginnersophoeutsen2
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.Haard Shah
 
Lecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageLecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageSURAJ KUMAR
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniquesvalarpink
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)jakejakejake2
 
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 Dubeykiranrajat
 

Similar to Programming basics (20)

Dart workshop
Dart workshopDart workshop
Dart workshop
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
C programming session3
C programming  session3C programming  session3
C programming session3
 
C programming session3
C programming  session3C programming  session3
C programming session3
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to c
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptx
 
C_BASICS FOR C PROGRAMMER WITH SRIVATHS P
C_BASICS FOR C PROGRAMMER WITH  SRIVATHS PC_BASICS FOR C PROGRAMMER WITH  SRIVATHS P
C_BASICS FOR C PROGRAMMER WITH SRIVATHS P
 
Lec 10
Lec 10Lec 10
Lec 10
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
 
Python ppt
Python pptPython ppt
Python ppt
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Lecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageLecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming Language
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)
 
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
 

Recently uploaded

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 

Recently uploaded (20)

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 

Programming basics

  • 2. How does a program run? ● Step 1 → Write lines of codes. ● Step 2 → Compile. ● Step 3 → Execute. ● Step 4 → Get the output.
  • 3. IDE vs Compiler ● IDE – Integrated Development Environment ● Compiler → translates to machine level(01010)
  • 4. A basic C program
  • 5. Hello World in Detail : ● stdio.h is a header file ● #include is a preprocessor directive. ● int main() : where the program execution begins. ● { and } symbols mark the beginning and end of a block of code. ● return 0; terminates the main() function
  • 6. Identifiers ● name given to entities such as variables, functions. ● Example - int money ; ● int money; Here, money is identifier. ● must be different from keywords
  • 7. Keywords ● predefined, reserved words. ● Example : int money; int is a keyword .
  • 8. Variable ● a variable is a container to hold data. ● Example: int score = 95;
  • 9. Rules for naming a variable ● can have letters , digits and underscore only. ● The first letter of a variable should be either a letter or an underscore
  • 11. Integer ● positive and negative values but no decimal values. Eg : 0, -5, 10 . ● Int id ; ● Here, id is a variable of type integer. ● Int id,age;
  • 12. Floating types ● can hold real numbers such as: 2.34, -9.382, 5.0 etc. ● float price; // 4 bytes size ● double price; // 8 bytes size ● Both are floating types.
  • 13. Character types ● Keyword char is used for declaring such variables. ● char test = 'h'; ● test is a character variable. ● The value of test is 'h'. ● No string type in C . alternative = char array ● Eg: char num[ ] = “hello”
  • 14. I/O in C programming ● Two commonly used functions are printf() and scanf(). ● Function scanf() reads input. ● Function printf() prints output.
  • 15. Format specifiers and ampersand ● scanf("%d”,&a); for int , &a means the address of variable a ● scanf("%f”,&a); for float ● Scanf(“%c”,&ch); ● Scanf(“%s”,&word); ● printf("%d is value of a",a);
  • 16. Operators ● to perform tasks including arithmetic, conditional and bitwise operations ● Types : 1. Arithmetic Operators 2. Increment and Decrement Operators 3. Assignment Operators 4. Relational Operators 5. Logical Operators 6. Others (Conditional,Bitwise and Special Operators)
  • 18. Increment and decrement operators ● Increment ++ increases the value by 1 ● Decrement -- decreases the value by 1 ● Example : int a=5; a++ . value of a is now 6 ● Similarly, for a-- , a is 4
  • 19. ++ and -- operator as prefix and postfix ● Postfix a++ → original value of a is returned first then, a is incremented by 1. ● Prefix ++a → value of a is incremented by 1 then, it returns the value.
  • 23. Decision Making ● If else ● Nested if else ● Loops
  • 24. if and if else statement 1 . if (testExpression) { // statements } 2 . if (testExpression) { // codes inside the body of if } else { // codes inside the body of else }
  • 25. Flowcharts of if and if else
  • 26. Nested if...else statement if (testExpression1) { // statements to be executed if testExpression1 is true } else if(testExpression2) { // to be executed if testExpression1 is false and testExpression2 is true } ... else { // statements to be executed if all test expressions are false }
  • 27. Loops ● are used to repeat a specific block of code. ● Types - 1 . for loop 2 . while loop 3 . do while loop
  • 28. For loop for (initializationStatement; testExpression; updateStatement) { // codes }
  • 29.
  • 31.
  • 32. Do while loop do { // codes } while (testExpression);
  • 33.
  • 34. Break and continue statement ● Break→ terminates the loop ● Continue → skips some statement ● Syntax : break; continue;
  • 35.
  • 36. Switch case switch (n) { case constant1: // code to be executed if n is equal to constant1; break; case constant2: // code to be executed if n is equal to constant2; break; . . . default: // code to be executed if n doesn't match any constant }
  • 37. Functions ● a block of code that performs a specific task. ● Two types of functions : 1 . User defined functions 2 . Standard library functions
  • 38. Standard library functions ● built-in functions ● handle tasks such as mathematical computations, I/O processing, etc. ● Example : printf() and scanf()
  • 40. Advantage of user defined functions ● Clean,easier to maintain. ● Reusability. ● Easy to debug.