0% found this document useful (0 votes)
57 views4 pages

Assignment-1: - : Basics

The document provides a list of 37 programming assignments to complete involving basic C programming concepts like data types, operators, arrays, matrices, functions etc. The assignments include debugging programs with gdb, exploring compiler options, basic math operations, string conversions, file I/O, and more advanced topics like polynomial evaluation, matrix operations, determining day of week from a date. Students are expected to write and analyze code demonstrating understanding of fundamental C programming and standard library functions.

Uploaded by

BHAVIK KALPESH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views4 pages

Assignment-1: - : Basics

The document provides a list of 37 programming assignments to complete involving basic C programming concepts like data types, operators, arrays, matrices, functions etc. The assignments include debugging programs with gdb, exploring compiler options, basic math operations, string conversions, file I/O, and more advanced topics like polynomial evaluation, matrix operations, determining day of week from a date. Students are expected to write and analyze code demonstrating understanding of fundamental C programming and standard library functions.

Uploaded by

BHAVIK KALPESH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

C&DS DESD Aug 2015

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)

CDAC ACTS, Pune 1


C&DS DESD Aug 2015

for eg:- 1:2:30 ==> 3750


8000 ==> 2:13:20
11. Go through the functions provided in math.h, ctype.h files
12. Formatted I/O using printf (%5d, %05d,%-5d,%8.2f, %.2f etc.)
13. Given a=10,b=20,c=30 evaluate the following
d=++a,++b,++c,a+5;
d=(++a,++b,++c,a+5);
14. Justify the output of following code.
int a=10,b;
b=sizeof(++a)
printf(“a=%d,b=%d\n”,a,b);
15. Give the output of following code.
char c1='A';
printf(“%d,%d\n”,sizeof(c1), sizeof('A'));
16. Evaluate following expressions,find x,y,z values in each case assuming x=1,y=5 initially,
what do you observe
a) z=++x && ++y;
b) z=--x && --y;
c) z=++x || ++y;
d) z=--x || --y;

17. Find sum & avg of elements in an array


18. Find min & max element in an array
19. Reversing an array in memory
20. Addition of two arrays
21. Addition, Subtraction of long integers
22. No. conversions (decimal, binary, octal, hexadecimal)
23. Polynomial evaluation where coefficients are stored in an array
a0xn+a1xn-1+a2xn-2+...+an
24. Addition, Subtraction, Multiplication of two matrices

CDAC ACTS, Pune 2


C&DS DESD Aug 2015

25. Transpose of a matrix


26. Trace of a matrix
27. Determinant for 2x2 , 3x3 matrices
28. Solving linear equations
a1x+b1y=c1; a2x+b2y=c2
a1x+b1y+c1z=d1; a2x+b2y+c2z=d2; a3x+b3y+c3z=d3
29. Generation of identity, null matrices
30. Checking whether given matrix is identity or not?
31. Checking whether given matrix is null or not?
32. Finding day of week based on reference date, say 1st January 1970 which is thursday.
(Hint:- calculate no.of days elapsed from reference date to given date)

CDAC ACTS, Pune 3


C&DS DESD Aug 2015

For Analysis – Program may not be required


33. Go through the functions provided in math.h, ctype.h files
34. Using sizeof operator find no.of bytes required for different data types like int,float,double,char with
applicable qualifiers like short,long,long long
35. Find the max,min values supported by different data types with the constants defined in limits.h
36. Check the applicable sections as per symbol table printed by objdump for
1. initialized global variables int a=10;
2. uninitialized global variables int b;
3. initialized constant global variables const int c=20;
4. zero intialized global variables int d=0;
5. functions
37. Explore various format specifiers used in printf, scanf
%5d, %05d,%-5d,%8.2f, %.2f ,%e,%g,%u,%ld,%lu,%lld,%llu

CDAC ACTS, Pune 4

You might also like