Download presentation
Presentation is loading. Please wait.
Published byAdrian Bryan Modified over 9 years ago
1
The C Character Set: The Characters used to form words, numbers and Expression depends upon the computer on which program runs. Letters. Digits White spaces Special characters Basic of Computer & 'C' Programming1
2
Character Set: Basic of Computer & 'C' Programming2 1.Letters2.Digit 3.White Space Capital A to Z All Decimal digit 0-9 Blank space, New Line Small a to zHorizontal Tab, Vertical Tab
3
Special Characters: Basic of Computer & 'C' Programming3 SymbolNameSymbolName,Comma\Back Slash.Dot or Period~Tilde ;Semi Colon_Under score “ Quotation Mark $Dollar ! Exclamation Mark ?Question Mark |Vertical Bar^Caret
4
Delimiters: Basic of Computer & 'C' Programming4 DelimitersUses : ColonUseful for label. ; SemicolonTerminates statements. ( ) Parenthesis Used in expression & Function [ ] SquareUsed for array Declaration { } curly BraceScope of statement # HashPreprocessor directive, CommaVariable separator
5
C Key Word: The c key words are reserved word by the compiler. All c keywords have been assigned fixed meaning. The keywords cannot be used as variable names because they have been assigned fixed job. E.g Auto, Break, Case, Char, Const, Default, Continue, Do, Double, Else, If, Float, Int,For, While, Void, Switch, Return, Long, struct Basic of Computer & 'C' Programming5
6
Identifiers:- Identifiers are names of variable, function and arrays. They are user-defined names consisting of sequence of letters and digit with the letters as the 1st character. Lower case letters are preferred. However the upper case letters are also permitted. The (-) underscore symbol can be used as an identifier. In general underscore is used as a link between two words in long identifiers. Example: #define N 10 #define a 15 Here N, a are user define identifiers. Basic of Computer & 'C' Programming6
7
Constants: The constants in c are applicable to the values, which do not change during the execution of a program. Basic of Computer & 'C' Programming7 1.Numeric Constant2. Character Constant. a) Integer Constanta)Single Char Constant b) Real Constant b)String Constant
8
Variables: A variable is a data names used for storing a data values. Its value may be changed during the program execution. Example: Height, Average, Sum, etc. Basic of Computer & 'C' Programming8
9
Data Types: All c compilers support a variety of data types. This enables the programmer to select the appropriate data types as per the need of the application. Generally data is represented using numbers or characters. Basic of Computer & 'C' Programming9
10
Data types and their control strings. Basic of Computer & 'C' Programming10 Data TypesSizeRangeFormat string Char1-128 to 127%c Unsigned Char10 to 255%c Short or int2-32768 t0 32767%i or %d Unsigned int20 to 65535%u Long4 -2147483648 to 2147483647 %ld Unsigned Long40 to 4294967295%lu Float43.4 e -308 to 1.7 e +308%lf Double81.7 e -308 to 1.7 e +308%lf
11
Operators & Expression Operator: Arithmetic Operator- +, -, *, /, %. Logical- &&, ||, ! Relational -, = Increment - ++ Decrement – Basic of Computer & 'C' Programming11
12
Unary Arithmetic Operates:- Basic of Computer & 'C' Programming12 OperatorDescription or Action -Minus ++Increment - Decrement &Address Operator Size ofGive the size of variable
13
Ex-1 x=37, y=5 (a) x+y =42 (b) x-y =32 (c) x*y =185 (d) x/y =7 (e) x%y =2. Basic of Computer & 'C' Programming13
14
Ex-2 #include void main() { int x,y,z,a,b,c,d; x=22; y=3; a=x+y; b=x-y; c= x/y; z=x*y; d=x%y; printf(“a=%d,b=%d,c=%d,z=%d,d=%d\n”,a,b,c,z,d); } a=25, b=19, c=7, z=66, d=1 Basic of Computer & 'C' Programming14
15
Increment operator + + Decrement Operator - - Q- Find the Output of the following programs 1. int i; i=2; printf(“i=%d”,i); i=2 printf(“i=%d\n”,++i); i=3 printf(“i=%d\n”,i); i=3 Basic of Computer & 'C' Programming15
16
int i; i=2; printf(“i=%d\n”,i); i=2 printf(“i=%d\n”,i++); i=2 printf(“i=%d\n”,i); i=3 int m,y; m=3; y=++m; pritnf(“y=%d\n”,y); y=4 y=m++; printf(“y=%d\n”,y); y=4 printf(“m=%d\n”,m); y=5 Basic of Computer & 'C' Programming16
17
Find the output of the following programs 1. int m,n; m=3; n=3; ++m; n++; printf(“m=%d and n=%d\n”,m, n); m=4 & n=4 Basic of Computer & 'C' Programming17
18
2. int m,n; m=3; n=3; printf(“m=%d and n=%d\n”,++m,n++); m=4 & n=3 find the Output of the following programs #include void main() { i,j,m,n; i=9; j=11; m=++i/2-2; printf(”m=%d\n”,m); n=j++ -1; printf(“n=%d\n”,n); } m=3n=10 Basic of Computer & 'C' Programming18
19
Q. Find the value of c & d 2 nd a,b; a=2; b=3;c=6,d=12 c=++a; c*=2; d=b++; d*=b; Basic of Computer & 'C' Programming19
20
Q.Find the output of following Program:- #include main() { i,j,k; i=10; j=5; k=++i-j; printf(“k=%d\n”,k); k=i++ +j; printf(“k=%d\n”,k); } K=6 K=16 Basic of Computer & 'C' Programming20
21
Q. Find the output of following. #include main() { int x,z; x=6; z=++x + x++; printf(“z=%d\n”,z); printf(“x=%d\n”,x);” } z=14,x=8 Basic of Computer & 'C' Programming21
22
Q. Find the output of the following program. #include int x; int z; x=6; z=x++ + ++x; printf(“z=%d and x=%d\n”,z,x); } z=14; x=8; Basic of Computer & 'C' Programming22
23
Q. Find the output of following program. #include void main() { int x,y,z; x=7;y=3; x=x++ + y++; printf(“z=%d x=%d y=%d\n”,z,x,y); } z=14 and x=8 Basic of Computer & 'C' Programming23
24
Thanks Basic of Computer & 'C' Programming24
25
Basic of Computer & 'C' Programming25
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.