C- TOKENS
Sakshi Agrawal
immediate joiner | Backend Developer | Java |Spring Boot|Microservices|Hibernate|Jenkins|Bitbuket|Kubernetes|kafka|Putty|Cassandra|Software Engineer
Today I am here with my new Technical Learning, hope you all might get benefited from it
Hello folks!....
Hope You All are having good Reading
Below I'm sharing my complete learning regarding Technical Concept (C Language). Have a glance on this and enjoy your reading.
C Tokens the smallest individual words we are using in developing a c program are called tokens. They are of different types.
How to download C++ compiler: open any browser. Type download turbo c++ by akki. Download winrar.
Example program:
Identifier naming rules:
2. Numbers allowed but not at first position.
3. No special char except underscore.
4. Spaces not allowed.
5. Keywords are not allowed.
6. Names are case sensitive. i.e. lower and upper are different.
7. Duplicate names are not allowed.
8. Name may contain up to 32 char and excess char's ignored by the compiler automatically.
Constants: Fixed values. we can't change the constant value during program execution. Constant value during program execution. Constant value should be provided at the time of declaration only and further Initializations not allowed.
Eg:
String: A group of characters, It is alpha-numeric. i.e. it is collection of alphabets, numbers and special characters. Eg: char city[ ]="Hyd-16";
Note:
2. String variable size never smaller than the string. Otherwise we are getting error.
3. We can't copy a string into a variable using = operator. For this we have to use strcpy( ) available in string.h
4. We can't compare two strings using == operator. For this we have to use strcmp( ) available in string.h
Operators: Operator is a special symbol designed for a particular task [work]. In C we are having 44 operators and 14 separators. Based on no. of operands participating in operation, the operators divided into 3 types.
Based on the operation, the operators divided into several types.
2. Arithmetic operators[ +, -, *, % , /]: They are used to perform mathematical operations. Eg: a+b, a-b, a*b,.............. %- modulus [Remainder]: Eg: 5%2=1
Note: If divisor bigger than dividend then dividend is the answer .
5.0%2.0==Error
Note: In C & C++ we can't perform floating modulus with% operator. we should have to use fmod() belongs to <math.h>
Note: If numerator is negative then result also negative
Note: Any number%10 gives the last digit.
/ ==> division [Quotient] : 5/2=2[int/int=int] 5.0/2=2.500000
Note: Any one or both are float answer also float 5/2.0=2.500000 5.0/2,0=2.500000 (float)5/2=2.500000[explicit type casting] int a=2.3; =>Output => a=2[implicit type casting] 5/(float)2=2.500000 (float)(5/2)=2.000000
Note: In division any one operand is negative then result also negative. Both are positive/ negative then result is positive.
Note: Any n/10 removes the last digit.
Method 1: write a program to print a 3 digit no in reverse order without using loop. Eg: 123 as 321
Method 2:-
Relational Operators [ == (Comparison), <, >, <=, >=, !=(not equal)]:They are used to check the condition or expression is true or false. If condition true always it return 1. Condition false it return 0.
Logical Operators:
To combine two or more expressions we are using logical operators\
Truth Tables:-
Note: in C other than ) anything is 1 i.e. true.
3.Increment / Decrement / modify Operator[++/--]: They are used to increment or decrement a variable value by 1. Eg: int a=8; a++; ==>a=a+i ==>a=9 int a=2; a-- ==> a=a-1;==> a=1
领英推荐
Note: Until assignment to any other variable, pre & post operations are same.
Note: we can't perform ++/ -- on expressions.
Output: a=5, b=5, c=5, d=1.
Note: In && operation when left exp false right exp not checked.
Note: In || operation when left exp true then right exp not checked.
Note: we can't perform inc/ decr on constants/ expressions.
Note: In printf() execution order is right to left.
a=5 a= a++ + ++a; priority: ++a,+,=,a++ 1. ++a ==> a=6; 2. a= a+ a==>a=6+6 3.a=12 4. a++ ==> a=13
Compound assignment operator / short hand operators:-
Here assignment operator used with other operators as follows. Assignment operator have the least priority. += , -=, *=, %=, /=,<<=,>>=,~=,.....
int a =2; a+=5; i.e. a=a+5=>a=7 int b=20; b*=5; i.e. b=b*5=>b=100 float c=5; c/=2; i.e. c=c/2=> c=2.500000
NOTE:- Here = have more priority than , operator.
Address Operators:
Sizeof() operator: It returns the no of bytes taken by a variable / data type /value.
Note: Integer can't convert to float
BITWISE OPERATORS
Bitwise operator's works on bits. Turbo-c is a 16 bit compiler. Due to this bitwise operations are limited to 16 bits only [ 2^0 to 2^15]. Bitwise operators operate integer type values only. We have to calculate only the on bits[1].
When the first bit[sign bit] is 1 then the number is negative and it is 0 then the number is positive. They are very much used in system software development.
Note: Bitwise operator is low level feature.
C-language supports following bitwise operators.
&- Bitwise AND | - Bitwise OR ^ - XOR==> Exclusive OR ~ - Compliment operator << -Left shift operator >> - Right shift operator
&- Bitwise and: In this bits are 1's then result bit is 1. Otherwise result bit is 0. Eg: 25 & 15 =9
| -Bitwise or: In this both bits are 0's then result bit is 0. Otherwise result bit is 1. Eg: 25 | 15 =31
^ - XOR [Exclusive OR]: In this both bits are same then result bit is 0. Otherwise result bit is 1. Eg: 25 ^ 15= 22
~ - Compliment operator: In compliment operation the bits are complimented i.e. 1's become 0's and 0's become 1's. Due to this +Ve no. become -Ve and -Ve become +Ve. Eg:~25 => -26
Note: When starting bit is 1 given no is -Ve. Eg: ~ -25 ==> +24
<< - Left shift operator: In left shift, the specified no. of bits are deleted from left side and the same no. of zero added on right side, In left shift operation, most probably the value is multiplied with 2 that no. of times. Eg: 25<<1=50, 25<<2=100, 25<<15=-32768, 25<<16=0
Note: When stating bit 1 no. is negative.
<< - Right shift operator: In right shift operation, the bits are moved to right side i.e. the specified no. of bits are deleted from right side and same no. of zero's are added left side. Due to this always the number is divided with 2 that no. of times. Eg: 25>>1=12, 25>>2=6, 25>>3=3, 25>>4=1,25>>5=0.
Thankyou For Reading!
Published by:?Sakshi Agrawal
Date?:?February 17,2022