2. C Programming Languages
C is a general-purpose programming language that is extremely popular, simple, and
flexible to use. It is a structured programming language that is machine-independent and
extensively used to write various applications, Operating Systems like Windows, and many
other complex programs like Oracle database, Git, Python interpreter, and more. The C
programming language came out of Bell Labs in the early 1970s. According to the Bell Labs
paper The Development Of C Language by Dennis Ritchie, “The C programming language was
devised in the early 1970s as a system implementation language for the nascent Unix operating
system. Derived from the typeless language BCPL, it evolved a type structure; created on a tiny
machine as a tool to improve a meager programming environment.” Originally, Ken Thompson, a
Bell Labs employee, desired to make a programming language for the new Unix platform.
Thompson modified the BCPL system language and created B. However, not many utilities were
ever written in B due to its slow nature and inability to take advantage of PDP-11 features in the
operating system. This led to Ritchie improving on B, and thus creating C.
3. Variable And Constant
A variable is an identifier which value may change during the execution of the program. For example, in the expression
i=i+1, i is a variable.
A constant is an identifier in which value remains fixed or unchanged throughout the program. For example, in an
expression, Area=3.14*r*r, 3.14 is the constant.
Operand, Operator, and Operation
In computer programming , an operand is a term used to explain any object that is capable of being manipulated. In these
two statements: Z-A + B and 18-12-6, there are the "A" and "B" and the "18" and "12" are the operands.
An operator is a symbol, which defines the operations to be performed on operands. In the statement of "A+ B" and "18-
12", there are the "+" and "-" are the operators.
An Operation is a result of an expression. The operation is defined by the operator. It can be defined as the action upon
data. For example, in a mathematical expression, "A+B" or "18-12" and "Z" and "6" are the results of the operation or
result of the expression.
4. Programming Design Tools
Program design tools are used to design a program before it is actually developed.
It is used by the designers.
Some of the commonly used tools in programming are:
◦ Algorithm
◦ Pseudo code
◦ Flowchart
5. Algorithm
Definition
An algorithm is the finite set of step-by-step set of
statements that solve a particular problem.
Example
◦ Find the sum of the two numbers.
◦ Step 1: START.
◦ Step 2: Read the two numbers A and B.
◦ Step 3: Add the number A and B and store in D.
or D=A+B
◦ .Step 4: Display D or print D.
◦ Step 5: STOP.
6. Flow Chart
Definition
A flow chart is a diagrammatic
(pictorial) representation that
illustrates the sequence of operations
to be performed.
7. Pseudo Code
Definition
Pseudo Code is a notation resembling a
simplified programming language, used in
program design.
Example
Q. Computing Sales Tax: Pseudo-code the task of computing the final price of an
item after figuring in sales tax. Note the three types of instructions: input (get),
process/calculate (=) and output (display).
get the price of the item
get sales tax rate
sales tax = price of item times sales tax rate
final price = price of the item plus sales tax
display final price
halt
8. C tokens
C tokens are the basic buildings blocks in C language which are constructed together to
write a C program.
C token includes:
oIdentifier
oKeyword
oConstant And Variable
oOperator
9. Identifier
An identifier is a combination of alphanumeric characters. An identifier can be
composed of letters such as uppercase, lowercase letters, underscore, digits, but the
starting letter should be either an alphabet or an underscore. If the identifier is not used
in the external linkage, then it is called as an internal identifier. If the identifier is used in
the external linkage, then it is called as an external identifier. We can say that an
identifier is a collection of alphanumeric characters that begins either with an
alphabetical character or an underscore, which are used to represent various
programming elements such as variables, functions, arrays, structures, unions, labels,
etc. There are 52 alphabetical characters (uppercase and lowercase), underscore
character, and ten numerical digits (0-9) that represent the identifiers. There is a total of
63 alphanumerical characters that represent the identifiers.
10. Keyword
Definition
Keywords are predefined, reserved
words used in programming that have
special meanings to the compiler
Keywords
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
11. Variable And Constant
Definition
A variable is an identifier which value may
change during the execution of the program.
For example, in the expression i=i+1, i is a
variable.
A constant is an identifier in which value
remains fixed or unchanged throughout the
program. For example, in an expression,
Area=3.14*r*r, 3.14 is the constant.
12. Constant V/S Variable
Variable
◦ Variables also have its uses in computer programming and
applications.
◦ Variables, on the other hand, represent the unknown
values.
◦ Variables are specially written in letters or symbols.
◦ A variable, on the other hand, changes its value dependent
on the equation.
Constant
◦ Constants are used in computer programming.
◦ Constants usually represent the known values in an
equation, expression or in line of programming.
◦ Constants are usually written in numbers
◦ A constant does not change its value over time.
13. Operators and Expressions
An operator is a symbol that instructs C to perform some operation or action on one or more operands.
Types of operators are
◦ Relational operator
◦ Increment/Decrement operator
◦ Logical operator
◦ Arithmetic operator
◦ Equality operator
◦ Assignment operator
◦ Conditional operator (Ternary operator)
◦ Special operator
◦ Bitwise operator
14. Arithmetic operator
An arithmetic operator is a mathematical function that takes two operands and performs a calculation on
them
16. Logical operator
Logical operator is a symbol that logically connects the logical expressions i.e. it is used to connect
two or more expressions.
17. Other Operators Definitions
◦ Equality operator: The equality operator (==) is used to compare two values or
expressions.
◦ Increment/Decrement operator: Increment and decrement operators are unary operators
that add or subtract one, to or from their operand, respectively
◦ Assignment operator: An assignment operator is the operator used to assign a new
value to a variable, property, event or indexer element.
◦ Conditional operator: Conditional operators are used to evaluate a condition that's
applied to one or two Boolean expressions.
◦ Bitwise operator: Bitwise operators are characters that represent actions to be
performed on single bits.
◦ Special operator: These operators are used to either increase or decrease the value of
the variable by one is special operators.
19. Sequence Control Structures
Definition
Sequence is the default control structure;
instructions are executed one after another
C program
#include
#include
void main()
{
clrscr();
int x , y, sum;
printf(“enter the two numbers”);
scanf(“%d%d”,&x,&y);
sum=x+y;
printf(“the sum of the two numbers is =%d”,sum);
getch();
}
20. Decision Control Structures
Definition
The decision control statements are the
decision making statements that decides
the order of execution of statements
based on the conditions
Types of decision control structures
• nested if statements
• if-else statements
• if statements
Flowchart
22. Decision(if else)
Syntax
If (expression)
statementl;
else
statement
OR
If (expression)
{
statement1;
statement2;
}
Else
{
statement3;
statement4;
}
Flowchart
23. Decision(nested if statements)
Syntax
if (expressionl)
{
If(expression2)
Statement1;
Else
Statement2;
}
Else
{
if (expression3)
Statement3;
Else
Statement4;
}
Flowchart
24. Looping
A loop is a programming structure that repeats a sequence of instructions until a
specific condition is met.
Types of looping are:
• for statement
• while statement
• do…while statement
25. Looping(FOR)
Syntax Flowchart
// Print numbers from 1 to 10
#include <stdio.h>
int main() {
int i;
for (i = 1; i < 11; ++i)
{
printf("%d", i);
}
return 0;A
}
26. Looping(while)
Syntax
// Print numbers from 1 to 5
#include <stdio.h>
int main() {
int i=1:
while (I <= 5) {
printf("%dn", 1):
++i:
}
return 0;
}
Flowchart
27. Looping(do..while)
Syntax
#include <stdio.h>
int main() {
double number, sum = 0;
// the body of the loop is executed at least once do {
printf("Enter a number: ");
scanf("%lf", &number);
sum += number;
}
while(number != 0.0);
printf("Sum = %.2lf",sum);
return 0;
}
Flowchart