2. What is programing
A programming language is a formal computer language or
constructed language designed to communicate instructions to a
machine, particularly a computer. Programming languages can
be used to create programs to control the behavior of a machine
or to express algorithms.
3. Language year Developed By
ALGOL 1960 International Group
BPCL 1967 Martin Richards
B 1970 Ken Thompson
Traditional C 1972 Dennis Ritchie
K & R C 1978 Kernighan & Dennis Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISO C 1990 ISO Committee
C99 1999 Standardization
Committee
4. What is C Programing
• C is a high-level and general purpose programming language that is ideal
for developing firmware or portable applications. Originally intended for
writing system software, C was developed at Bell Labs by Dennis Ritchie for
the Unix Operating System (OS) in the early 1970s.
13. NOT Operator (!)
The NOT operator (!) is used to reverse the results. This
operator is mainly used as a key in big complex programs.
By using this operator we can reverse the condition easily.
Lets try to understand it with an example.
If ( !(y>6) )
In the above statement I am writing a condition that y
should be lesser than or equal to 6. I can also write the
same condition as
If (y<=6)
Both the statements will give the same results. You can
use anyone of them.
14. Hierarchy of Operators
I have given the hierarchy of operators after arithmetic operators. Now we have learnt
about the logical operators (AND OR NOT) too. So the new hierarchy of operators is given
below.
15. (Expression 1 ? expression 2 : expression 3)
It is generally used to avoid small if-else statement. Remember it is not the alternative of if-else
clauses. It can used at some places.
Lets try to understand it with some simple example.
if (x==10)
Y=3;
else
Y=9;
In the above we are basically checking if x is equal to 10. If condition turns true then it will assign
y as 3. Otherwise it will assign y as 9. The same task can be completed using ternary operator.
Y=(x==10 ? 3 : 9);
Conditional Operators
They are also called ternary operators. As we have to use three
arguments to use this operator.
General form of Conditional/Ternary operator
16. Nested Conditional Operator
Well nested conditional operators are used very rarely but
they are good to make the program compact.
A small example of nested ternary operator is given below
Small = ( x < y ? ( x > z ? 9: 10 ) : ( y > z ? 14: 16 ) ) ;
In the above example small is the variable and it will store
9 if x<y and x>z
10 if x<y and x<z
14 if x>y and y>z
16 if x>y and y<z
Sounds confusing? Well that’s why they are used rarely.
But like our example, it can sometimes make the program
compact.
17.
18.
19.
20.
21.
22.
23.
24.
25. Switch statement:
The switch statement is also an selection statement.It is mostly a matter of
preference
which you use,if we want to perform addition,subtraction,multiplication
and division at your selection this can be done by switch statement.The
syntax of switch statement is as follows
switch(expression)
26. A do-while statement is a looped structure which is
repeated for that particular condition. The
syntax of do-while statement is as follows
Do-while statement:
27. While loop:
This statement is also a looped structure, in this we pass
some condition in while if that
condition is true the loop will continue if it is false the
loop terminate.
Let us see the syntax
while(condition is true)
{
action 1;
}
28. example:
for(i=1;i<=n;i++)
{
f=f*i;
}
For loop:
This statement is very simpler than the other statements
in this we declare initialization
value, test value and increment or decrement at a time.
Let us see the syntax and one example
of this statement
for(initial value;test;increment or decrement)
{
action 1;
}
action 2;