C programming-apurbo datta
-
Upload
apurbo-datta -
Category
Education
-
view
306 -
download
2
Transcript of C programming-apurbo datta
![Page 1: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/1.jpg)
C Programing
Created by APURBO DATTA
![Page 2: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/2.jpg)
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.
![Page 3: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/3.jpg)
Language year Developed ByALGOL 1960 International GroupBPCL 1967 Martin RichardsB 1970 Ken ThompsonTraditional C 1972 Dennis RitchieK & R C 1978 Kernighan & Dennis
RitchieANSI C 1989 ANSI CommitteeANSI/ISO C 1990 ISO CommitteeC99 1999 Standardization
Committee
![Page 4: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/4.jpg)
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.
![Page 5: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/5.jpg)
![Page 6: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/6.jpg)
![Page 7: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/7.jpg)
![Page 8: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/8.jpg)
![Page 9: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/9.jpg)
variables
![Page 10: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/10.jpg)
![Page 11: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/11.jpg)
![Page 12: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/12.jpg)
![Page 13: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/13.jpg)
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 asIf (y<=6)Both the statements will give the same results. You can use anyone of them.
![Page 14: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/14.jpg)
Hierarchy of OperatorsI 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.
![Page 15: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/15.jpg)
(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 OperatorsThey are also called ternary operators. As we have to use three arguments to use this operator.
General form of Conditional/Ternary operator
![Page 16: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/16.jpg)
Nested Conditional OperatorWell 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 belowSmall = ( x < y ? ( x > z ? 9: 10 ) : ( y > z ? 14: 16 ) ) ;In the above example small is the variable and it will store9 if x<y and x>z10 if x<y and x<z14 if x>y and y>z16 if x>y and y<zSounds confusing? Well that’s why they are used rarely. But like our example, it can sometimes make the program compact.
![Page 17: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/17.jpg)
![Page 18: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/18.jpg)
![Page 19: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/19.jpg)
![Page 20: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/20.jpg)
![Page 21: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/21.jpg)
![Page 22: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/22.jpg)
![Page 23: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/23.jpg)
![Page 24: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/24.jpg)
![Page 25: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/25.jpg)
Switch statement:The switch statement is also an selection statement.It is mostly a matter of preferencewhich 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)
![Page 26: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/26.jpg)
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:
![Page 27: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/27.jpg)
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;
}
![Page 28: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/28.jpg)
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;
![Page 29: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/29.jpg)
![Page 30: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/30.jpg)
![Page 31: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/31.jpg)
![Page 32: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/32.jpg)
![Page 33: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/33.jpg)
![Page 34: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/34.jpg)
![Page 35: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/35.jpg)
![Page 36: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/36.jpg)
![Page 37: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/37.jpg)
![Page 38: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/38.jpg)
![Page 39: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/39.jpg)
![Page 40: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/40.jpg)
![Page 41: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/41.jpg)
![Page 42: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/42.jpg)
![Page 43: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/43.jpg)
![Page 44: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/44.jpg)
![Page 45: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/45.jpg)
![Page 46: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/46.jpg)
![Page 47: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/47.jpg)
![Page 48: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/48.jpg)
![Page 49: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/49.jpg)
![Page 50: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/50.jpg)
![Page 51: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/51.jpg)
![Page 52: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/52.jpg)
![Page 53: C programming-apurbo datta](https://reader035.fdocuments.us/reader035/viewer/2022062503/587d033c1a28ab1e7e8b6e05/html5/thumbnails/53.jpg)