===================================== Part 2 : C programming FAQs ===================================== .. _malloc: https://man7.org/linux/man-pages/man3/realloc.3.html .. _calloc: https://man7.org/linux/man-pages/man3/calloc.3p.html .. _realloc: https://man7.org/linux/man-pages/man3/realloc.3p.html .. _reallocarray: https://man7.org/linux/man-pages/man3/realloc.3.html .. _free: https://man7.org/linux/man-pages/man3/free.3p.html .. _memset: https://man7.org/linux/man-pages/man3/memset.3p.html .. _memcpy: https://man7.org/linux/man-pages/man3/memcpy.3.html .. _memccpy: https://man7.org/linux/man-pages/man3/memccpy.3p.html .. _memmove: https://man7.org/linux/man-pages/man3/memmove.3.html .. _mempcpy: https://man7.org/linux/man-pages/man3/mempcpy.3.html .. _memmem: https://man7.org/linux/man-pages/man3/memmem.3.html .. _memfrob: https://man7.org/linux/man-pages/man3/memfrob.3.html .. _memcmp: https://man7.org/linux/man-pages/man3/memcmp.3p.html .. _bcopy: https://man7.org/linux/man-pages/man3/bcopy.3.html .. _bstring: https://man7.org/linux/man-pages/man3/bstring.3.html .. _bcmp: https://man7.org/linux/man-pages/man3/bcmp.3.html .. _bzero: https://man7.org/linux/man-pages/man3/bzero.3.html .. _fopen: https://man7.org/linux/man-pages/man3/fopen.3p.html .. _fdopen: https://man7.org/linux/man-pages/man3/fdopen.3p.html .. _freopen: https://man7.org/linux/man-pages/man3/freopen.3p.html .. _fclose: https://man7.org/linux/man-pages/man3/fclose.3p.html .. _fmemopen: https://man7.org/linux/man-pages/man3/fmemopen.3p.html .. _fflush: https://man7.org/linux/man-pages/man3/fflush.3p.html .. _fcloseall: https://man7.org/linux/man-pages/man3/fcloseall.3.html .. _fseek: https://man7.org/linux/man-pages/man3/fseek.3.html .. _ftell: https://man7.org/linux/man-pages/man3/ftell.3p.html .. _rewind: https://man7.org/linux/man-pages/man3/rewind.3p.html .. _fgetpos: https://man7.org/linux/man-pages/man3/fgetpos.3p.html .. _fsetpos: https://man7.org/linux/man-pages/man3/fsetpos.3p.html .. _fprintf: https://man7.org/linux/man-pages/man3/fprintf.3p.html .. _fscanf: https://man7.org/linux/man-pages/man3/fscanf.3p.html .. _printf: https://man7.org/linux/man-pages/man3/printf.3p.html .. _dprintf: https://man7.org/linux/man-pages/man3/dprintf.3p.html .. _sprintf: https://man7.org/linux/man-pages/man3/sprintf.3p.html .. _snprintf: https://man7.org/linux/man-pages/man3/snprintf.3p.html .. _vprintf: https://man7.org/linux/man-pages/man3/vprintf.3p.html .. _vfprintf: https://man7.org/linux/man-pages/man3/vfprintf.3p.html .. _vdprintf: https://man7.org/linux/man-pages/man3/vdprintf.3p.html .. _vsprintf: https://man7.org/linux/man-pages/man3/vsprintf.3p.html .. _vsnprintf: https://man7.org/linux/man-pages/man3/vsnprintf.3p.html .. _fgetc: https://man7.org/linux/man-pages/man3/fgetc.3p.html .. _fgets: https://man7.org/linux/man-pages/man3/fgets.3p.html .. _fputc: https://man7.org/linux/man-pages/man3/fputc.3p.html .. _fputs: https://man7.org/linux/man-pages/man3/fputs.3p.html .. _getc: https://man7.org/linux/man-pages/man3/getc.3p.html .. _getchar: https://man7.org/linux/man-pages/man3/getchar.3p.html .. _ungetc: https://man7.org/linux/man-pages/man3/ungetc.3p.html .. _putc: https://man7.org/linux/man-pages/man3/putc.3p.html .. _putchar: https://man7.org/linux/man-pages/man3/putchar.3p.html .. _puts: https://man7.org/linux/man-pages/man3/puts.3p.html .. _pthread_create: https://man7.org/linux/man-pages/man3/pthread_create.3p.html .. _pthread_attr_init: https://man7.org/linux/man-pages/man3/pthread_attr_init.3p.html .. _pthread_attr_setstacksize: https://man7.org/linux/man-pages/man3/pthread_attr_setstacksize.3p.html .. _pthread_attr_destroy: https://man7.org/linux/man-pages/man3/pthread_attr_destroy.3p.html .. _pthread_join: https://man7.org/linux/man-pages/man3/pthread_join.3p.html .. _pthread_detach: https://man7.org/linux/man-pages/man3/pthread_detach.3p.html .. _pthread_equal: https://man7.org/linux/man-pages/man3/pthread_equal.3p.html .. _atoi: https://man7.org/linux/man-pages/man3/atoi.3p.html .. _atol: https://man7.org/linux/man-pages/man3/atol.3p.html .. _atoll: https://man7.org/linux/man-pages/man3/atoll.3p.html .. _atof: https://man7.org/linux/man-pages/man3/atof.3p.html .. _isalnum: https://man7.org/linux/man-pages/man3/isalnum.3p.html .. _isalpha: https://man7.org/linux/man-pages/man3/isalpha.3p.html .. _isascii: https://man7.org/linux/man-pages/man3/isascii.3p.html .. _isblank: https://man7.org/linux/man-pages/man3/isblank.3p.html .. _iscntrl: https://man7.org/linux/man-pages/man3/iscntrl.3p.html .. _isdigit: https://man7.org/linux/man-pages/man3/isdigit.3p.html .. _isgraph: https://man7.org/linux/man-pages/man3/isgraph.3p.html .. _islower: https://man7.org/linux/man-pages/man3/islower.3p.html .. _isprint: https://man7.org/linux/man-pages/man3/isprint.3p.html .. _ispunct: https://man7.org/linux/man-pages/man3/ispunct.3p.html .. _isspace: https://man7.org/linux/man-pages/man3/isspace.3p.html .. _isupper: https://man7.org/linux/man-pages/man3/isupper.3p.html .. _isxdigit: https://man7.org/linux/man-pages/man3/isxdigit.3p.html .. _isalnum_l: https://man7.org/linux/man-pages/man3/isalnum_l.3p.html .. _isalpha_l: https://man7.org/linux/man-pages/man3/isalpha.3p.html .. _isblank_l: https://man7.org/linux/man-pages/man3/isblank.3p.html .. _iscntrl_l: https://man7.org/linux/man-pages/man3/iscntrl_l.3p.html .. _isdigit_l: https://man7.org/linux/man-pages/man3/isdigit_l.3p.html .. _isgraph_l: https://man7.org/linux/man-pages/man3/isgraph_l.3p.html .. _islower_l: https://man7.org/linux/man-pages/man3/islower_l.3p.html .. _isprint_l: https://man7.org/linux/man-pages/man3/isprint_l.3p.html .. _ispunct_l: https://man7.org/linux/man-pages/man3/ispunct_l.3p.html .. _isspace_l: https://man7.org/linux/man-pages/man3/isspace_l.3p.html .. _isupper_l: https://man7.org/linux/man-pages/man3/isupper_l.3p.html .. _isxdigit_l: https://man7.org/linux/man-pages/man3/isxdigit_l.3p.html .. _abs: https://man7.org/linux/man-pages/man3/abs.3p.html .. _labs: https://man7.org/linux/man-pages/man3/labs.3p.html .. _llabs: https://man7.org/linux/man-pages/man3/llabs.3p.html .. _imaxabs: https://man7.org/linux/man-pages/man3/imaxabs.3p.html .. _asctime: https://man7.org/linux/man-pages/man3/asctime.3p.html .. _time: https://man7.org/linux/man-pages/man3/time.3p.html .. _clock: https://man7.org/linux/man-pages/man3/clock.3p.html .. _ctime: https://man7.org/linux/man-pages/man3/ctime.3p.html .. _difftime: https://man7.org/linux/man-pages/man3/difftime.3p.html .. _gmtime: https://man7.org/linux/man-pages/man3/gmtime.3p.html .. _localtime: https://man7.org/linux/man-pages/man3/localtime.3p.html .. _mktime: https://man7.org/linux/man-pages/man3/mktime.3p.html .. _strftime: https://man7.org/linux/man-pages/man3/strftime.3p.html .. _strptime: https://man7.org/linux/man-pages/man3/strptime.3p.html .. _va_start: https://man7.org/linux/man-pages/man3/va_start.3p.html .. _va_arg: https://man7.org/linux/man-pages/man3/va_arg.3p.html .. _va_copy: https://man7.org/linux/man-pages/man3/va_copy.3p.html .. _va_end: https://man7.org/linux/man-pages/man3/va_end.3p.html .. _offsetof: https://man7.org/linux/man-pages/man3/offsetof.3.html C Basics-Level 1 - Syntax ---------------------------- 1. What are the basic data types 2. What are storage class specifiers 3. What are modifiers 4. What are Qualifiers 5. Explain different categories of operators in C 6. Explain order of evaluation of operators in C 7. Explain rules of defining an identifier in C 8. Explain rules of defining functions in C 9. Explain rules of writing "for" loops in C 10. Explain rules of writing "while" loops and "do {} while" loops in C 11. Explain rules of writing "switch" cases in C 12. Explain rules of writing "if" conditions in C 13. Explain rules of writing "if else" conditions in C 14. Explain rules of defining structures in C 15. Explain rules of defining unions in C 16. Explain rules of defining Macro functions in C 17. Explain rules of defining inline functions in C 18. Explain rules of defining a static function in C 19. Explain rules of defining a reentrant function in C 20. Explain rules of defining an integer array 21. Explain rules of defining a float array 22. Explain rules of defining a character array 23. Explain rules of defining a double array 24. Explain rules of defining structure arrays 25. Explain rules of defining union arrays 26. Explain rules of defining enums 27. Explain rules of defiing array of strings 28. Explain rules of defining an integer pointer 29. Explain rules of defining a float pointer 30. Explain rules of defining a character pointer 31. Explain rules of defining a double pointer 32. Explain rules of defining a function pointer 33. Write a function which takes function pointers as arguements 34. Write a function which returns function pointer 35. EXplain rules of defining array of function pointers 36. Explain rules of defining function pointers inside a structure 37. Explain rules of defiing array of integer pointers 38. Explain rules of defiing array of float pointers 39. Explain rules of defiing array of double pointers 40. Explain rules of defiing array of character pointers 41. Explain rules of defiing array of structure pointers 42. Explain rules of defiing array of union pointers 43. Explain rules of pointer arithmetic 44. Explain rules of using a compile time macros 45. Explain rules of using sizeof() operator on different types 46. Explain rules of structure padding 47. Explain rules of structure packing 48. Explain rules of bit fields in structures 49. Explain rules of zero length arrays in structures 50. Explain rules of using all format specifiers .. toctree:: :maxdepth: 1 c-exercise-1 c-exercise-2 c-exercise-3 C Basics-Level 2 - Differences --------------------------------- 1. Difference between one's complement and two's compiement and application 2. Difference between Little endian and Big endian 3. Difference between OR and XOR 4. Difference between OR and XNOR 5. Difference between OR and AND 6. Difference between & and && 7. Difference between | and || 8. Difference between sizeof(int) in 32 bit and 64 bit machines 9. Difference between structure and union 10. Difference between structure padding and structure packing 11. Difference between macros and inline functions 12. Difference between normal functions and inine functions 13. Difference between normal functionsand static functions 14. Difference between "int" and "unsigned int" 15. Difference between "double" and "long long double" 16. Difference between pre-increment and post-increment in case of simple integers 17. Difference between pre-increment and post-increment in case of integer pointers 18. Difference between C and C++ 19. Differnce between local variables and global variables 20. Difference between local static variable and global static variables 21. Difference between initialised global variables and not intialised global variables 22. Difference between "auto" variables and "register" variables 23. Difference between call by value and call by reference 24. Difference between while and do while 25. Difference between strncat and strlcat 26. Difference between strncpy and strlcpy 27. Difference between strcat and strncat 28. Difference between strcpy and strncpy 29. Difference between strcmp and memcmp 30. Difference between strcpy and memcpy 31. Difference between malloc and calloc 32. Difference between malloc and realloc 33. Difference between fopen, open 34. Difference between ~ and ! 35. Difference between RAM and ROM 36. Difference between declaration and defintion 37. Difference between function prototype and function definition 38. Difference between printf and fprintf 39. Difference between float and double 40. Difference between variable and constant 41. Difference between gets and fgets 42. Difference between far pointers and near pointers 43. Difference between arrays and pointers 44. Difference between array of integer pointers and array of array of integers 45. Difference between two dimensional arrays and double pointers 46. Difference between modifiers and qualifiers 47. Difference between storage class specifiers and format specifiers 48. Difference between < and << operator 49. Difference between > and >> operator 50. Difference between Postfix and Prefix operations 51. Difference between string and array of characters C Basics-Level 3 - Compilation stages ------------------------------------------ 1. Explain stages of compilation involved when program is compiled 2. Explain memory layout of a running process 3. Explain memory layout of a compiled program 4. Differnce between Segments and sections 5. Differnce between code segment and data segment 6. Difference between BSS and initialised data segment 7. Difference betwen Unix and Linux 8. DIffernce between syntac analyser and semantic analyser 9. What are the responsibilities of a pre-processor 10. What are the responsibilities of an assembler 11. What are the responsibilities of a linker/loader 12. What are the contents of an object file 13. What are the contents of an ELF a.out file C Basics-Level 4 - Searching - Arrays ---------------------------------------- 1. Implement Linear searching algorithm 2. Implement binary searching algorithm 3. Implement my_strstr similar to strstr 4. Search and replace letter 'a' in a string with letter 'k' 5. Search and replace letter 'a' in a string with letter 'k' in a file containing a plain text C Basics-Level 5 - Sorting - Arrays -------------------------------------- 1. Implement bubble sort algorithm to sort an array in increasing way 2. Implement bubble sort algorithm to sort an array in decreasing way 3. Implement selection sort algorithm to sort an array in increasing way 4. Implement selection sort algorithm to sort an array in decreasing way 5. Implement insertion sort algorithm to sort an array in increasing way 6. Implement insertion sort algorithm to sort an array in decreasing way 7. Implement merge sort algorithm to sort an array in increasing way 8. Implement merge sort algorithm to sort an array in decreasing way 9. Implement quick sort algorithm to sort an array in increasing way 10. Implement quick sort algorithm to sort an array in decreasing way 11. Implement heap sort algorithm to sort an array in increasing way 12. Implement heap sort algorithm to sort an array in decreasing way 13. Implement counting sort algorithm to sort an array in increasing way 14. Implement counting sort algorithm to sort an array in decreasing way 15. Implement Radix sort algorithm to sort an array in increasing way 16. Implement Radix sort algorithm to sort an array in decreasing way 17. Implement Bucket sort algorithm to sort an array in increasing way 18. Implement Bucket sort algorithm to sort an array in decreasing way 19. Implement Shell sort algorithm to sort an array in increasing way 20. Implement Shell sort algorithm to sort an array in decreasing way 21. Sort an array of employees based on their name 22. Sort an array of employees based on their age 23. Sort an array of employees based on their salary C Basics-Level-6 - integer Programs ------------------------------------- 1. Progam to find if a number is odd or even 2. Progam to find if a number is prime or not 3. Program to find the Nth fibonacci number 4. Program to print the fibonacci series 5. Program to find the factorial of a number 6. Program to reverse an integer. Input : 12345, Output : 54321 7. Program to find the power of a number; Input : Base, power Output : (Base)^Power 8. Program to print all prime numbers till 1000 9. Program to print all perfect square numbers till 1000. 1, 4, 9, 16, 25 etc., 10. Program to check if a number is perfect cube or not 11. Program to swap two numbers stored in two different variables 12. Program to find sum of all numbers in an array of integers 13. Program to find product of all numbers in an array of integers 14. Program to create an union of two integer arrays 15. Program to create an intersection of two integer arrays 16. Program to remove duplicate integers in an array of integers 17. Program to add only even numbers in an array of integers 18. Program to add only odd numbers in an array of integers 19. Program to delete all negative numbers in an array of integers 20. Program to count number of integers which are palnidrome numbers in an array of integers 21. Program to count number of perfect cubes in an array of integers 22. Program to find the square root of a number 23. Program to find all the divisors of a given number 24. Program to print the tables of a given number from 1 to 10 25. Program to perform matrix addition 26. Program to perform matric multiplication 27. Program to reverse the contents of an integer array 28. Program to find the smallest element and it's position in an array 29. Program to find the larget element and it's position in an array 30. Program to convert to "centimeters" to "inches" 31. Program to convert seconds to microseconds 32. Program to swap two numbers without using temporary variables 33. Program to find the sum of all negative numbers in an array 34. Program to find LCM and HCF 35. Program to add all digits in a given integer C Basics-Level-7 - Bitwise programs ------------------------------------- 1. Program to set a bit at a particular position in an integer 2. Program to clear a bit at a particulat position in an integer 3. Program to count how many bits are set in an integer 4. Program to count how many bits are not set in an integer 5. Program to check if a system is little endian or big endian 6. Program to swap byte3, byte 2 with byte 1, byte 0 in a 32 bit integer 7. Program to convert all 1s to 0s and all 0s to 1s in an integer 8. How negative integer numbers are represented in an integer 9. How negative integer numbers are represented in a float 10. Program to find a if a number is odd or even using bitwise operators 11. Program to swap two numbers without using temporary variables using bitwise operators 12. Program to multiply a number by 2 using bitwise operator 13. Program to divide a number by 2 using bitwise operator 14. Program to set all bits between positions M and N 15. Program to clear all bits between positions M and N 16. Program to swap bits from M,N with P,Q in an integer C Basics-Level-8 - memory allocation programs ---------------------------------------------- 1. Program to allocate a single block of integer using malloc 2. Program to allocate a single block of float using malloc 3. Program to allocate a single block of double using malloc 4. Program to allocate a single block of char using malloc 5. Program to allocate a multiple blocks of integer using malloc 6. Program to allocate a multiple blocks of float using malloc 7. Program to allocate a multiple blocks of double using malloc 8. Program to allocate a multiple blocks of char using malloc 9. Program to allocate memory to a double integer pointer, store and access data using single and double indirection 10. Program to allocate memory to triple integer pointer, store and access data using single, double & triple indirection 11. Program to allocate memory to array of integer pointers, store and access data using indirection 12. Program to allocate memory to a structure pointer, store and access data using single indirection 13. Program to allocate memory to an array of structure pointers, store and access data using single indirection 14. Program to allocate memory to a double structure pointer, store and access data using indirection C Basics-Level-9 - C library APIs ------------------------------------- .. _strlen: https://man7.org/linux/man-pages/man3/strlen.3.html .. _strcat: https://man7.org/linux/man-pages/man3/strcat.3.html .. _strncat: https://man7.org/linux/man-pages/man3/strncat.3p.html .. _strlcat: https://linux.die.net/man/3/strlcat .. _strcmp: https://man7.org/linux/man-pages/man3/strcmp.3p.html .. _strncmp: https://man7.org/linux/man-pages/man3/strncmp.3p.html .. _strchr: https://man7.org/linux/man-pages/man3/strchr.3p.html .. _strrchr: https://man7.org/linux/man-pages/man3/strrchr.3p.html .. _strchrnul: https://linux.die.net/man/3/strchrnul .. _strstr: https://man7.org/linux/man-pages/man3/strstr.3p.html .. _strcasestr: https://linux.die.net/man/3/strcasestr .. _strcasecmp: https://man7.org/linux/man-pages/man3/strcasecmp.3p.html .. _strpbrk: https://man7.org/linux/man-pages/man3/strpbrk.3p.html .. _strsep: https://man7.org/linux/man-pages/man3/strsep.3.html .. _strspn: https://man7.org/linux/man-pages/man3/strspn.3p.html .. _strtok: https://man7.org/linux/man-pages/man3/strtok.3p.html .. _strtok_r: https://man7.org/linux/man-pages/man3/strtok_r.3p.html .. _strcpy: https://man7.org/linux/man-pages/man3/strcpy.3p.html .. _strncpy: https://man7.org/linux/man-pages/man3/strncpy.3p.html .. _strlcpy: https://linux.die.net/man/3/strlcpy .. _stpcpy: https://man7.org/linux/man-pages/man3/stpcpy.3p.html .. _strcoll: https://man7.org/linux/man-pages/man3/strcoll.3p.html .. _strcspn: https://man7.org/linux/man-pages/man3/strcspn.3p.html .. _strdup: https://man7.org/linux/man-pages/man3/strdup.3p.html .. _strndup: https://man7.org/linux/man-pages/man3/strndup.3p.html .. _strfry: https://man7.org/linux/man-pages/man3/strfry.3.html .. _strxfrm: https://man7.org/linux/man-pages/man3/strxfrm.3p.html 1. Program to learn use of string.h APIs * strlen_ - calculate the length of a string * strcat_ - concatenate two strings * strncat_ - concatenate two strings * strlcat_ - size-bounded string concatenation * strcmp_ - compare two strings * strncmp_ - compare part of two strings * strchr_ - string scanning operation * strrchr_ - string scanning operation * strchrnul_ - string scanning operation * strstr_ - find a substring * strcasestr_ - find a substring * strcasecmp_ - case-insensitive string comparisons * strpbrk_ - scan a string for a byte * strsep_ - extract token from string * strspn_ - get length of a substring * strtok_ - split string into tokens * strtok_r_ - split string into tokens * strcpy_ - copy a string and return a pointer to the end of the result * strncpy_ - copy fixed length string, returning a pointer to the array end * strlcpy_ - size-bounded string copying * stpcpy_ - opy a string and return a pointer to the end of the result * strcoll_ - string comparison using collating information * strcspn_ - get the length of a complementary substring * strdup_ - duplicate a specific number of bytes from a string * strndup_ - duplicate a specific number of bytes from a string * strfry_ - randomize a string * strxfrm_ - string transformation 2. Program to learn use of memory allocation APIs * malloc_ - a memory allocator * calloc_ - a memory allocator * realloc_ - a memory reallocator * reallocarray_ - a memory allocator * free_ - free dynamic memory 3. Program to learn use of mem_xxxx APIs * memset_ - set bytes in memory * memcpy_ - copy memory area * memccpy_ - copy bytes in memory * memmove_ - copy memory area * mempcpy_ - copy memory area * memmem_ - locate a substring * memfrob_ - frobnicate (encrypt) a memory area * memcmp_ - compare bytes in memory 4. Program to learn use of b_xxxx APIs * bcopy_ - copy byte sequence * bstring_ - byte string operations * bcmp_ - compare byte sequences * bzero_ - zero a byte string 5. Program to learn use of C library file operation APIs * fopen_ - open a stream * fdopen_ - associate a stream with a file descriptor * freopen_ - open a stream * fclose_ - close a stream * fmemopen_ - open a memory buffer stream * fflush_ - flush a stream * fcloseall_ - close all open streams * fseek_ - reposition a stream * ftell_ - return a file offset in a stream * rewind_ - reset the file position indicator in a stream * fgetpos_ - get current file position information * fsetpos_ - set current file position * fprintf_ - print formatted output * fscanf_ - convert formatted input 6. Program to learn formatted output conversion * printf_ - print formatted output * fprintf_ - print formatted output * dprintf_ - print formatted output * sprintf_ - print formatted output * snprintf_ - print formatted output * vprintf_ - format the output of a stdarg argument list * vfprintf_ - format output of a stdarg argument list * vdprintf_ - format output of a stdarg argument list * vsprintf_ - format output of a stdarg argument list * vsnprintf_ - format output of a stdarg argument list 7. Program to learn file read, write APIs * fgetc_ - get a byte from a stream * fgets_ - get a string from a stream * fputc_ - put a byte on a stream * fputs_ - put a string on a stream * getc_ - get a byte from a stream * getchar_ - get a byte from a stdin stream * ungetc_ - push byte back into input stream * putc_ - put a byte on a stream * putchar_ - put a byte on a stdout stream * puts_ - put a string on standard output 8. Program to learn use of pthread_xxxx apis * pthread_create_ - thread creation * pthread_attr_init_ - initialize the thread attributes object * pthread_attr_setstacksize_ - set the stacksize attribute * pthread_attr_destroy_ - destroy the thread attributes object * pthread_join_ - wait for thread termination * pthread_detach_ - detach a thread * pthread_equal_ - compare thread IDs 9. Program to learn conversion of string to integer * atoi_ - convert a string to an integer * atol_ - convert a string to a long integer * atoll_ - convert a string to a long integer * atof_ - convert a string to a double-precision number 10. Program to learn apis from ctypes.h - character classification functions * isalnum_ - test for an alphanumeric character * isalpha_ - test for an alphabetic character * isascii_ - test for a 7-bit US-ASCII character * isblank_ - test for a blank character * iscntrl_ - test for a control character * isdigit_ - test for a decimal digit * isgraph_ - test for a visible character * islower_ - test for a lowercase letter * isprint_ - test for a printable character * ispunct_ - test for a punctuation character * isspace_ - test for a white-space character * isupper_ - test for an uppercase letter * isxdigit_ - test for a hexadecimal digit * isalnum_l_ - test for an alphanumeric character * isalpha_l_ - test for an alphabetic character * isblank_l_ - test for a blank character * iscntrl_l_ - test for a control character * isdigit_l_ - test for a decimal digit * isgraph_l_ - test for a visible character * islower_l_ - test for a lowercase letter * isprint_l_ - test for a printable character * ispunct_l_ - test for a punctuation character * isspace_l_ - test for a white-space character * isupper_l_ - test for an uppercase letter * isxdigit_l_ - test for a hexadecimal digit 11. Program to learn apis to compute the absolute value of an integer * abs_ - return an integer absolute value * labs_ - return a long integer absolute value * llabs_ - return a long integer absolute value * imaxabs_ - return absolute value 12. Program to learn apis from time.h * asctime_ - convert date and time to a string * time_ - get time * clock_ - report CPU time used * ctime_ - convert a time value to a date and time string * difftime_ - compute the difference between two calendar time values * gmtime_ - convert a time value to a broken-down UTC time * localtime_ - convert a time value to a broken-down local time * mktime_ - convert broken-down time into time since the Epoch * strftime_ - convert date and time to a string * strptime_ - date and time conversion 13. Program to learn variable arguement APIs * va_start_ - handle variable argument list * va_arg_ - handle variable argument list * va_copy_ - handle variable argument list * va_end_ - handle variable argument list 14. Program to find offset of a structure member * offsetof_ - offset of a structure member .. note :: An exercise : Complete this exercise ! Test an API by passing inputs as defined in Five modules .. toctree:: :maxdepth: 1 c-exercise-9.1 C Basics-Level-10 - String programs --------------------------------------- 1. Implement custom definitions of below APIs, using loops (for or while) * strlen_ - calculate the length of a string * strcat_ - concatenate two strings * strncat_ - concatenate two strings * strlcat_ - size-bounded string concatenation * strcmp_ - compare two strings * strncmp_ - compare part of two strings * strchr_ - string scanning operation * strrchr_ - string scanning operation * strchrnul_ - string scanning operation * strstr_ - find a substring * strcasestr_ - find a substring * strcasecmp_ - case-insensitive string comparisons * strpbrk_ - scan a string for a byte * strsep_ - extract token from string * strspn_ - get length of a substring * strtok_ - split string into tokens * strtok_r_ - split string into tokens * strcpy_ - copy a string and return a pointer to the end of the result * strncpy_ - copy fixed length string, returning a pointer to the array end * strlcpy_ - size-bounded string copying * stpcpy_ - opy a string and return a pointer to the end of the result * strcoll_ - string comparison using collating information * strcspn_ - get the length of a complementary substring * strdup_ - duplicate a specific number of bytes from a string * strndup_ - duplicate a specific number of bytes from a string * strfry_ - randomize a string * strxfrm_ - string transformation 2. Program to search letter 'a' and replace it with letter 'k' in a string 3. Program to search letter 'a' and replace it with letter 'k' in an array of strings 4. Program to reverse a string using for or while loop 5. Program to reverse all strings in an array of strings 6. Program to convert all charcaters to capital letters in a string 7. Program to convert all charcaters to capital letters in all strings in an array of strings 8. Program to convert all charcaters to small letters in a string 9. Program to convert all charcaters to small letters in all strings in an array of strings 10. Program to replace occurance of word "paper" with "pen" in a string 11. Program to replace occurance of word "paper" with "pen" in all strings in an array of strings 12. Program to search letter 'a' and delete it in a string 13. Program to search letter 'a' and delete it in an array of strings 14. Program to replace occurance of word "paper" and delete it in a string 15. Program to replace occurance of word "paper" and delete in all strings in an array of strings 16. Program to print A-Z and a-z 17. Program to count number of new lines in a string or array of strings 18. Program to check if a string is a palindrome 19. Program to check if a string is a proper IPv4 address or not 20. Program to check if a string is a proper MAC address or not 21. Program to check if two strings are anagram of each other 22. Program to count number of words in a string where each word is separated by space 23. Program to remove all characters which are not alphabets in a string 24. Program to sort the letters in a string as per alphabetical order 25. Program to sort the strings in an array of strings similar to a dictionary 26. Program to sort all characters in all strings in an array of strings 27. Program to extract the digits from a string and store them in integer variables 28. Program to extract information from an excel sheet and store it in a proper data structure in RAM 29. Program to remove any leading spaces in a string or array of strings 30. Program to remove any trailing spaces in a string or array of strings 31. Program to remove leading spaces, trailing spaces and white spaces in a string or array of strings 32. Program to find out smallest word in an english statement 33. Program to find out longest word in an english statement C Basics-Level-11- Data structure programs --------------------------------------------- 1. Program to implement Single linked list with functions insert_at_front, insert_at_rear, insert_at_position, delete_at_front, delete_at_rear, delete_at_position 2. Program to implement Double linked list with functions insert_at_front, insert_at_rear, insert_at_position, delete_at_front, delete_at_rear, delete_at_position 3. Program to implement Binary search tree with functions insert_left, insert_right, delete_left, delete_right, search 4. Program to implement stacks using arrays 5. Program to implement stacks using Single linked lists 6. Program to implement Queues using Single linked lists 7. Program to implement stacks using Double linked lists 8. Program to implement Queues using Double linked lists 9. Program to reverse a single linked list using iteration 10. Program to print the left view of binary tree 11. Program to print the right view of binary tree 12. Program to create a mirror copy of binary tree 13. Program to implement a disctionary search of strings using hastable of single linked lists 14. Program to implement Min-Heap 15. Program to implement Max-Heap 16. Program to implement AVL trees 17. Program to implement threaded binary trees 18. Program to implement B+ trees 19. Program to implement red black trees 20. Program to implement double ended queues 21. Program to implement circular queues 22. Program to implement circular linked lists 23. Program to implement a custom malloc and free operation C Basics-Level-12- Recursion programs --------------------------------------- 1. Implement custom definitions of below APIs, using recursion * strlen_ - calculate the length of a string * strcat_ - concatenate two strings * strncat_ - concatenate two strings * strlcat_ - size-bounded string concatenation * strcmp_ - compare two strings * strncmp_ - compare part of two strings * strchr_ - string scanning operation * strrchr_ - string scanning operation * strchrnul_ - string scanning operation * strstr_ - find a substring * strcasestr_ - find a substring * strcasecmp_ - case-insensitive string comparisons * strpbrk_ - scan a string for a byte * strsep_ - extract token from string * strspn_ - get length of a substring * strtok_ - split string into tokens * strtok_r_ - split string into tokens * strcpy_ - copy a string and return a pointer to the end of the result * strncpy_ - copy fixed length string, returning a pointer to the array end * strlcpy_ - size-bounded string copying * stpcpy_ - opy a string and return a pointer to the end of the result * strcoll_ - string comparison using collating information * strcspn_ - get the length of a complementary substring * strdup_ - duplicate a specific number of bytes from a string * strndup_ - duplicate a specific number of bytes from a string * strfry_ - randomize a string * strxfrm_ - string transformation 2. Program to implement tower of hanoi using recursion 3. Program to reverse a string using recursion 4. Program to reverse a linked list using recursion 5. Program to print fibonacci series usinf recursion 6. Program to find sum of all numbers in an integer array using recursion 7. Program to implement insert_at_rear and delete_at_rear using recursion in single linked lists 8. Program to print the contens of an integer array using recursion 9. Program to print A-Z or a-z using recursion 10. Program to print sum of digits of an integer using recursion 11. Program to find GCD of two numbers using recursion 12. Program to find factorial of a number using recursion 13. Convert all above programs having loops to recursion C Basics-Level-13- File operation programs --------------------------------------------- 1. Program to create an empty file 2. Program to write 1 to 100 into a file 3. Program to write a string to a file 4. Program to write an array of strings to a file 5. Program to count number of characters in a file 6. Program to count number of words in a file 7. Program to count number of new lines in a file 8. Program to count number of occurances of character 'a' in a file 9. Program to create a file which is a copy of another file 10. Program to print list of file names present in the current directory 11. Program to delete a file in the current directory whose name matches the input arguement 12. Programt to search and replace letter 'a' with letter 'k' in a file 13. Program to seach and replace word "paper" with the word "pen" in a file 14. Program to count how many ip address strings are present in a file 15. Program to count how many mac address strings are present in a file 16. Program to delete occurances of "paper" in a file 17. Program to search and replace all occurances of words "paper", "book" with "pen" and "pencil" respectively 18. Program to count number of anagrams in a file 19. Program to count number of palindromes in a string 20. Program to delete all the contents of a file 21. Program to delete all new lines in a file 22. Program to number of lines, number of characters and number of words in a file 23. Program to split an input file and create two files exactly into two halves 24. Program to split an input file into multiple files based on number of lines input by the user 25. Program to split an input file into multiple files based on output size input by the user C Basics-Level-14- Applications of Data structures --------------------------------------------------- .. literalinclude:: ds_sample_data.py 1. SLL: Store the list of records in a singly linked list. Print all entries in the linked list. 2. SLL: Store the list of records in a singly linked list after sorting the records in alphabetic order by member names. Print all entries in the linked list. 3. SLL: Store the list of records in 2 singly linked lists according to gender. Print all entries in each linked list. 4. SLL: Store the list of records in mutiple SLL according to age buckets (21-30, 31-40, 41-50, 51-60). Print all entries in each linked list. 5. SLL: Store the list of records in a singly linked list. Print all entries in the linked list. Delete all records which fall in the age bucket of 21-30 and print the SLL once again. 6. SLL: Store the list of records in a singly linked list. Print all entries in the linked list. Increase the age of all members by 1 and print the SLL once again. 7. SLL: Store the list of records in a singly linked list. Print all entries in the linked list. While displaying the SLL, print an additional text "[Mark for title upgrade]" for all members whose age is greater than 45. 8. SLL: Store the list of records in a singly linked list. Delete every alternate entry in the SLL. 9. CSLL: Store the list of records in a circular singly linked list. Print all entries in the linked list. 10. CSLL: Store the list of records in a circular singly linked list after sorting the records in alphabetic order by member names. Print all entries in the CSLL but starting from the alphabet J 11. CSLL: Store the list of records in a circular singly linked list. Print all entries in the linked list. Delete all records which match the occupation "Engineer" and print the CSLL once again. 12. CSLL: Store the list of records in a circular singly linked list. Print all entries in the linked list. Modify the ID of all records by adding the value 100 to it and print the CSLL once again. 13. CSLL: Store the list of records in a circular singly linked list. Print only the members in the CSLL who are above the age of 40 and match the occupation "Doctor". 14. CSLL: Store the list of records in a CSLL. Delete every alternate entry in the CSLL 15. DLL: Store the list of records in a doubly linked list. Print all entries in the DLL 16. DLL: Store the list of records in a doubly linked list after sorting the records in alphabetic order by member surnames. Print all entries in the DLL. 17. DLL: Store the list of records in 2 singly linked lists according to gender. Print all entries in each DLL starting from the tail of the DLL. 18. DLL: Store the list of records in mutiple DLLs according to age buckets (21-30, 31-40, 41-50, 51-60). Print the DLL. Delete the entries in the age bucket 41-50 and print the DLL once again 19. DLL: Store the list of records in mutiple DLLs according to age buckets (21-30, 31-40, 41-50, 51-60). The records in the age bucket must be storted acording to increasing age. Print all entries in each DLL in reverse age order for each bucket. 20. DLL: Store the list of records in a doubly linked list. Sort all entries according to occupation. Print only one entry for each occupation. 21. DLL: Store the list of records in a doubly linked list. Sort all entries alphabetically according to occupation. Delete entries such that only one entry is present for each occupation in the DLL. 22. DLL: Store the list of records in a doubly linked list. Delete every alternate entry in the DLL. 23. DLL: Store the list of records in a doubly linked list. Sort all entries alphabetically according to occupation and print the DLL(Order should be: Actor list <-> Author list <-> Doctor <-> Engineer <-> Manager <-> Politician). Swap the order for the occupation entries "Doctor" and "Engineer" (Order should be Actor <-> Author <-> Engineer <-> Doctor <-> Manager <-> Politician) 24. CDLL: Store the list of records in a circular doubly linked list. Print all entries in the CDLL 25. CDLL: Store the list of records in a circular doubly linked list after sorting the records in alphabetic order by member names. Print all entries in the CDLL, starting from the alphabet M but in reverse alphabetic order. 26. CDLL: Store the list of records in a circular doubly linked list. Print only the members in the CDLL who are above the age of 40. 27. CDLL: Store the list of records in a CDLL. Print only the members of the CDLL whose first or last name start with the letter J 28. CDLL: Store the list of records in a CDLL. Delete all entries whose occupation matches Actor and print the CDLL. 29. CDLL: Store the list of records in a CDLL. Entries must be sorted according to occupation. Print the CDLL. 30. CDLL: Store the list of records in a CDLL. Delete every alternate entry in the CDLL C Basics-Level-15 - Structures ------------------------------- .. csv-table:: :file: ./c-structure-concepts.csv :widths: 10 C Basics-Level-16 - Macros ------------------------------- .. csv-table:: :file: ./c-macro-classification.csv :widths: 10 C Basics-Level-17 - Function Pointers -------------------------------------- .. csv-table:: :file: ./c-function-pointers.csv :widths: 50,50