Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Modulus Operator %
- Result is always Remainder
- a= 5 % 2; 1
- a= 18 % 5; 3
- a= 33 % 4; 1 4X8=32 rem = 1
- a= -5 % 2 ; -1
- a= 5 % -2 ; 1 5/-2; -2
- Divident = Divisor X Quotient + Remanider
- 5 = 3
- 5/2 Quo=2 Rem=1
- a=5/2; 2
- a=5%2; 1
- Example
- Divident 5 Divident = Divisor X Quo + Rem
- Divisor 2 5 = 2 X 2 + 1 = 4+1 = 5
- Q 2
- R 1
- %%%%%%%%%%%
- a= 5 / -2 ; -2 Divident = Divisor X Quo + Rem
- a= 5 % -2 ; -1 X 1 5 = -2 X -2 + (-1) = 4 + (-1)= 3
- %%%%%%%%%%%
- Rule for Modulus
- 1. Result is always Remainder
- 2. Result Sign is always same as numerator.
- 3. Result sign does not depend on sign of Denominator.
- 4. Mod (%) operator does not apply on float value.
- C Lang
- +/+ => + + % + => +
- +/- => - + % - => +
- -/+ => - - % + => -
- -/- => + - % - => -
- %%%%%%%%%%%
- a=5.0 / 2; 2.5 Quotient
- a=5.0 % 2; 1 Remainder
- Divident = Divisor X Quo + Rem
- 5.0 = 2 X 2.5 + 1 = 5 + 1 = 6
- %%%%%%%%%%%
- a= 12 % 10; 2 num % 10 will gives unit value as it result
- a= 154 %10; 4
- a= 456231 %10; 1
- a=-75 %10; -5
- a= 20 % -10; 0
- a= 24 % -10; 4
- a= 8 % 10; 8 In Mod Operator, When num<Denominator Result always numerator
- a= 3 % 13; 3
- a= 8 % 45; 8
- a= 32 % 78; 32
- Arithematic Operator
- * / %
- + -
- = (Assignment Operator)
- Data Type
- int %d(decimal) or %i(int) ==> Format Specifier
- char %c
- float %f
- Basic C Program
- void main()
- {
- }
- Header file is Optional (#include<_____>)
- Mukesh Height 150cm
- School Dis 10km
- C-Tokens (Unit)
- Keywords
- Operator
- Seperator ;
- Variable
- Constant
- void Tokens
- main() Keyword: void 1
- { operator: () () 4
- printf Seperators: {} ; 3
- ( Identifier : main printf 2
- "Hello World" constant : "Hello world" 1 Total Tokens=11
- )
- ;
- }
- In C program, There can be
- N no of spaces, N no of Tab, N no of New Lines Between any 2 tokens
- void main()
- {
- printf("Hello World");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement