This document provides information about C programming language elements such as data types, variables, constants, expressions, operators, and input/output functions. It defines a program as a collection of instructions that a computer understands to solve problems. Programming involves writing these instruction sets, and a programmer is the person who writes the programs. It also explains what a programming language is and describes some basic and important C programming language elements for beginners to understand.
Get ready to learn the best programming language called C Programming Language. This note is based on +2 HSEB Syllabus of C programming. It helps you to get idea on the concept of C Programming Language. You get detail explanations on operators, looping, switch case, history, many more.
C programming slide day 01 uploadd by md abdullah al shakilZenith SVG
This Slide is about the basics of C programming. It is the first lecture on the C program. In this session, we will be able to clear the concept of :
i) Introduction
ii) Element of C
iii)Conditional Statements
Get ready to learn the best programming language called C Programming Language. This note is based on +2 HSEB Syllabus of C programming. It helps you to get idea on the concept of C Programming Language. You get detail explanations on operators, looping, switch case, history, many more.
C programming slide day 01 uploadd by md abdullah al shakilZenith SVG
This Slide is about the basics of C programming. It is the first lecture on the C program. In this session, we will be able to clear the concept of :
i) Introduction
ii) Element of C
iii)Conditional Statements
Program, Language, & Programming Language
Object Oriented Programming vs Procedure Oriented Programming
About C
Why still Learn C?
Basic Terms
C Stuff
C Syntax
C Program
Learn c language Important topics ( Easy & Logical, & smart way of learning)Rohit Singh
Learn C language with an easy way including all important topics in C.
Learn c language Important topics ( Easy & Logical, & smart way of learning)
preprocessor Directive, Search Strategy, Header file, return 0 in C, return, main function, flow of execution, explicit return, function, return type and non return type function. Run- time Environment, type specifier, void keyword, 32 keyword in C, openning curly brace and closing curly brace, system library, single argument, String literal is an unnamed array with element of type char.
C Programming
History of C Programming
Features of C Programming
More about C Programming
Advantages of C Programming
Disadvantages of C Programming
Write using C programming
It is a very simple and easy language, C language is mainly used for develop desktop based application. All other programming languages were derived directly or indirectly from C programming concepts. This language have following features;
http://www.tutorial4us.com/cprogramming/c-features
Program, Language, & Programming Language
Object Oriented Programming vs Procedure Oriented Programming
About C
Why still Learn C?
Basic Terms
C Stuff
C Syntax
C Program
Learn c language Important topics ( Easy & Logical, & smart way of learning)Rohit Singh
Learn C language with an easy way including all important topics in C.
Learn c language Important topics ( Easy & Logical, & smart way of learning)
preprocessor Directive, Search Strategy, Header file, return 0 in C, return, main function, flow of execution, explicit return, function, return type and non return type function. Run- time Environment, type specifier, void keyword, 32 keyword in C, openning curly brace and closing curly brace, system library, single argument, String literal is an unnamed array with element of type char.
C Programming
History of C Programming
Features of C Programming
More about C Programming
Advantages of C Programming
Disadvantages of C Programming
Write using C programming
It is a very simple and easy language, C language is mainly used for develop desktop based application. All other programming languages were derived directly or indirectly from C programming concepts. This language have following features;
http://www.tutorial4us.com/cprogramming/c-features
Full description about the c programming language . It will helpful to learn the c language easily with this notes and it will helpful in the building of coding and to get jobs in required companies
In order to communicate with the computer user also needs to have a language that should be understood by the computer. for this purpose, different languages are developed for performing different types of work on the computer. C is a general-purpose high level language that was originally developed by Dennis Ritchie for the Unix operating system.
Introduction to Computer.
Program and Programming.
Languages.
Types of Programming Languages.
Low-Level Languages.
Assembly languages.
High-Level Languages.
History of Programming.
Languages.
Translators.
Compiler.
Interpreter.
Typical C Program Development.
Environment
The C Programming Language
Characteristics of C language
durk computer,computer clan,jim's computer,chama computer,computer gk for,tiktok computer,gaming computer,kvs computer science full syllabus,chama computers,lil durk computer,trucchi computer,bhuture computer,computer science,patwari computer,computer security,computer for uppcl,
computer business basic computer
Characteristics of C language
Basic Program Structure in C
Language
Three types of loops: for a loop. while loop.In this tutorial, you will learn to create for loop in C programming with the help of examples anits purpose, syntax, flowchart
Unit I: Sociology of Education (5)
1.1 Concept of social perspectives in education
1.2 Concept of sociology and sociology of education
1.3 Contents of the sociology of education
1.4 Sociological perspectives in education
1.4.1 Structural-functional
1.4.2 Conflict
1.4.3 Symbolic interaction
Welcome to the Program Your Destiny course. In this course, we will be learning the technology of personal transformation, neuroassociative conditioning (NAC) as pioneered by Tony Robbins. NAC is used to deprogram negative neuroassociations that are causing approach avoidance and instead reprogram yourself with positive neuroassociations that lead to being approach automatic. In doing so, you change your destiny, moving towards unlocking the hypersocial self within, the true self free from fear and operating from a place of personal power and love.
4. Program is a set of coded instructions that a computer can
understand to solve a problem or produce a desired result.
Two basic types of computer programs are (1) an operating
system, which provides the most fundamental instructions a
computer uses in its operations, and (2) an application
program, which runs on the operating system and does a
specific job such as word processing.
A computer can’t perform any work by itself. It must be fed with some
instructions by which it knows what to do. Collection of such instructions (i. e.
a set of coded instructions) is called a program.
5. These instructions (Program/s) help the computer to know
what to do .
Without programs, computers are useless and can do
nothing .
Note that computer does not understand the instructions ( so
called programs) written in human language directly.
6. NOW, CAN YOU ANSWER THIS
QUESTION?
What is a program ?
7.
8. Programming language
We have known that computer can’t understand the
human language directly. It can only understand the
machine language (binary codes).
Computer Users know only natural human language/s.
The communication between two parties whether they are
machines or human beings always need a common
language or terminology(words/terms)
9. The language (prepared)used to communicate with the
computer is known as programming language. (It is
written in human language but in programming form- with certain codes-
following the fixed instructions). The programming language can be
understood by the programmers but the laymen may not
necessarily understand although the language is human.
It (The programming language) is also not directly
understood by the computer. It needs language
processor.
10. Then, the program prepared in the specific codes is
converted to the machine understandable form by any
conversion process.
The person who writes programs is called a
programmer and the task of writing program is
programming.
11.
12. Now, consider the following questions:
1. What is programming ?
2. What is a program ?
3. What does a programmer mean? or Who
is a programmer?
4. What is ‘programming language’ ?
13. 1. Program – A collection of
sequential instructions given to
computer to carry out certain task.
2. Programming – The work/task of
writing a set of sequential
instructions is called programming.
3. Programmer – The person who
writes a set of instructions to a
computer.
14. 4. The language used to communicate with
the computer is known as programming
language.
15. /* Display your name*/
#include <stdio.h>
#include <conio.h>
Int main()
{
Printf(“hello ! I am Ram”);
Getch();
}
16. 1. Low level language
a) Machine level language.
b) Assembly level language.
2. High level language
a) Compilers
b) Interpreters
17. The C was developed at AT and T’s Bell Lab of the
USA in 1972. It was designed and written by a man
named Dennis Ritchie . C was derived from a
language known as BCPL which was developed at
the Massachusetts Institute of Technology in the late
1960s. C is a successor of BCPL language.
18. C is a very powerful and most popular high
level programming language. It is a structural
programming language. Popular operating
systems such as UNIX , LINUX ,MINIX and
many system and application programs are
written in C.
19. with feature of high level language and therefore it
is suitable for writing both system software and
application software. C is programming language
for academic purpose. For this reason many
universities have a course in C programming in
their curriculum . C has very typical syntax
which can later be used to learn other
languages.
20. Tips
C was developed by Dennis Ritchie in 1972
at the Bell Telephone Laboratories in USA .
C is a general-purpose programming
language.
C is a high-level language that has the
advantages of readability, maintainability,
and portability.
Programs written in C can be reused.
21. C provides many programming languages,
such as Perl, C++, and Java, with basic
concepts and useful features.
C is the ANSI standard programming
language.
22. By 1960 there ware a number of programming
languages. But almost all were used for
specific purpose only. For example ,
FORTRAN (formulaTranslation) and COBOL(Common
Business Oriented) developed in 1960 with specific
use and specific purpose.
General purpose language was developed in
1960Which is called ALGOL (Algorithmic Oriented
Language).
ALGOL was too abstract (=unobservable )
and too general.
23. Cambridge university developed a new
programming language in 1963 which was
called CPL(Combined Programming language).
CPL was also too broad and had too many
features.
Therefore, Martin Richard developed BCPL in 1967.
BCPL was so less powerful and too much specific.
Ken Thompson (at AT & T Bell Lab ) developed a
programming language called B in 1970..
24. B was less specified and much powerful.
Taking all the good and strong features of BCPL, CPL
and B, C programming language was developed by
Dennis Richie at AT & T’s Bell lab in 1972 for use
with the UNIX operating system.
25. Readability: Programs written in C are easy to
read.
Maintainability: Programs are easy to
maintain(= keep).
Portability: Programs are easy to port across
different computer platforms.
C is a structured (modular) programming
language
C is a general-purpose (multipurpose)
26. Note: It is being used to develop operating
system, business application, text
processing, data-base applications, spread-
sheets, compilers etc. More than 70%
softwares are developed in C language
27. 1. The main disadvantage of C, particularly for beginners, is its
conciseness (shortness/brevity). Brief statements may be written
to carry out complex computation.
2. C programs use the pointers extensively (heavily /a lot ).
3. It is difficult to read C programs. In other words, C often becomes
difficult to understand because it is written by professional
programmers .
4. The programmers tend to use tricks with pointer and other C
features to make the program small.
28. /* Display your name*/
#include <stdio.h>
#include <conio.h>
Int main()
{
Printf(“hello ! I am Ram”);
Getch();
}
30. Programming elements of C language
Basic elements of C programming language are
as follows:
1. Character set 2. keyword 3. variable
4. Operators 5. expression 6. statement
7.constants
31. Alphabets :-
A,a………….Z,z
Character sets are valid set of characters used in C
programming language.They can be considered as
the basic elements of the programming.They
include letters (alphabets), numbers (digits) and
special symbols.The valid character sets used in C
programming language
are given blow:
33. Compiler collects the valid characters set s to make
sensible tokens. So, it can be said that tokens are
collections of different characters, operators or
punctuators. The first job of the compiler is to test
the validity of these tokens there are six types of
tokens as prescribed by C
35. Keywords are the reserved words used in the
program.That means they are defined in the C
compiler. Each key has a fixed meaning and that
cannot be changed by user, e.g,
int money
Here, int is a keyword
Key words are those words whose meaning is
already define by compiler.As ,c programming
language is case sensitive all keyword must be
written in lowercase.
36. They have special significance in C programs.
They may not be used in any other purposes.
For example, keywords cannot be used to
give the variable's names, function's name
etc .There are altogether 32 keywords in C
programming which are in the following
table:
37. auto break case char const continue default do
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while
38. Variable is an identifier whose value changes
time to time during program execution. Each
and every variables must be declared before it
is used . It is a memory location that can hold a
value of a certain data type. Programmers
cannot use any of the keywords as variable
names.
e.g.
Int a; (Here, ‘int’ is data type and ‘a’ is variable)
39. The syntax to declare a new variable is
a) first write the data type
b) then, give a valid variable identifier
as given in the following examples:
Int a ;
float total;
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,sum;
a=10;
b=5;
sum=a+b;
printf("sum=%d",sum);
getch();
}
40.
41. A variable name is any combination of 1 to
31 alphabets digits or underscores.
First characters in the variable name must be
an alphabet or underscore.
No commas or blanks are allowed within a
variable name.
No special symbols other then an underscore
can be used in variable name.
42. A constant is an entity that doesn't change during
execution of the program. The constants are
also formed (made) with alphabets , numbers ,
etc . However , the constants do not change but
variables change. Consider the following table
with a variable and constants in the memory
cells:
A
5
A
10
43. C constants are of different types . The basic
types are as follows:
(a) Integer constants (b) real (floating –
point) constants, (c ) character constants
and (d)string constants.
44. All the integer values can be considered as intege
constants
Rule for constructing integer constant
An integer constant must have at least one digit.
It must not have a decimal point.
It can be either positive or negative.
If no sign precedes an integer constant, it is
assumed to be positive
No commas or blanks are allowed within an
integer constant.
45. All the numbers with fractional parts can be
considered as floating constants
Rule for constructing real /Floating-point constant
➢ A real constant must have at least one digit.
➢ It must have a decimal point.
➢ It could be either positive or negative.
➢ Default sign is positive.
➢ No commas or blanks are allowed within a real
constant.
46. Characters are also constants which are
single alphabets enclosed in single quotes.
➢ A character constant is a single alphabet, a
single digit or single special symbol
enclosed within the single inverted
commas. Both the inverted commas should
point to the left. For example ,’A’ is valid
character constant whereas ‘A’ is not.
➢ The maximum length of character
constant can be 1 character.
47. Collection of multiple character constants are
called string constants which are enclosed in
double quotes(i.e. “ Ram”, “Sita”, etc. )
It must be formed with more than one
characters.
It must be enclosed within double quotations.
There should be no space between the
characters . But underscore can be used.
48. A data type in a programming
language is a set of data with
values(size) having predefined
characteristics such as
integers, floats and characters
etc . Storage representations
and data types differ form
machine to machine.
49. C supports a number of data types; if
they are not enough, programmers
can also define their own data types. C
supports three classes of data types:
50. Primitive (or basic) data types – these are the
fundamental data types supported by the language. These
can be classified as integer types, floating point types and
character types.
User defined data types – based on the fundamental data
types . Users can define their own data types. These
include type defined data types (using typedef keyword)
and enumerate types (using enum keyword).
Derived data types – programmers can derive data types
such as arrays, structures, unions and pointers by
combining several data types together.
51. Write a program to calculate total amount of (p)kept in
bank for (n) years at the rate of (r) simple interest per
annum.
Write a program to read the radius of a sphere and compute
its surface area and volume.
Write a program to read base and altitude of a triangle and
prints its area.
52. 8. Write a program to calculate total amount of (p)kept in bank for (n) years at
the rate of (r) simple interest per annum.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float I,P,Total,T,R;
printf("Enter the Value of P = ");
scanf("%f",&P);
printf("Enter the Value of T= ");
scanf("%f",&T);
printf("Enter the Value of R= ");
scanf("%f",&R);
I=(P*T*R)/100;
Total=p+I;
printf("Interest= %.2f",I);
Printf(“ Total amount=%.2f”,total);
getch();
}
53. 5. Write a program to read the radius of a sphere and compute its surface
area and volume.
#include<math.h>
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float A,V,r;
float PI=3.14;
printf("Enter the Value of Radious :");
scanf("%f",&r);
A=4*PI*pow(r,2);
V=4/3*PI*pow(r,3);
printf("Area :%.2fn",A);
printf("Volume :%.2f",V);
getch();
}
55. 3. Write a program to read base and
altitude of a triangle and prints its
area.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float A,B,H;
printf("Enter the Value of Altitude of a triangle H= ");
scanf("%f",&H);
printf("Enter the Value of Base of a triangle B= ");
scanf("%f",&B);
A=(B*H)/2;
printf("Area= %.2f",A);
getch();
}
56. 11.Write a program to print a
format of flag of Nepal .
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("*n");
printf("* *n");
printf("*t*n");
printf("*tt*n");
printf("*ttt*n");
printf("*tttt*n");
printf("*ttt*n");
printf("*tt*n");
printf("*t*n");
printf("* *n");
printf("*n");
printf("*n");
printf("*n");
printf("* *n");
printf("*t*n");
printf("*tt*n");
printf("*ttt*n");
printf("*tttt*n");
printf("*ttt*n");
printf("*tt*n");
57. Data Type Size in
bits
Size in Byte
Char 8 1 Byte
Int 32 4/2Bytes
Float 32 4Bytes
Double 64 8 Bytes
Void 0 Without value (null)
58. Expressions can be built up from literals,
variables and operators ( special
symbols). The operators define how the
variables and literals in the expression
will be manipulated.
. Data items upon which operation is performed
are called operands
x + y
operands
operator
60. The assignment operator is the simple equal
sign (=). The assignment operator is used to
assign a value to a variable. The format of an
assignment statement is:
variable-name = expression;
a+=b (a=a+b)
a-=b (a=a-b)
a/=b (a=a+b)
a%=b ( a=a%b)
a*= b (a=a*b)
61. C supports five major operators and two
extended (shortcuts) operators
64. 4.Write algorithm, flow chart and program to input length & breadth of a room and
calculate and print its area and perimeter.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int l,b,A,P;
printf("Enter the L");
scanf("%d",&l);
printf("Enter the B");
scanf("%d",&b);
A=l*b;
P=2*(l+b);
printf("%d,%d",A,P);
getch();
}
65. Relational operators are used to compare two similar
operands, and depending on their relation. Relation
operators compare their left hand side operand with their
right hand side operand for lesser than, greater than lesser
than or equal to, greater than or equal to, equal or not equal
to relations. The value of a relational expression is either
1(condition is true) or 0 (if condition is false). C support six
relational operators
66. operator Meaning
> Greater than
< Less than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal
67. #include <stdio.h>
#include <conio.h>
void main()
{ int a=13,b=32,c=14;
clrscr();
printf("a<b=t%dt a>b=t%d", a<b,a>b);
printf("na==ct %da<=ct%dta>=ct%d",a==c,a<=c,a>=c);
getch();
}
Example of Relational Operators
#include <stdio.h>
#include <conio.h>
void main()
{ int a=13,b=32,c=14;
clrscr();
printf("a<b=t%d",a<b);
printf("na==ct%d",a==c);
getch();
}
68. Logical Operators
&& AND
|| OR
! NOT
Logical operators are used to compare or evaluate logical and
relation expressions. The operands of these operator must
produce either 1 (true) or 0(false ). The whole result produced
by these operators is also either true or false. There are three
logical operators in c:
69. Cont…
a b a && b a||b !a !b
0 0 0 0 1 1
0 1 0 1 1 0
1 0 0 1 0 1
1 1 1 1 0 0
70. Try to answer these questions:
1. Why is “NOT” operator unary ?
1.
71. Bitwise Operators
They are also called low level operators. C supports six
bitwise operators and they are listed in table below.
Their precedence (priority) is lower than arithmetic,
relational and logical operators
Operator Action
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
~ One’s complement
>> Right shift
<< Left shift
72. cont
Bitwise operators are used for manipulating data at bit
level. These operators are used for testing the bits , or
shifting them to the left or to the right . Bitwise
operators can be applied only one integer –type
operands and not to float or double. There are three
types of bitwise operators:
Bitwise Logical operators
Bitwise shift operators
One’s complement operator
73. Bitwise Logical operators
Bitwise logical operators performs logical ANDing
between two operands . There are three logical bitwise
operators:
Bitwise AND (&)
Bitwise OR (|)
Bitwise Exclusive OR(^)
74. Bitwise AND(&): the result of ANDing opration is 1 if the
both the bit have a value of 1 ; otherwise it is 0. let us
consider two variable n1=60 and n2 =15. the binary
representations of these two variables are:
N1= 0000 0000 0011 1100
N2= 0000 0000 0000 1111
If we execute the statement,
N3=N1&N2
The result will be .
N3=0000 0000 0000 1100
Although the resulting bit pattern represents the decimal
number 12, there is no plain connection between the
decimal values of these variables
75. Bitwise OR(|): the result of ORing operation is 1 if
eihter of the bit have a value of 1 ; otherwise it is 0. let
us consider two variable n1=60 and n2 =15. the binary
representations of these two variables are:
N1= 0000 0000 0011 1100
N2= 0000 0000 0000 1111
If we execute the statement,
N3=N1|N2
The result will be .
N3=0000 0000 0011 1111
Again , although the resulting bit pattern represents the
decimal number 63, there is no plain connection
between the decimal values of these variables
76. Bitwise Exclusive XOR(^): the result of exclusive ORing
operation is 1 only if one of the bit have a value of 1;
otherwise it is 0. let us again consider the two
variables n1=60 and n2=15. if we execute the
statement,
N3=n1^n2;
Then the result will be
n1 0000 0000 0011 1100
n2 0000 0000 0000 1111
---------------------
0000 0000 0011 0011
Again , although the resulting bit pattern represents
the decimal number 53, there is no plain connection
between the decimal values of these variables .
78. Bitwise shift operators are used to move bit
patterns either to left or to the right. There
are two bitwise shift operators:
Left shift (<<)
Right shift (>>)
Left shift (<<): the left shift operation causes
the operand to be shifted to the left by some
bit positions. The general of left-shift
operation is -
Operand << n
79. The bits in the operand are shifted to the left by n positions. The
leftmost n bits in the original bit pattern will be lost and the
rightmost n bits empty positions will be filled with 0s. For
example if n1=60, than if we execute the statement,
n2=n1<<3;
The result is calculated as;
n1 0000 0011 1100
Shift1 0000 0111 1 000
Shift 2 0000 1111 0000
Shift 3 0001 1110 0000
80. Right shift (>>): the ritht shift operation causes the operand
to be shifted to the right by some bit positions. The general
of right-shift operation is -
Operand >> n
The bits in the operand are shifted to the right by n positions.
The leftmost n bits will be lost the empty leftmost n bits
positions will be filled 0s , if the operand an unsigned
integer . If the operation is assigned , then the operand is
machine dependent, for example if unsigned int n1=60,
then if we execute the statement,
N2=n1>>3;
81. The result is calculate as;
n1 0000 0000 0011 1100
Shift 1 0000 0000 00011110
Shift 2 0000 0000 0000 1111
Shift 3 0000 0000 0000 0111
The following example shows the operation of these two shift Bitwise perators:
#include <stdio.h>
#include <conio.h>
void main()
{
unsigned int n1=60,left,right;
clrscr();
left=n1<<3;
right=n1>>3;
printf("left=%d", left);
printf("right=%d",right);
getch();
}
82. Bitwise one’s compliment operator is a unary operator
which inverts all the bits presented by its operand. This
means that all 0s become 1s and all 1s become 0s. For
example , if n1=60 than if we execute the statement,
n2=~n1
Than the result is calculated as,
n1= 0011 1100
n2= 1100 0011
84. Increment and decrement operators
C offers two unusual and unique operators ++ and
-- called increment and decrement operator
respectively. The use of these two operators will
results in the value of the variable being
incremented or decremented by unity. i=i+1 can be
written as i++ and j=j-1 can be written as j--. The
increment operators is used to increase the value of
an operand by 1; and the decrement operator is
used to decrease the value of an operand by 1.
they take only one operand, so called unary
operator. The syntax for the operator is.
85. ++a a= a+1
a++ a= a+1
--a a= a-1
a-- a= a-1
The increment and decrement operators can be
used as postfix or prefix notations.
The operators can be place either before or after
the operand. If the operator is placed before the
variable (++I or --I) it is known as pre
incrementing or pre decrementing.
If the operator is placed after the variable
(I++ or I--) it is known as post incrementing or
post decrementing
86.
87. Let us see an example to illustrate the use of increment
and decrement operator
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int a=10;
printf("ta=%dn",a);
printf("ta=%dn",++a);
printf("ta=%dn",a++);
printf("ta=%dn",a);
getch();
}
Output:
In this example, initially the value of a is 10. When ++a is displayed, the variable
a is first incremented by 1(i.e 11)and then displayed; so the result is 11. but
when a++ is displayed , the value of a is displayed first and then increment
By one. Thus, it shows 11 at this time but when displayed again, it shows 12.
88. #include <stdio.h>
#include <conio.h>
void main()
{
int num,a=5;
num=++a;
printf( "%d %d",num,a);
getch();
}
What will be output if you execute following c code?
void main()
{
int num,a=5; num=++a; printf( "%d %d",num,a);}
91. 1. Unary (monadic): Require / take one
operand
2. Binary(dyadic) : Require /take two operands
3. Ternary : Require/take three operands
92. 2. How many kinds of operators are there according to
the number of operands ? and what are they ?
93. An expression represents a single data item,
such as number or character.An expression
may be a single entity or combination of such
entities interconnected by one or more
operators.
c = a + b
a = c * b
a==b
a < b, etc.
94. A statement causes (gives instructions)
the computer to carry out some
action. There are five types of
statements, which are:
i) Expressional (simple ) Statement
ii) Compound Statement
iii) Control Statement
iv) Iterative Statement (for, while ,do …..while)
v) Jump statement( goto, continue, break, return)
95. An expression statement consists of an
expression followed by semi colon.
Example:
x = 3;
y = a+c;
printf (“Total = %f ", total);
96. A compound statement consists of(includes)
several individual expression statements
enclosed within a pair of braces ({ and }).
Example:
{
pi = 3. 141593;
circumference = 2.0 * pi * radius;
area = pi * radius * radius;
}
97. A control statement is used to create special program
features, such as logical test, loops and branches.
Example:
if (area < 12)
{
printf (“Area is small”);
}
printf (“Area is big”);
102. An algorithm is the most commonly used programming
tool. An algorithm is a stepwise presentation of procedures
to perform specific task in the computer. In the algorithm ,
instructions are written in the sequential order to solve a
particular problem. Algorithm is written in simple English
language.
An algorithm is named after the 9th century mathematician,
“Abu Jafar Muhammad Ibn Al –knowarizmi of Bagdad (Iraq)
103. We should prepare an algorithm by dividing the
problem into small modules
There should be finite(fixed) number of steps in an
algorithm.
The input has to be identified for the particular
problem.
Required output has to be identified from the given
input.
The steps written in the algorithm should be simple
and clear.
104. After writing algorithm, programmer makes flowchart to
represent that algorithm. Graphical(pictorial)
representation of sets of instructions is called
FLOWCHART.The first “flow chart” was introduced by
Frank Gilberth
109. Terminal indicates the beginning and end of the
program. It is of OVAL shape. Start or end is
written inside it……….
End
110. This symbol indicates input or
output function.This notation is
used to input data and to display
result.The shape of input/output
notation is PARALLELOGRAM.
111. This symbol is used to check the
condition of the program. This
symbol gives yes or no result.The
shape of this symbol is diamond.
112.
113. This symbol indicates the
function(information processing)
like calculations or movements.
It is rectangle in shape.
117. Q. Write an algorithm and draw
flowchart to find the largest
numbers among two numbers.
118. Step1: Start
Step2: enter the three number
Step3: read the three number: a, b & c
Step4: if a>b and a>c , then print “a is
greatest”.
Step5: if b>a and b>c them print “b is greatest”
else print C is greatest
Step6: stop
119. .
START
Read numbers
a ,b ,c
Is a>b?
Is a>c ? Is b>c ?
PRINT a
as
greater
PRINT C
is greater
PRINT b
as
greater
STOP
YES
YES YES
NO
NO NO
121. Example: Make an algorithm and then a flowchart
in detail as far as possible, for the tasks performed,
while making a phone call.
One of the possible algorithms might look like
this:
122. Step 1. (start)- Recall the phone number.
Step 2. Lift the Phone receiver
Step 3. Check for Dial tone?
If YES Go to Step 4
If No Put down the receiver
Go to Step 2
Step 4. Dial the phone number.
Step 5. Is the phone ringing?
If Yes Go to Step 6.
If No Put down the receiver
Go to Step 2
Step 6. Has the phone being picked up?
If Yes Talk with the other end.
Go to Step 8.
If No Go to Step 7.
Step 7. Has the bell stopped ringing?
If Yes Put down the receiver
Go to Step 2.
If No Go to Step 6
Step 8. Put down the receiver.
Stop
123. General symbols used in Flowchart
Flowchart based upon the above algorithm is as follows:
START
READ Phone No.
Lift the Receiver
Is there dial tone?
Put down the receiver
Dial the Phone
No.
Is the phone
Ringing?
No
No
Has the phone
been picked?
Yes
Yes
Yes
Talk with other end
STOP
Has the bell
Stopped?
Put down the
receiver
No
No
Yes
124. Pseudo codes
When we are planning to write a program , we prepare
an algorithm and them a flowchart. Before coding the
program in editor , we prepare a code . It looks like a
program but it is not . Such a program like code is
called “pseudo-code”.
❑It is also called structured code .
❑ It is program independent construct.
125. Cont…
Look at the following example of the pseudo-code :
Input a, b
If a>b
g=a
Else
g=b
End if
Print “largest number is”,g
126. Examples – Algorithm & Flowchart
2. Develop an Algorithm to
read two numbers and
print the bigger number.
Convert it into
Flowchart.
Read two numbers N1 and N2
Is N1 > N2
YES Print N1
NO Print N2
Stop
START
Read N1, N2
Is N1 > N2?
PRINT N1 PRINT N2
STOP
YES
NO
127. The title should be given to every flowchart.
Operation should be written inside every
symbol of the flowchart.
The language should be simple and easy to
understand for any programmers.
The flow-line in the flowchart should won't
cross each other.