Basic Programming Lab
Basic Programming Lab
— — 0x07
Operator Precedence
() Functional call
[] Array element reference
Left to right
-> Indirect member selection
. Direct member selection
Logical negation
!
Bitwise(1 's) complement
~
Unary plus
+
Unary minus
-
Increment
++
Decrement Right to left
--
Dereference (Address)
&
Pointer reference
*
Returns the size of an
sizeof
object
(type)
Typecast (conversion)
* Multiply
/ Divide Left to right
% Remainder
+ Binary plus(Addition)
Left to right
- Binary minus(subtraction)
= Equal to
Left to right
!= Not equal to
= Simple assignment
*= Assign product
/= Assign quotient
%= Assign remainder
+= Assign sum
-= Assign difference Right to left
&= Assign bitwise AND
^= Assign bitwise XOR
|= Assign bitwise OR
<<= Assign left shift
>>= Assign right shift
printf("\n|%.2f|",
Two positions after the decimal |12.35|
12.3456);
#include <stdio.h>
int main()
{
int i;
return 0;
}
Assignment
//0x06
//Use scanf for input in Every Program
1. Write a program to print formatted integers.
Input : 123
Output:
a) |1|2|3| | | | | | | | //Width = 10
b) | | | | | | | |1|2|3| //Width = 10
Input : 1234.56
Output:
a) |1|2|3|4|.|5|6|0|0|0|0|
b) |1|.|2|3|4|5|6|0|e|+|0|3|
c) |1|2|3|5|
d) |1|2|3|4|.|6|
e) |1|2|3|4|.|5|6|0| | |
f) | | |1|2|3|4|.|5|6|0|
g) | |1|.|2|3|5|e|+|0|3|
/*
--------------------------------------------------
|Author : Your_Name |
|Roll No: Your_Roll_No |
|Department: Your_Department |
--------------------------------------------------
*/