Blog - C Language Quiz 2

C Language Quiz 2

C Language Quiz 2

C Language

1.  How do you include a user-defined header file in a C program?

आप C प्रोग्राम में उपयोगकर्ता-परिभाषित हेडर फ़ाइल को कैसे शामिल करते हैं?

a) #include "myheader.h"

b) #include <myheader.h>

c) #import "myheader.h"

d) #import <myheader.h>

 

2.  What is the purpose of the "sizeof" operator in C, and how is it different from "strlen()"?

C में "sizeof" ऑपरेटर का उद्देश्य क्या है, और यह "strlen()" से कैसे भिन्न है?

a) "sizeof" returns the size of a data type in bytes, while "strlen()" returns the length of a string.

b) "sizeof" returns the length of a string, while "strlen()" returns the size of a data type in bytes.

c) "sizeof" and "strlen()" are used interchangeably.

d) "sizeof" and "strlen()" are not valid C functions.

 

3. What does the "do-while" loop in C do?

C में "डू-व्हाइल" लूप क्या करता है?

a) It executes a block of code as long as a condition is true.

b) It executes a block of code once and then checks a condition.

c) It executes a block of code repeatedly until a condition is false.

d) It does not exist in C.

 

4.  Which operator is used for pointer-to-member selection in C?

C में पॉइंटर-टू-मेंबर चयन के लिए किस ऑपरेटर का उपयोग किया जाता है?

a) *

b) ->

c) .

d) ::

 

5. What is the purpose of the "break" statement in a loop in C?

C में लूप में "ब्रेक" स्टेटमेंट का उद्देश्य क्या है?

a) To start a new loop

b) To skip to the next iteration of the loop

c) To end the program

d) To exit the loop

 

6.  What is the difference between "char" and "int" data types in C?

C में "char" और "int" डेटा प्रकारों के बीच क्या अंतर है?

a) "char" is used for characters and "int" is used for integers.

b) "char" is a signed data type, and "int" is an unsigned data type.

c) "char" can store larger values than "int."

d) "char" is used for floating-point numbers, and "int" is used for integers.

 

7. How do you declare a two-dimensional array in C with 3 rows and 4 columns?

आप C में 3 पंक्तियों और 4 स्तंभों के साथ द्वि-आयामी सरणी कैसे घोषित करते हैं?

a) int[3][4] myArray;

b) myArray[3, 4];

c) int myArray[3][4];

d) myArray = int[3][4];

 

8. What is the purpose of the "goto" statement in C, and why is it generally discouraged?

सी में "गोटो" कथन का उद्देश्य क्या है, और इसे आम तौर पर हतोत्साहित क्यों किया जाता है?

a) It is used for debugging and is considered a best practice.

b) It is used to transfer control to a labeled statement but can lead to unstructured code.

c) It is used to declare a new variable.

d) It is used to define functions.

 

9. Which function is used to close a file in C after reading or writing?

पढ़ने या लिखने के बाद C में किसी फ़ाइल को बंद करने के लिए किस फ़ंक्शन का उपयोग किया जाता है?

a) fclose()

b) close()

c) endfile()

d) finish()

 

10. What is the significance of the "volatile" keyword in C when applied to a variable?

किसी वेरिएबल पर लागू होने पर C में "अस्थिर" कीवर्ड का क्या महत्व है?

a) It indicates that the variable cannot be changed.

b) It specifies that the variable should be stored in a cache.

c) It tells the compiler not to optimize the variable.

d) It declares the variable as a constant.

 

11. How is memory allocated for variables in C, and what is the difference between stack and heap memory?

C में वेरिएबल्स के लिए मेमोरी कैसे आवंटित की जाती है, और स्टैक और हीप मेमोरी के बीच क्या अंतर है?

a) Memory is allocated automatically for all variables. Stack memory is used for local variables, while heap memory is used for global variables.

b) Memory is allocated explicitly using the "malloc()" function. Stack memory is used for global variables, while heap memory is used for local variables.

c) Memory is allocated dynamically for heap variables, while stack memory is used for global variables.

d) Memory is allocated at compile time for all variables. Stack memory is used for local variables, while heap memory is used for global variables.

 

12. What is the purpose of the "const" keyword in C when applied to a function parameter?

फ़ंक्शन पैरामीटर पर लागू होने पर C में "कॉन्स्ट" कीवर्ड का उद्देश्य क्या है?

a) It indicates that the parameter is constant and cannot be modified within the function.

b) It specifies that the parameter should be passed by reference.

c) It indicates that the parameter should be passed by value.

d) It declares the parameter as a global variable.

 

13. In C, what is the purpose of the "struct" keyword?

C में, "struct" कीवर्ड का उद्देश्य क्या है?

a) To declare a pointer variable

b) To define a custom data structure

c) To perform typecasting

d) To declare a constant variable

 

14. What is the purpose of the "typedef" keyword in C when used with "struct"?

जब C में "struct" के साथ प्रयोग किया जाता है तो "typedef" कीवर्ड का उद्देश्य क्या होता है?

a) It declares a new structure variable.

b) It initializes a structure.

c) It defines a new data type based on a structure.

d) It specifies the size of a structure.

 

15. What does the "feof()" function in C check for?

C में "feof()" फ़ंक्शन किसकी जाँच करता है?

a) The end of a file

b) The beginning of a file

c) The length of a file

d) The presence of a file

 

16. What is the purpose of the "enum" keyword in C?

C में "enum" कीवर्ड का उद्देश्य क्या है?

a) To declare a variable

b) To define a custom data structure

c) To declare constants with meaningful names

d) To specify the type of a variable

 

17. What is the default return type of a function in C when not explicitly specified?

स्पष्ट रूप से निर्दिष्ट नहीं होने पर C में किसी फ़ंक्शन का डिफ़ॉल्ट रिटर्न प्रकार क्या है?

a) int

b) char

c) void

d) float

 

18. How do you declare a pointer to a function in C?

आप C में किसी फ़ंक्शन के लिए पॉइंटर कैसे घोषित करते हैं?

a) ptr myFunction;

b) myFunction pointer;

c) int *myFunction;

d) int (*myFunction)();

 

 

19. What is the difference between "malloc()" and "calloc()" in C when allocating memory dynamically?

मेमोरी को गतिशील रूप से आवंटित करते समय C में "मॉलोक ()" और "कॉलॉक ()" के बीच क्या अंतर है?

a) "malloc()" initializes memory to zero, while "calloc()" does not.

b) "malloc()" automatically allocates memory for an array, while "calloc()" does not.

c) "malloc()" does not initialize memory, while "calloc()" initializes memory to zero.

d) "malloc()" and "calloc()" are equivalent.

 

20. How do you access the value stored at a memory address pointed to by a pointer in C?

आप कैसे पहुँचते हैं?

a) *myPointer

b) &myPointer

c) myPointer.value

d) myPointer->value

 

 

21. What is the purpose of the "void" data type in C?

C में "शून्य" डेटा प्रकार का उद्देश्य क्या है?

a) To specify an empty data type

b) To indicate an error

c) To define a data structure

d) To declare a constant variable

 

22. What is the difference between "malloc()" and "realloc()" in C when resizing dynamically allocated memory?

गतिशील रूप से आवंटित मेमोरी का आकार बदलते समय C में "malloc()" और "realloc()" के बीच क्या अंतर है?

a) "malloc()" allocates new memory, while "realloc()" resizes existing memory.

b) "malloc()" and "realloc()" perform the same task.

c) "malloc()" resizes memory, while "realloc()" allocates new memory.

d) "malloc()" and "realloc()" are not valid C functions.

 

23. How do you declare a character array (string) in C?

आप C में कैरेक्टर ऐरे (स्ट्रिंग) कैसे घोषित करते हैं?

a) string myString;

b) char myString[];

c) char[] myString;

d) char* myString;

 

24. What is the purpose of the "assert()" function in C?

C में "assert()" फ़ंक्शन का उद्देश्य क्या है?

a) To perform arithmetic operations

b) To declare a constant variable

c) To check for errors during program execution

d) To print output to the screen

 

25. What does the "const" keyword indicate when used as part of a pointer declaration in C?

C में पॉइंटर घोषणा के भाग के रूप में उपयोग किए जाने पर "const" कीवर्ड क्या दर्शाता है?

a) It declares a constant pointer.

b) It specifies that the pointer should be passed by reference.

c) It indicates that the pointer cannot be modified to point to a different memory location.

d) It indicates that the pointer cannot be dereferenced.

 

 


54 8 months ago