0% found this document useful (0 votes)
15 views2 pages

C Library Practice Questions

The document contains a list of C programming practice questions organized by standard libraries: stdio.h, stdlib.h, and string.h. Each library section includes various tasks such as reading and displaying text, file operations, memory management, and string manipulation. The exercises aim to enhance understanding and application of C programming concepts.

Uploaded by

pokeb14730
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)
15 views2 pages

C Library Practice Questions

The document contains a list of C programming practice questions organized by standard libraries: stdio.h, stdlib.h, and string.h. Each library section includes various tasks such as reading and displaying text, file operations, memory management, and string manipulation. The exercises aim to enhance understanding and application of C programming concepts.

Uploaded by

pokeb14730
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/ 2

C Programming Practice Questions

Library: stdio.h
1. Write a program to read and display a line of text using gets() and puts().

2. Create a program that reads an integer and a float and prints them using printf().

3. Write a C program that demonstrates formatted input using scanf().

4. Make a menu-driven program using switch-case to read user input.

5. Write a program to read a file line by line using fgets().

6. Use fgetc() and fputc() to copy one file's content to another.

7. Write a program to count the number of characters, words, and lines in a file.

8. Demonstrate usage of fprintf() and fscanf() to store and retrieve structured data.

9. Create a program that uses getchar() and putchar() to echo typed characters.

10. Implement a program to compare fprintf vs fwrite using a sample structure.

Library: stdlib.h
1. Write a program to convert a string to integer using atoi().

2. Demonstrate the use of atof() to convert a string to float.

3. Create a program that uses malloc() and free() for dynamic memory allocation.

4. Write a program to sort an array using qsort().

5. Demonstrate use of system() to run a shell command.

6. Generate random numbers using rand() and srand() with time(NULL).

7. Allocate and reallocate memory using realloc().

8. Use exit() and atexit() in a program to demonstrate program termination behavior.

9. Convert integers to strings using itoa() (if available in your compiler).

10. Write a C program to find the largest element in a dynamically allocated array.

Library: string.h
1. Write a program to compare two strings using strcmp().
2. Demonstrate how to copy a string using strcpy().

3. Write a function that reverses a string using strlen().

4. Concatenate two strings using strcat() and display the result.

5. Write a program to tokenize a string using strtok().

6. Use strstr() to find a substring inside a string.

7. Count how many times a character appears in a string using strchr().

8. Demonstrate the difference between strncpy() and strcpy().

9. Replace all spaces in a string with underscores.

10. Write a custom implementation of strlen() function.

You might also like