Download presentation
Presentation is loading. Please wait.
Published byJonah Baker Modified over 8 years ago
1
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com
2
Flowchart Algorithm Program 2www.gowreeswar.com
3
Flowchart 3www.gowreeswar.com
4
Algorithm Step 1:start Step 2: read two values for a and b Step 3: calculate the sum of a and b i.e. c=a+b; Step 4: print ‘c’ value Step 5:stop 4www.gowreeswar.com
5
Character Set Keywords Variables Constants Data types Operators 5www.gowreeswar.com
6
Character Set 0 to 9 digits A to Z a to z alphabets +,. $ ^ = ; “ ‘ @ ? / special symbols 6www.gowreeswar.com
7
7
8
Keywords (Reserve words) auto static extern register if else for while do switch case break return continue return goto typedef struct union enum int float double long char unsigned sizeof const default void volatile signed 8www.gowreeswar.com
9
Variable 9www.gowreeswar.com
10
Constant 3 ways 1) const keyword const a=22; 2) macro #define a 22 3) enum 10www.gowreeswar.com
11
Built- in Derived User definedvoid Example: int float char long double Arrays Pointers Functions Structures Unions enums 11www.gowreeswar.com
12
keyword Memory (in Bytes) Rangeformat char1-128 to +127%c int2-32768 to +32767%d float4-3.4e38 to +3.4e38%f double8-1.7e308 to +1.7e308%lf long4 -2,147,483,648 to 2,147438647 %ld unsigned int20 to 65535%u unsigned long40 to 4,294,967,295%lu long double10-1.7e932 to +1.7e932%Lf 12www.gowreeswar.com
13
Operators Arithmetic Relational Logical Increment Decrement Ternary or Conditional Assignment Bitwise Sizeof Special Operators 13www.gowreeswar.com
14
Arithmetic Operator Use Example Result +Addition5 + 27 -Minus5 – 23 *Multiplication5 * 210 /Divide5 / 22 %Reminder5 % 21 14www.gowreeswar.com
15
Relational OperatorUseExampleResult <Less than5 > 2True >Greater than5 < 2False <=Less than or equal 5 >= 2True >=Greater than or equal 5 <= 2False ==Equal5 == 2False !=Not equal5 != 2True 15www.gowreeswar.com
16
Logical OperatorUseExampleResult &&Andx=5,y=2 x>2 && y> 1 True ||Orx==2 || y==1False !Not!(x==2)True 16www.gowreeswar.com
17
Increment pre increment ++a Example a=10; b=++a; ( a= a+1 ; b=a ) o/p: a=11 b= 11 post increment a++ Example : a=10; b=a++; ( b=a; a=a+1 ) o/p: a=11 b= 10 17www.gowreeswar.com
18
Decrement pre decrement --a Example a=10; b=--a; ( a= a-1 ; b=a ) o/p: a=9 b= 9 post decrement a-- Example : a=10; b=a--; ( b=a; a=a-1 ) o/p: a=9 b= 10 18www.gowreeswar.com
19
Ternary Condition ? Expression 1 : Expression 2 true false 19www.gowreeswar.com
20
Assignment = OperatorExampleMeaning +=X + = YX=X+Y -=X - = YX=X-Y *=X * = YX=X*Y /=X / = YX=X/Y %=X %= YX=X%Y 20www.gowreeswar.com
21
Bitwise Operator use &Bitwise and |Bitwise or ~Bitwise not ^Exclusive or <<Shift left >>Shift right 21www.gowreeswar.com
22
sizeof(), (comma). (dot) -> (arrow) 22www.gowreeswar.com
23
C Instructions type declaration Arithmetic Input/output Control 23www.gowreeswar.com
24
Type Declaration int a,b; float c,d; char ch; 24www.gowreeswar.com
25
Arithmetic c = a + b; 25www.gowreeswar.com
26
Input - output 26www.gowreeswar.com
27
Input FormattedUnformatted scanf() fscanf () gets () fgetc () 27www.gowreeswar.com
28
output FormattedUnformatted printf() fprintf() puts() fputc() 28www.gowreeswar.com
29
Function : printf() header file : stdio.h Syntax : printf(“format string”,var1,var2…); Examples: printf(“welcome to c world”); printf(“%d%d”,a,b); printf(“sum=%d”,c); 29www.gowreeswar.com
30
Function : scanf() header file : stdio.h Syntax : scanf(“format string”,&var1,&var2…); & - address of variable Examples: scanf(“%d%d”,&a,&b); scanf(“%f%d”,&x,&y); 30www.gowreeswar.com
31
comments pre processors global declaration void main() { === } 31www.gowreeswar.com
32
comments pre processors global declaration int main() { === Return 0; } 32www.gowreeswar.com
33
comments pre processors global declaration main() { === } 33www.gowreeswar.com
34
/* welcome program */ #include void main() { printf(“welcome to C”); } Output welcome to C 34www.gowreeswar.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.