12/12/2021, Sun
Arithmetic o/p: + - * / % (binary operators)
+ - (unary sign operators)
int a;
a = 10;
a = +10; //sign operator
a = -10; //sign operator
one operand ==> unary operator
two operands ==> binary operator
three operands ==> ternary oprator
float c;
c = 5.0+2.0;//7.0
c = 5.0-2.0;//3.0
c = 5.0*2.0;//10.0
c = 5.0/2.0;//2.5
c = 5.0%2.0;//invalid
2.0 | 5.0 | 2.5 quotient
5.0
-----------
0 remainder
==============================
Relational operators:
< <= > >= == != (binary o/p) ==> T/F (boolean type) --> 1/0 (integer type) ==> conditions
int c;
c = 5>2; //1
c = 5>=2; //1
c = 5<2;//0
c = 5<=2;//0
c = 5==2;//0
c = 5!=2;//1
===============================
logical operators: digital gates ==> i/p boolean T/F ==> o/p boolean T/F
&& || !
&& AND gate
|| OR gate
! NOT gate
Z = A && B;
int c;
c = 10 && 0; //0
T && F ==> F ==> 0
c = 10 && 5; //1
T && T ==> T ==> 1
T/F (boolean type) --> 1/0 (integer type)
integer type ==> boolean type
0 ==> False
non-zero ==> True
AB Z
----------------------
00 0
01 0
10 0
11 1
------------------------
Z = A || B;
int c;
c = 10 || 5; //1
T || T ==> T ==> 1
AB Z
----------------------
00 0
01 1
10 1
11 1
------------------------
Z = !A;
int c;
c = !(10); //0
=!(T) ==> F ==> 0
A Z
----------
0 1
1 0
----------
decisions ==> combination of conditions
int a,b,c;
a>b && a>c
=============================
12/13/2021, Mon
bitwise operators:
& ^ | ~ << >>
& bitwise AND gate
^ bitwise X-OR gate
| bitwise OR gate
~ bitwise NOT gate
<< bitwise left shift
>> bitwise right shift
int c;
c = 10 && 5; //1
T && T ==> T ==> 1
c = 10 & 5; //0
10 ==> 1010
5 ==> 0101
-------------------------
0000 ==> 0
int c;
c = 10 || 5; //1
T || T ==> T ==> 1
c = 10 & 5; //15
10 ==> 1010
5 ==> 0101
-------------------------
1111 ==> 15
int c;
c = !(10); //0
= !(T) ==> F ==> 0
c = ~(10); //5
10 ==> 1010 ==> 0101 ==> 5
int c;
c = 10 ^ 5; //15
10 ==> 1010
5 ==> 0101
-------------------------
1111 ==> 15
int c = 10;
c = c << 2;
12/15/2021, Wed
Type Casting:
implicit type casting
explicit type casting - (type)
int <--> float
int <--> char
ASCII Table:
https://www.educba.com/ascii-value-in-c/
A-65, Z-90
a-97,z-122
'0'-48, '9'-57
first character - 0 - NUL
last character - 127 - DEL
----------------------------------------------
#include <stdio.h>
int main()
{
int a,b;
float c;
a = 5;
b = 2;
c = (float)a/(float)b; // c = 5.0/2.0;
printf("c is %f\n", c);
return 0;
}
-------------------------------
#include <stdio.h>
int main()
{
int a,b,c; //delimiter
c = (a=10, b=20, a+b);
printf("c is %d\n", c);
return 0;
}
----------------------
Operators Precedence and Associativity:
http://senseactsolutions.com/C/C%20Operators.html
Control statements:
selection statements
if statement: if, else
switch statement: switch, case, default
iterative statements (loops)
for loop: for
while loop: while
do loop / do-while loop: do
jump statements
return statement: return
break statement: break
continue statement: continue
goto statement: goto
Assignments:
12/12/2021, Sun:
logical gates: AND, OR, NOT, NAND, NOR, XOR, XNOR
number systems and its conversions : binary, octal, decimal, hexa-decimal
study keywords: signed, unsigned, short, long, sizeof, const
12/12/2021, Mon:
?: conditional operator (alternative to if-else)
++ increment operator
-- decrement operator
(type) typecasting operator
, comma operator
() function call operator/parenthesis operators
12/15/2021, Wed
extern keyword
control statements - if, else, switch, case, default, for, while, do, break, continue, goto
12/18/2021, Sat:
dangling else problem
for, while, do, break vs. continue, goto.
convert decimal 456 into octal and hexa-decimal
octal ==> 710 ==> 7*64 + 1*8 + 0*1 ==>448+8+0 ==> 456
hexadecimal ==> 1C8 ==> 1*256 + 12*16 + 8*1 ==> 256+192+8
12/22/2021, Wed:
23/32 keywords
30/34 operators
dangling else problem
extern keyword
convert hexa-decimal 425 into decimal and octal
decimal => 4*256+2*16+5*1 ==> 1024+32+5 ==> 1061
binary ==> 010 000 100 101 ==> 2045
12/26/2021,Sun:
write a program to add array elements - without functions, with functions
how to pass individual elements of an array to function.
2-D arrays
3-D arrays
number system convertions