0% found this document useful (0 votes)
19 views11 pages

Programing Qustion

The document provides a comprehensive overview of C programming concepts, including descriptive questions and multiple-choice questions for a final exam. Key topics covered include pointers, arrays, loops, conditional statements, and string manipulation. It also includes examples and explanations for various functions and operators used in C programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views11 pages

Programing Qustion

The document provides a comprehensive overview of C programming concepts, including descriptive questions and multiple-choice questions for a final exam. Key topics covered include pointers, arrays, loops, conditional statements, and string manipulation. It also includes examples and explanations for various functions and operators used in C programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

‫ دلته ټول‬،‫ ډېر ښه‬C Programming Final Exam ‫ څلور ځوابي سوالونه) په انګلیسي ژبه یو‬+ ‫مواد (تشریحي‬

‫ ته کولی شې دا ټوله کاپي کړې او په‬.‫ ځای درته وړاندې کوم‬Word ‫ یا‬Google Docs ‫ کې یې‬PDF ‫ته واړوې‬.

---

📘 C Programming Final Exam Questions (English Version)

---

🧠 Descriptive Questions (10 with Answers)

1. What is a Pointer? Give an example.

A pointer is a variable that stores the memory address of another variable.

Example:

int a = 5;

int *p = &a;

---

2. What is an Array and how is it defined?


An array is a collection of elements of the same data type stored in contiguous memory locations.

Example:

int arr[5] = {1, 2, 3, 4, 5};

---

3. What is a for loop? Explain with an example.

A for loop is a control structure used to repeat a block of code a known number of times.

Example:

for (int i = 0; i < 5; i++) {

printf("%d\n", i);

---

4. What is an if-else statement?

It is a conditional structure that allows the program to choose between two blocks based on a condition.

Example:
if (marks >= 60)

printf("Passed");

else

printf("Failed");

---

5. What is a String and how is it different from a character array?

A string is a sequence of characters ending with a null character ('\0'). It is stored in a character array.

---

6. What is a switch statement?

A switch statement allows multi-way branching based on the value of an expression.

Example:

switch(day) {

case 1: printf("Sunday"); break;

default: printf("Invalid");

}
---

7. Explain strlen() and strcpy() functions.

strlen(str): Returns the length of the string.

strcpy(dest, src): Copies the source string into the destination.

---

8. Explain the difference between * and & operators.

&: Address-of operator (returns the address of a variable)

*: Dereferencing operator (accesses the value at the address stored in a pointer)

---

9. What are the types of loops in C?


C provides three types of loops:

for loop

while loop

do-while loop

---

10. What are Logical Operators in C?

&&: Logical AND

||: Logical OR

!: Logical NOT

---

✅ Multiple Choice Questions (30 with Answers)


1. Which statement is valid for declaring a variable?

✅ b) int a;

2. Which function returns the length of a string?

✅ c) strlen()

3. What does *ptr = 10; mean?

✅ c) Assign 10 to the location pointed by ptr

4. Which are the parts of a for loop?

✅ c) Initialization, condition, increment

5. How is an array defined in C?

✅ c) int array[5];

6. What is %d used for?

✅ d) Integer values
7. Which is not a C keyword?

✅ b) then

8. C strings always end with which character?

✅ b) '\0'

9. Which is the logical AND operator?

✅ b) &&

10. Which function takes string input from user?

✅ b) scanf()

11. Which is the correct way to declare a pointer?

✅ b) int *ptr;

12. What does if statement do?

✅ b) Performs selection

13. What is %s used for?


✅ c) Strings

14. What does a++ do?

✅ c) Increments a by 1

15. What is switch used for?

✅ b) Multi-way decision

16. Which function copies a string?

✅ b) strcpy()

17. Which function searches for a substring?

✅ b) strstr()

18. Which operator gives remainder?

✅ c) %

19. What is the first index of an array?

✅ b) 0
20. Which loop runs at least once?

✅ c) do-while

21. Which function reads an entire line of input?

✅ c) fgets()

22. What does &x mean?

✅ c) Address of variable x

23. Which is not a pointer operator?

✅ c) &&

24. What does strcmp("a", "b") return?

✅ b) Negative number

25. Which operator has the highest precedence?

✅ c) *
26. Which logical operator is true if any one is true?

✅ b) ||

27. How to access a character in a string?

✅ c) str[0]

28. What is the difference between ++i and i++?

✅ b) Pre-increment vs Post-increment

29. What does default do in switch?

✅ c) Runs if no case matches

30. What is the correct syntax of do-while loop?

✅ c) do { } while (condition);

---
‫‪ Save as PDF‬کې‪ ،‬او ‪ Google Docs‬یا ‪ Word‬په )‪ (Paste‬کړې‪ ،‬و یې ننباسې ‪ Copy‬اوس کولی شې دا ټول متن ✅‬
‫‪.‬یې واچوې‬

‫‪.‬که کوم بل څه هم درته پکار وي‪ ،‬نو مهرباني وکړه‪ ،‬خبر راکړه‬

You might also like