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
This PPT File helps IT freshers with the Basic Interview Questions, which will boost there confidence before going to the Interview. For more details and Interview Questions please log in www.rekruitin.com and click on Job Seeker tools. Also register on the and get employed.
By ReKruiTIn.com
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
This PPT File helps IT freshers with the Basic Interview Questions, which will boost there confidence before going to the Interview. For more details and Interview Questions please log in www.rekruitin.com and click on Job Seeker tools. Also register on the and get employed.
By ReKruiTIn.com
A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
INTRODUCTION
COMPARISON BETWEEN NORMAL FUNCTION AND INLINE FUNCTION
PROS AND CONS
WHY WHEN AND HOW TO USED?
GENERAL STRUCTURE OF INLINE FUNCTION
EXAMPLE WITH PROGRAM CODE
Vladimir Romanov - How to write code that is easy to read and change? What should you do when you see a piece of code written years ago which is hard to understand? In my experience, this boils down to 4 principles that I would like to share along with some examples in Apex
A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. Functions are used to perform certain actions, and they are important for reusing code: Define the code once, and use it many times.
A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
INTRODUCTION
COMPARISON BETWEEN NORMAL FUNCTION AND INLINE FUNCTION
PROS AND CONS
WHY WHEN AND HOW TO USED?
GENERAL STRUCTURE OF INLINE FUNCTION
EXAMPLE WITH PROGRAM CODE
Vladimir Romanov - How to write code that is easy to read and change? What should you do when you see a piece of code written years ago which is hard to understand? In my experience, this boils down to 4 principles that I would like to share along with some examples in Apex
A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. Functions are used to perform certain actions, and they are important for reusing code: Define the code once, and use it many times.
BRANCHING STATEMENTS
if statement
if – else statement
if – else if ladder
Nested if
Goto
Switch case
programs
output
flowchart
Branching / Decision Making Statements
The statements in the program that helps to transfer the control from one part to other parts of the program.
Facilitates program in determining the flow of control
Involves decision making conditions
See whether the condition is satisfied or not
If statement; Execute a set of command line or one command line when the logical condition is true.
It has only one option
syntax with flowchart
If else if ladder; Number of logical statements are checked for executing various statement
If the first condition is true the compiler executes the block followed by first if condition.
If false it skips the block and checks for the next logical condition followed by else if.
Process is continued until a true condition is occurred or an else condition is satisfied.
Switch case; Multiway branch statement
It only requires one argument of any type, which is checked with number of cases.
If the value matches with the case constant, that particular case constant is executed. If not the default statement is executed.
Break statement – used to exit from current case structure
Nested if else; When a series of decisions are involved we use more than one if-else statement.
If condition is true control passes to first block i.e., if block. In this case there may be one more if block.
If condition is false control passes to else block. There we may have one more if block.
18 css101j pps unit 2
Relational and logical Operators - Condition Operators, Operator Precedence - Expressions with pre / post increment operator - Expression with conditional and assignment operators - If statement in expression - L value and R value in expression -
Control Statements – if and else - else if and nested if, switch case - Iterations, Conditional and Unconditional branching
For loop - while loop - do while, goto, break, continue
Array Basic and Types - Array Initialization and Declaration - Initialization: one Dimensional Array - Accessing, Indexing one Dimensional Array Operations - One Dimensional Array operations - Array Programs – 1D
Chapter 3 Classes and Objects 3
2.1 The Nature of Objects 4
2.2 Relationships among Object 7
2.3 The Nature of Classes 10
2.4 Relationships among Classes 11
2.5 Interplay of Classes and Objects 14
2.6 Identifying Classes and Objects 15
2.7 Importance of Proper Classification 18
2.8 Key abstractions and Mechanism 19
Chapter 2 The Object Model
2.1 The Evolution of the Object Model
2.2 Foundations of the Object Model
2.3 Elements of the Object Model
2.4 Applying the Object Model
Chapter 1 Complexity 4
1.1 The Structure of Complex Systems 6
1.2 The Inherent Complexity of Software 8
1.3 The Five Attributes of a Complex System 11
1.4 Organized and Disorganized Complexity 12
1.5 Bringing Order to Chaos 13
1.6 On Designing Complex Systems 14
Introduction: The Structure of Complex systems, The Inherent Complexity of Software, Attributes of Complex System, Organized and Disorganized Complexity, Bringing Order to Chaos, Designing Complex Systems
Text Input / Output: Files, Streams, Standard Library Input / Output Functions, Formatting Input / Output Functions, Character Input / Output Functions, Binary Input / Output: Text versus Binary Streams, Standard Library, Functions for Files, Converting File Type
Repetition: Concept of Loop, Pretest and Post-test Loops, Initialization and Updating, Event and Counter Controlled Loops, Loops in C, Other Statements Related to Looping, Looping Applications
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
1. B Y
Y N D ARAVIND
A S S O C I A T E P R O F E S S O R , D E P T O F C S E
N E W T O N ’ S G R O U P O F I N S T I T U T I O N S , M A C H E R L A
@2020 Presented By Mr.Y N D Aravind
1
SELECTION – MAKING
DECISIONS
2. P A R T - I I
L O G I C A L D A T A A N D O P E R A T O R S
T W O W A Y S E L E C T I O N
M U L T I W A Y S E L E C T I O N
M O R E S T A N D A R D F U N C T I O N S
@2020 Presented By Mr.Y N D Aravind
2
SELECTION – MAKING DECISIONS
3. Logical Data and Operators
Presented By Mr.Y N D Aravind
3
A piece of data is called logical if it gives information as true or
false.
For this, we have boolean data type called _bool, declared as
unsigned integer in stdbool.h file.
To support logical data we have to use bool type. Logical
operators are used to combine two or more relations.
The logical operators are called Boolean operators. Because the
test between values are reduced to either true or false, with
zero being false and one being true.
4. Logical Data and Operators
Presented By Mr.Y N D Aravind
4
Operator Meaning
&&
Logical AND
||
Logical OR
!
Logical NOT
AND OR NOT
X Y X || Y
False False False
False True True
True False True
True True True
X Y X && Y
False False False
False True False
True False False
True True True
X !X
False True
True False
5. Logical Data and Operators
Presented By Mr.Y N D Aravind
5
Evaluating Logical Expressions
There are two methods to evaluate binary logical relations. First, expression
must be completely evaluated before the result is determined. Second, sets
the result as soon as it is known.
If the first operand of the logical and expression is false then there is no
need to evaluate the second half of the expression. And in the case of
logical or if the first operand is true then there is no need to evaluate the
second half of the expression. This is known as short circuit evaluation.
False && Anything True || Anything
FALSE TRUE
6. Program to illustrate about logical operators
#include<stdio.h>
#include<stdbool.h>
int main()
{
bool a = true;
bool b = false;
printf(“%d”, a&&b);
printf(“%d”, a||b);
printf(“%d”, !a&&b);
printf(“%d”, a&&!b);
printf(“%d”, !a||b);
printf(“%d”, a||!b);
return 0;
}
Presented By Mr.Y N D Aravind
6
OUTPUT
010101
7. In addition to logical operators, C provides six comparative operators. They all are
binary operators. They take two operands and compare to produce Boolean
value.(true or false). They are divided into two groups.
1. Relational operators 2. Equality operators
The relational and equality operators
are listed below:
Operator Meaning
< Is less than
<= Is less than or equal to
> Is Greater than
>= Is Greater than or
equal to
== Is Equalto
!= Is Not Equal to
Comparative Operators
Presented By Mr.Y N D Aravind
7
For example, x>y, x<y, x==y,
x>=y, x<=y, x!=y
Operator Complement
< >=
> <=
== !=
8. Comparative Operators
If we want to simplify an expression containing not less than operators,
we use greater than or equal to operator.
Presented By Mr.Y N D Aravind
8
Original expression Simplified expression
!(x < y) x >= y
!(x > y) x <= y
!(x != y) x == y
!(x <= y) x > y
!(x >= y) x < y
!(x == y) x != y
9. CONDITIONAL STATEMENT
Decision making is about deciding the order of execution of statements based on
certain conditions or repeat a group of statements until certain specified
conditions are met. C language handles decision-making by supporting the
following statements,
1. If statement
2. Switch statement
3. Conditional operator statement
4. Go to statement
if Statement
The if statement is powerful decision making statement and is used to control the
flow of execution of statements. The if statement may be complexity of
conditions to be tested.
1. Simple if statement
2. If else statement
3. Nested If-else statement
4. Else –If ladder statement
Presented By Mr.Y N D Aravind
9
10. Simple – If Statement
Syntax :-
if (test expression)
{
Statement block;
}
Statement - x ;
SINGLE WAY SELECTION
Presented By Mr.Y N D Aravind
10
Flow Chart
The statement block may be a single statement or a group of statements. If the
test expression is true then the statement block will be executed.
Otherwise the statement block will be skipped and the execution will jump to
the statement –x. If the condition is true both the statement - block and statement-x
in sequence are executed.
11. Example Program
if(category = sports)
{
marks = marks + bonus marks;
}
printf(“%d”, marks);
If the student belongs to the
sports category then additional
bonus marks are added to his
marks before they are printed.
For others bonus marks are not
added.
#include<stdio.h>
Void main()
{
int x;
clrscr();
printf(“enter the value of x”);
scanf(“%d”, &x);
if (x == 1)
printf(“ x value is one”);
printf(“%d”, x);
}
Simple – If Statement
Presented By Mr.Y N D Aravind
11
12. If – else Statement
Syntax :-
if (test expression)
{
True block - 1;
}
Else
{
False block – 2;
}
Statement - x ;
TWO WAY SELECTION
Presented By Mr.Y N D Aravind
12
Points to note
The expression must be enclosed in
parenthesis.
No semicolon is required for if else
statement
Both true and false block may
contain null statement or another if
else statement
Both blocks may contain either one
statement or group of statements if
group then they should be presented
between a pair of braces called
compound statement.
13. Example Program
If (code == 1)
boy = boy + 1;
else
girl = girl + 1;
st-x;
Here if the code is equal to „1‟ the statement
boy=boy+1; is executed and the control is
transferred to the statement st-x, after
skipping the else part. If code is not equal to
„1‟ the statement boy =boy+1; is skipped
and the statement in the else part girl
=girl+1; is executed before the control
reaches the statement st-x.
#include<stdio.h>
#include<conio.h>
Void main()
{
int num;
clrscr();
printf(“enter the value “);
scanf(„%d”, &num);
if(num%2==0)
printf(“the number is even”);
else
printf(“the number is odd”);
}
If - else Statement
Presented By Mr.Y N D Aravind
13
14. If – else Statement
TWO WAY SELECTION
Presented By Mr.Y N D Aravind
14
Points to note
The expression is a C
expression. After its evaluation
its value is either true or false.
If the test expression is true
then true-block statements are
executed, otherwise the false–
block statements are executed.
In both cases either true-block
or false-block will be executed
but not both.
Flow Chart
15. Nested If – else Statement
Syntax :-
if(test expression1)
{
if(test expression2)
{ statement block –1;
}
else
{ statement block – 2;
}
}
else
{ statement block – 3;
}
Statement – x;
TWO WAY SELECTION
Presented By Mr.Y N D Aravind
15
Test
expression
St- 1 St-3St- 2
Test
expression
St -x
Flow Chart
When a series of decisions are involved we may have to use
more than one if-else statement in nested form. An if-else is
included in another if-else is known as nested if else statement.
17. Dangling else problem
In nested if-else we have a problem known as dangling else problem. This problem
is created when there is no matching else for every if. In C, we have the simple
solution. “always pair an else to most recent unpaired if in the current
block”.
But however it may lead to problems hence the solution is to simplify if statements by putting braces.
if(test expression1)
{
if(test expression2)
st –1;
}
else
st – 2;
st – x;
Presented By Mr.Y N D Aravind
17
18. else - if ladder
Syntax :-
if (condition1)
St block–1;
else if (condition2)
St block –2;
else if (condition 3)
St block –3;
else
St block -4;
St –x;
MULTI WAY SELECTION
Presented By Mr.Y N D Aravind
18
A multi path decision is chain of if’s in which the
statement associated with each else is an if.
Flow Chart
19. Example Program
if (code = = 1)
Color = “red”;
else if ( code = = 2)
Color = “green”
else if (code = = 3)
Color = “white”;
else
Color = “yellow”
If code number is other than 1, 2 and 3
then color is yellow.
#include<stdio.h>
Void main()
{ int m1,m2,m3,m4,m5, total; float per;
printf(“enter the marks for five subjects”);
scanf(“%d%d%d%d%d”, &m1, &m2, &m3, &m4, &m5);
total = m1 + m2 + m3 + m4 + m5;
per = total / 500;
printf(“%f”, per);
if(per >= 90)
printf(“A”);
else if(per >= 80)
printf(“B”);
else if(per >= 70)
printf(“C”);
else if(per >= 60)
printf(“D”);
else
printf(“F”);
}
else - if ladder
Presented By Mr.Y N D Aravind
19
20. Switch Statement
Syntax :-
switch (expression)
{
case value1 : block1;
break;
case value 2 : block 2;
break;
default : default block;
break;
}
st – x;
MULTI WAY SELECTION
Presented By Mr.Y N D Aravind
20
Instead of else – if ladder, ‘C’ has a built-in multi-
way decision statement known as a switch.
Flow Chart
Switch
(Expression)
Block 1 Block 2 Default
St - x
21. Program Program Cont
main()
{
int a , b , choice;
float c;
clrscr();
printf(“enter the values of a & b”);
scanf(“%d%d”, &a, &b);
printf(“enter the choice”);
scanf(“%d”, &choice);
switch(choice)
{
case „1‟ : c=a+b;
printf(“%f”, c);
break;
case „2‟ : c=a-b;
printf(“%f”, c);
break;
case „3‟ : c=a/b;
printf(“%f”, c);
break;
case „4‟ : c=a*b;
printf(“%f”, c);
break;
case „5‟ : c=a%b;
printf(“%f”, c);
break;
default case : printf(“Invalid option”);
break;
} getch();
}
Switch Statement
Presented By Mr.Y N D Aravind
21
22. Y. N. D. ARAVIND
ASSOCIATE PROFESSOR, DEPT OF CSE
N E W T O N ’ S G R O U P O F I N S T I T U T I O N S , M A C H E R L A
Presented By Mr.Y N D Aravind
22
Thank YouThank You