SlideShare a Scribd company logo
1 of 40
Fundamental structure
of programming in 'c'
Presented by:
Mr. Yogesh Kumar
M.Sc. I Sem.(Bioinformatics)
‘C’ language is simple as compare to the English language
Here is steps comparison…
Steps in learning English language
Steps in learning ‘c’
alphabets words sentences paragraph
Alphabets , digits
Special symbols
Constants,
variables
keywords
instructi
ons
program
Before planning a program we need to define its logic
(the correct sequence of instructions need to solve the
problem at hand).the term algorithm is often used to
refer to the logic of a program.
It is a step by step description of how to arrive at the
solution of the given problem.(exp..)
*Write a program to find the larger of two given numbers.
Algorithm.
1.Input two numbers a and b
2.Assign big=a
3. If (b>big)the big=b
4.Output big
5.stop
 Flowchart is the diagrammatic representation of
programs and algorithm . it is generally used to
understand the program and to solve the program
 It uses boxes of different shapes to denote different
types of instructions.
 The process of drawing a flowchart for an algorithm is
often referred to flowcharting
Only a few symbols are needed to indicate the necessary
operations in a flowchart. These basic flowchart symbols
have been standardized by the American National
standards institute (ANSI).
As shown……
flow lines
connector
start processing Input/output
decision
example.1
no
yes
start
Read
num
i=1
Is
i<=10
Write
(i*num)
i=i+1
stop
Tokens in ‘c’
 The alphabets ,numbers and special symbols when
properly combined form constants , variables &
keywords
 Alphabets A,B,C………..Z
a , b, c ……....z
 Digits 0,1,2,3……….9
 Special symbols ~, ’, !, @, #, %, ^, &, =,|,?, /,
[ ] : ; ””,’ <> ., { }
Constant, variables & keywords
3
5
PRIMARY CONSTANT
 Integer constant
 Real constant
 Character constant
 Array
 Pointer
 Structure
 Union
 Enum.etc
SECONDARY CONSTANT
As we saw earlier , an entity that may vary during program
execution is called a variable.
 Type of variable used in program depend on the type of
constant stored in it.
 Float/real, integer ,or character constant
 Variable name are name given to locations in memory
Exp….
float=6.0 (4 byte)
Int =6 (2 byte)
char=‘a’ (1 byte)
 Keywords are the words whose meaning has already been
explained to the c compiler
 The keywords cannot be used as variable name if we do so,
we are typing to assign new value to keywords which is not
allowed by compiler
 There are 32 keywords available in c
 Some are …….
short return double switch register signed
long void float union static unsigned
int break if goto continue volatile
char default for do sizeof enum
else case while auto extern typedef ..etc
• structure
•class
• integer
• float
•Character (char)
•int %d
•float %f
•char %c
•Array
•Pointer
•Function
•String
DATA TYPES
User define data type Fundamental data type Derived data type
Arithmetic operators
+
-
*
/
%
purpose
Addition
Subtraction
Multiplication
Division
Remainder after
division
example
7+5=12
7-5=2
7*5=35
8/2=4
7%5=2
ARITHMETIC OPERATORS
&& Means logical AND
|| Means logical OR
! Means logical NOT
LOGICAL OPERATOR
RELATIONAL OPERATORS
> Means greater than
< Means less than
== Means equal to
>= Means greater than equal to
<= Means less than equal to
!= Means not equals to
 The general form of if statement is
if ( condition)
{
Statement-block
}
If condition is true the statement block will executed
otherwise the statement block will skipped.
#include<stdio.h>
#include<conio.h>
void main()
{
float a,b,big;
printf(“enter two numbersn”);
scanf(“%f%f”,&a,&b);
big=a;
if(b>big) big=b;
printf(“larger number is:%f”,big);
}
RUN
Enter two numbers
12.5 45.0
Larger number is 45.0
ENTER
false
true
next statement
condition
Statement-block
if (condition)
{
statement-1;
}
else
{
statement-2;
}
enter
false true
next statement
Condition
?
Statement-1
Statement-2
The switch statement test the value of given expression
against a list of case values
General form
switch(expression)
{
case val-1:
statement-1
break;
case val-2:
statement-2;
break;
default:
default-statement;
break;
#include<stdio.h>
#include<conio.h>
void main()
{
char grade;
switch(grade)
{
case ‘A’:
printf(“passed with first division”);
break;
case ‘B’:
printf(“passed with second division”);
break;
case ‘C’:
printf(“conditional pass”;
break;
default:
printf(“fail”);
break;
}
getch();
}
 There are two types of repetitive structures
1. Conditional controlled (in this body is repetitively
executed until the given condition become true)
a) while statement
b) do while statement
2. Counter controlled (in this the number of time the set of
statement is executed ex.. )For loop
a) while statement
while(condition)
{
Statement(s);
}
1. evaluate the condition.
2. If the condition true then execute the statement(s)and repeat step 1.
3. If the condition is false then the control is transferred out of loop.
Exp…..
#include<stdio.h>
main()
{
int num=1,s=0;
While(num<=10)
{
sum +=num;
num+1=1;
}
printf(“sum of first 10 natural numbers : %d ”, s);
getch();
}
RUN
Sum of first 10 natural num is : 55
The sequence of operation in while loop
no
yes
start
Read
num
i=1
Is
i<=10
Write
(i*num)
i=i+1
stop
In while statement, condition is evaluated first. Therefore
the body of loop may not be executed at all if condition
is not satisfied at the very first attempt. But in do loop,
condition is evaluated at the end. Therefore the body of
the loop is executed at lest once in this statement
The general form of this statement is..
do
{
Statement(s);
}
while (condition);
printf(“…………….”);
}
Do while statement
#include<stdio.>
main( )
{
int num=1,s=0;
do
{
s +=num;
num +=1;
}
while(num<=10);
printf(“sum of first natural no is %d”,s) ;
getch();
}
Run:
Sum of 10 natural number is 55.
(do while )..exp..sum of first 10 natural number
• The difference b/w. while & do while loop
I. In while the condition is tested before executing
body of loop. /In do while the condition is tested
after executing the body
II. Body of do loop is executed at lest once but body of
while loop may not be executed at all. /In while , If
initial the condition is not satisfied the loop will
to get executed even once
 There are situation where you want to have a
statement or group of statements to be executed
numbers of time and the number of repetition does
not depend on the condition but it is simply a
repetition up to a certain numbers. The best way of
repetition is a for loop. The general form of the loop
for single statement is:
for ( initialization ; condition ; increment)
{
statement(s);
}
#include<stdio.h>
main( )
{
int I,s=0;
for (i=1;1<=10;i++)
s=s+1;
printf(“sum of first natural number is:%d”,s);
getch( );
}
Run:
Sum of first 10 natural number is : 55
Loop construct can be nested or embedded within one
another. The inner loop must be completely embedded
with the outer loop . There should no overlapping of loops.
**Demonstration of nested loops**
#include<stdio.h>
void main()
{
int r,c,sum;
for (r=1;r<=3;r++) /*outer loop*/
{
for(c=1;c<=2;c++) /*inner loop*/
{
sum=r+c;
printf(“r=%d c=%d sum=%dn”,r,c,sum);
}}
getch();
}
Output
r=1 c=1 sum=2
r=1 c=2 sum=3
r=2 c=1 sum=3
r=2 c=2 sum=4
The loop that we have used so far executed the statements within them a finite number of
times. However, in real life programming, one comes across a situation when it is not
known beforehand how many times the statements in the loop are to be executed. This
situation can be programmed as shown below:
/* execution of a loop an unknown number of times*/
#include<stdio.h>
void main()
{
Char another;
Int num;
do
{
printf(“enter a number”);
scanf(“%d”,&num);
printf(“square of%d is %d”, num, num*num);
Printf(“n want to enter another number y/n”);
Scanf(“%c”,&another);
}while(another==‘y’);
}
getch();
}
Output
Enter a number 5
Square of 5 is 25
Want to enter another number y/n y
Enter a number 7
Square of 7 is 49
Want to enter anotehr number y/n n
THANK YOU ……. .
Claguage 110226222227-phpapp02

More Related Content

What's hot

Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsDhivyaSubramaniyam
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C LanguageShaina Arora
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CSowmya Jyothi
 
Learning C programming - from lynxbee.com
Learning C programming - from lynxbee.comLearning C programming - from lynxbee.com
Learning C programming - from lynxbee.comGreen Ecosystem
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c languagetanmaymodi4
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programmingRabin BK
 
Control Structures
Control StructuresControl Structures
Control StructuresGhaffar Khan
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statementnarmadhakin
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controlsvinay arora
 
Programming C Language
Programming C LanguageProgramming C Language
Programming C Languagenatarafonseca
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements Tarun Sharma
 

What's hot (19)

Control structures in c
Control structures in cControl structures in c
Control structures in c
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and Functions
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Control Structures: Part 1
Control Structures: Part 1Control Structures: Part 1
Control Structures: Part 1
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 
Learning C programming - from lynxbee.com
Learning C programming - from lynxbee.comLearning C programming - from lynxbee.com
Learning C programming - from lynxbee.com
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
Control Structures
Control StructuresControl Structures
Control Structures
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
 
Programming C Language
Programming C LanguageProgramming C Language
Programming C Language
 
Lecture 9- Control Structures 1
Lecture 9- Control Structures 1Lecture 9- Control Structures 1
Lecture 9- Control Structures 1
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
Ch6 Loops
Ch6 LoopsCh6 Loops
Ch6 Loops
 
Lecture 11 - Functions
Lecture 11 - FunctionsLecture 11 - Functions
Lecture 11 - Functions
 

Similar to Claguage 110226222227-phpapp02

Similar to Claguage 110226222227-phpapp02 (20)

C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
What is c
What is cWhat is c
What is c
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
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
 
C tutorial
C tutorialC tutorial
C tutorial
 
C operators
C operatorsC operators
C operators
 
C fundamental
C fundamentalC fundamental
C fundamental
 
Programming in C
Programming in CProgramming in C
Programming in C
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
 
What is c
What is cWhat is c
What is c
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
C tutorial
C tutorialC tutorial
C tutorial
 

Recently uploaded

GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 

Recently uploaded (20)

GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 

Claguage 110226222227-phpapp02

  • 1. Fundamental structure of programming in 'c' Presented by: Mr. Yogesh Kumar M.Sc. I Sem.(Bioinformatics)
  • 2. ‘C’ language is simple as compare to the English language Here is steps comparison… Steps in learning English language Steps in learning ‘c’ alphabets words sentences paragraph Alphabets , digits Special symbols Constants, variables keywords instructi ons program
  • 3. Before planning a program we need to define its logic (the correct sequence of instructions need to solve the problem at hand).the term algorithm is often used to refer to the logic of a program. It is a step by step description of how to arrive at the solution of the given problem.(exp..) *Write a program to find the larger of two given numbers. Algorithm. 1.Input two numbers a and b 2.Assign big=a 3. If (b>big)the big=b 4.Output big 5.stop
  • 4.  Flowchart is the diagrammatic representation of programs and algorithm . it is generally used to understand the program and to solve the program  It uses boxes of different shapes to denote different types of instructions.  The process of drawing a flowchart for an algorithm is often referred to flowcharting
  • 5. Only a few symbols are needed to indicate the necessary operations in a flowchart. These basic flowchart symbols have been standardized by the American National standards institute (ANSI). As shown…… flow lines connector start processing Input/output decision
  • 8.  The alphabets ,numbers and special symbols when properly combined form constants , variables & keywords  Alphabets A,B,C………..Z a , b, c ……....z  Digits 0,1,2,3……….9  Special symbols ~, ’, !, @, #, %, ^, &, =,|,?, /, [ ] : ; ””,’ <> ., { } Constant, variables & keywords
  • 9. 3 5
  • 10. PRIMARY CONSTANT  Integer constant  Real constant  Character constant  Array  Pointer  Structure  Union  Enum.etc SECONDARY CONSTANT
  • 11. As we saw earlier , an entity that may vary during program execution is called a variable.  Type of variable used in program depend on the type of constant stored in it.  Float/real, integer ,or character constant  Variable name are name given to locations in memory Exp…. float=6.0 (4 byte) Int =6 (2 byte) char=‘a’ (1 byte)
  • 12.  Keywords are the words whose meaning has already been explained to the c compiler  The keywords cannot be used as variable name if we do so, we are typing to assign new value to keywords which is not allowed by compiler  There are 32 keywords available in c  Some are ……. short return double switch register signed long void float union static unsigned int break if goto continue volatile char default for do sizeof enum else case while auto extern typedef ..etc
  • 13. • structure •class • integer • float •Character (char) •int %d •float %f •char %c •Array •Pointer •Function •String DATA TYPES User define data type Fundamental data type Derived data type
  • 14.
  • 16. && Means logical AND || Means logical OR ! Means logical NOT LOGICAL OPERATOR
  • 17. RELATIONAL OPERATORS > Means greater than < Means less than == Means equal to >= Means greater than equal to <= Means less than equal to != Means not equals to
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.  The general form of if statement is if ( condition) { Statement-block } If condition is true the statement block will executed otherwise the statement block will skipped.
  • 23. #include<stdio.h> #include<conio.h> void main() { float a,b,big; printf(“enter two numbersn”); scanf(“%f%f”,&a,&b); big=a; if(b>big) big=b; printf(“larger number is:%f”,big); } RUN Enter two numbers 12.5 45.0 Larger number is 45.0
  • 27. The switch statement test the value of given expression against a list of case values General form switch(expression) { case val-1: statement-1 break; case val-2: statement-2; break; default: default-statement; break;
  • 28. #include<stdio.h> #include<conio.h> void main() { char grade; switch(grade) { case ‘A’: printf(“passed with first division”); break; case ‘B’: printf(“passed with second division”); break; case ‘C’: printf(“conditional pass”; break; default: printf(“fail”); break; } getch(); }
  • 29.  There are two types of repetitive structures 1. Conditional controlled (in this body is repetitively executed until the given condition become true) a) while statement b) do while statement 2. Counter controlled (in this the number of time the set of statement is executed ex.. )For loop a) while statement while(condition) { Statement(s); }
  • 30. 1. evaluate the condition. 2. If the condition true then execute the statement(s)and repeat step 1. 3. If the condition is false then the control is transferred out of loop. Exp….. #include<stdio.h> main() { int num=1,s=0; While(num<=10) { sum +=num; num+1=1; } printf(“sum of first 10 natural numbers : %d ”, s); getch(); } RUN Sum of first 10 natural num is : 55 The sequence of operation in while loop
  • 32. In while statement, condition is evaluated first. Therefore the body of loop may not be executed at all if condition is not satisfied at the very first attempt. But in do loop, condition is evaluated at the end. Therefore the body of the loop is executed at lest once in this statement The general form of this statement is.. do { Statement(s); } while (condition); printf(“…………….”); } Do while statement
  • 33. #include<stdio.> main( ) { int num=1,s=0; do { s +=num; num +=1; } while(num<=10); printf(“sum of first natural no is %d”,s) ; getch(); } Run: Sum of 10 natural number is 55. (do while )..exp..sum of first 10 natural number
  • 34. • The difference b/w. while & do while loop I. In while the condition is tested before executing body of loop. /In do while the condition is tested after executing the body II. Body of do loop is executed at lest once but body of while loop may not be executed at all. /In while , If initial the condition is not satisfied the loop will to get executed even once
  • 35.  There are situation where you want to have a statement or group of statements to be executed numbers of time and the number of repetition does not depend on the condition but it is simply a repetition up to a certain numbers. The best way of repetition is a for loop. The general form of the loop for single statement is: for ( initialization ; condition ; increment) { statement(s); }
  • 36. #include<stdio.h> main( ) { int I,s=0; for (i=1;1<=10;i++) s=s+1; printf(“sum of first natural number is:%d”,s); getch( ); } Run: Sum of first 10 natural number is : 55
  • 37. Loop construct can be nested or embedded within one another. The inner loop must be completely embedded with the outer loop . There should no overlapping of loops. **Demonstration of nested loops** #include<stdio.h> void main() { int r,c,sum; for (r=1;r<=3;r++) /*outer loop*/ { for(c=1;c<=2;c++) /*inner loop*/ { sum=r+c; printf(“r=%d c=%d sum=%dn”,r,c,sum); }} getch(); } Output r=1 c=1 sum=2 r=1 c=2 sum=3 r=2 c=1 sum=3 r=2 c=2 sum=4
  • 38. The loop that we have used so far executed the statements within them a finite number of times. However, in real life programming, one comes across a situation when it is not known beforehand how many times the statements in the loop are to be executed. This situation can be programmed as shown below: /* execution of a loop an unknown number of times*/ #include<stdio.h> void main() { Char another; Int num; do { printf(“enter a number”); scanf(“%d”,&num); printf(“square of%d is %d”, num, num*num); Printf(“n want to enter another number y/n”); Scanf(“%c”,&another); }while(another==‘y’); } getch(); } Output Enter a number 5 Square of 5 is 25 Want to enter another number y/n y Enter a number 7 Square of 7 is 49 Want to enter anotehr number y/n n