[go: up one dir, main page]

0% found this document useful (0 votes)
21 views3 pages

Advance C Prog FYBCA

The document is a question bank for an Advanced C Programming course covering topics such as strings, pointers, file handling, preprocessor directives, command line arguments, and arrays. It includes multiple choice questions, short answer questions, and programming tasks for students to attempt. The questions test knowledge and application of C programming concepts and functions.
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)
21 views3 pages

Advance C Prog FYBCA

The document is a question bank for an Advanced C Programming course covering topics such as strings, pointers, file handling, preprocessor directives, command line arguments, and arrays. It includes multiple choice questions, short answer questions, and programming tasks for students to attempt. The questions test knowledge and application of C programming concepts and functions.
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/ 3

QUESTION BANK – ADVANCED C PROGRAMMING

For: FYBCA
Topics Covered: Strings, Pointers, File Handling, Preprocessor Directives, Command Line Arguments,
Arrays

Q.1. Multiple Choice Questions [½ mark each]

1. Which function is used to calculate the length of a string?


A) strlength() B) strlen() C) strcount() D) len()
Answer: B) strlen()

2. Which of the following is a preprocessor directive?


A) main() B) #define C) return D) scanf()
Answer: B) #define

3. Which function is used to open a file in C?


A) fopen() B) fileopen() C) open() D) createfile()
Answer: A) fopen()

4. How many arguments does main() take when using command line arguments?
A) 1 B) 2 C) 3 D) 0
Answer: B) 2

5. What is the output of strlen("Hello")?


A) 6 B) 4 C) 5 D) Error
Answer: C) 5

6. Which symbol is used to denote a pointer in C?


A) & B) * C) @ D) %
Answer: B) *

7. In C, what does #include <stdio.h> do?


A) Includes the standard input-output library functions.
B) Declares a function.
C) Defines a macro.
D) None of the above.
Answer: A) Includes the standard input-output library functions.

8. What will happen if you try to access a null pointer?


A) It will return 0.
B) It will cause a segmentation fault.
C) It will give a random value.
D) It will print "null".
Answer: B) It will cause a segmentation fault.

9. Which of the following is the correct syntax to declare an array of integers?


A) int arr[5];
B) int arr(5);
C) arr[5] int;
D) array int[5];
Answer: A) int arr[5];

10. Which of the following functions is used to copy a string?


A) strcat()
B) strcpy()
C) strlen()
D) strrev()
Answer: B) strcpy()

Q.2. Short Answer Questions (Attempt Any 2) [1 mark each]

1. What are command-line arguments in C?

2. Define a pointer and give a simple example.

3. What is the use of the fclose() function in file handling?

4. Explain the difference between strcpy() and strcat().

5. What is the purpose of using #include in a C program?

6. What is the difference between == and = operators in C?

7. Explain what a null pointer is.

8. What are the different types of preprocessor directives in C?

9. What is the difference between #define and const in C?

10. Explain the #include preprocessor directive in C.

Q.3. Programming Questions (Attempt Any 2) [3 marks each]

1. Write a C program to read a string and print it in reverse.

2. Write a C program to accept and display command-line arguments.

3. Write a C program to open a file, read and display its contents.

4. Write a C program using pointers to swap two integers.

5. Write a C program to concatenate two strings using strcat().

6. Write a C program to count the number of occurrences of a character in a string.

7. Write a C program to implement a simple file handling program that writes user input into a
file.

8. Write a C program using arrays and pointers to find the sum of elements in an integer array.

9. Write a C program to copy one string into another without using strcpy().

10. Write a C program to take input from the user and save it in a text file.
11. Write a C program that demonstrates the use of #define and #include directives in C.

12. Write a C program that implements the use of #ifdef and #endif preprocessor directives to
check if a variable is defined or not.

13. Write a C program to calculate the average of n numbers using arrays.

14. Write a C program to compare two strings without using the strcmp() function.

15. Write a C program that accepts data from a file and counts the number of words in it.

16. Write a C program to implement a simple calculator that performs addition, subtraction,
multiplication, and division.

17. Write a C program to sort an array of integers in ascending order using pointers.

18. Write a C program to demonstrate the use of #ifdef, #ifndef, and #endif preprocessor
directives.

You might also like