Assignment-1: - : Basics
Assignment-1: - : Basics
Assignment-1: -
Work with known programs and debug them with gdb wherever necessary. Use various options of gcc
like -E, -c, -S, -g, -O0, -O1, -O2, -O3 etc. to understand various development phases, optimizations.
Also explore other tools like cpp, as, ld etc.
Basics:-
1. Swapping of two no.s (with, without temporary, one line code with xor operator)
2. Write a program to find area, perimeter of the circle
a) consider PI as symbolic constant
b) consider pi as constant double variable
Check the preprocessed output for above program using -E option of gcc or with the tool cpp in both
the cases, which is preferred among these two alternatives,justify.
3. Differentiate between post, pre decrement operators
a) k=i++, k=++i
b) y=x++*10, y=++x*10
c) q=p--/3, q=--p/3
4. Reversing 4 digit no.
5. Conversion of ip address in a.b.c.d format into 32 bit unsigned integer and vice versa
6. Using bitwise operators for the expressions for
a) set kth bit
b) reset kth bit
c) flip kth bit
d) query the kth bit
7. Biggest of 3 no.s using conditional operator
8. Using sizeof operator find no.of bytes required for different data types
9. Find the max,min values supported by different data types with the constants defined in limits.h
10. Write a program to convert time between hh:mm:ss format and total no.of seconds(note:- you may take
the input hh,mm,ss separately, need not be in string form)