FliQi Education App Download
प्रश्न-बैंक · C Language

Header File in C Language — प्रश्न और उत्तर

C Language · 23 जाँचे हुए (verified) प्रश्न

  • 23 जाँचे हुए प्रश्न
  • हिंदी + English

पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 13 के उत्तर और हल FliQi Question Bank app में।

भाषा
प्रश्न 1उत्तर + हल
क्या हेडर फ़ाइलों (header files) में function definition मौजूद हो सकती है?
Can function definition be present in header files?
  1. Aहाँ, हो सकती है, पर सामान्यतः हेडर फ़ाइल में रखी नहीं जातीYes, it could be but normally it does not exist in header file
  2. Bनहीं, हेडर फ़ाइल में यह मौजूद नहीं होतीNo, it does not exist in header file
  3. Ccompiler पर निर्भर करता हैDepends on the compiler
  4. Dstandard पर निर्भर करता हैDepends on the standard

सही उत्तर / Answer: (A)

हल / Solution
हेडर फ़ाइल को preprocessor वहीं जोड़ देता है जहाँ #include लिखा है, इसलिए भाषा के नियम से उसमें function की पूरी definition भी लिखी जा सकती है। चलन इसके उलट है: हेडर में सिर्फ़ घोषणा रखी जाती है, क्योंकि वही हेडर कई फ़ाइलों में जुड़ने पर एक ही function दो बार बन जाता है और linker «multiple definition» की शिकायत करता है। यह बात किसी compiler या मानक पर नहीं टिकी, सो तीसरा और चौथा विकल्प ग़लत हैं।
The preprocessor pastes a header file in where #include is written, so by the rules of the language a full function definition may sit there too. Practice runs the other way: a header normally carries only declarations, because if the same header reaches several files the function gets built twice and the linker reports a multiple definition error. This does not hang on any compiler or standard, so the third and fourth options are wrong.
प्रश्न 2उत्तर + हल
C भाषा में हेडर फाइल क्या है?
What is a header file in C language?
  1. Aहेडर फाइल वह फाइल है जिसमें C के बिल्ट-इन लाइब्रेरी फंक्शनों की घोषणाएँ और मैक्रो परिभाषाएँ होती हैंHeader file is a file that contains function declarations & macro definitions for C built-in library functions
  2. BC के सभी स्टैंडर्ड लाइब्रेरी फंक्शन कई हेडर फाइलों में घोषित होते हैं, जो file_name.h के रूप में सहेजी जाती हैंAll C standard library functions are declared in many header files, which are saved as file_name.h
  3. Cजब हम #include <file_name.h> से हेडर फाइल जोड़ते हैं, तो हेडर फाइल का पूरा C कोड हमारे प्रोग्राम में जुड़ जाता हैWhen we include header files in our C program using the #include <file_name.h> command, all the C code of the header file is included in the C program
  4. Dउपर्युक्त सभीAll of the above

सही उत्तर / Answer: (D)

हल / Solution
सही उत्तर "उपर्युक्त सभी" है। पहला कथन सही है, क्योंकि header file में library functions की घोषणा और macro परिभाषाएँ होती हैं। दूसरा कथन भी सही है, क्योंकि standard library के functions अलग-अलग headers जैसे stdio.h, math.h, string.h में बँटे हैं और सबका नाम .h पर ख़त्म होता है। तीसरा कथन भी सही है, क्योंकि #include मिलते ही preprocessor उस header की पूरी सामग्री उसी जगह चिपका देता है। तीनों सही हैं, इसलिए विकल्प D।
The answer is all of the above. The first statement is true because a header file holds declarations of library functions and macro definitions. The second is true because standard library functions are spread over many headers such as stdio.h, math.h and string.h, each saved with a .h name. The third is also true, since on reading #include the preprocessor pastes the whole content of that header at that spot. As all three statements hold, option D is correct.
प्रश्न 3उत्तर + हल
डिफ़ॉल्ट header file में क्या होता है?
What does a default header file contain?
  1. Aमशीन कोड (machine code)Machine code
  2. Bफंक्शन की परिभाषाएँ (implementations)Implementations
  3. Cघोषणाएँ (declarations)Declarations
  4. Dपॉइंटिंग (pointing)Pointing

सही उत्तर / Answer: (C)

हल / Solution
सही उत्तर घोषणाएँ हैं। stdio.h जैसी header file में फंक्शन की घोषणा लिखी रहती है — उसका नाम, लौटाने वाला प्रकार और parameters — साथ में macro, स्थिरांक और typedef भी। इससे compiler जान जाता है कि printf को किस तरह बुलाना है। फंक्शन का असली कोड header में नहीं होता, वह पहले से compile होकर library में पड़ा रहता है, इसलिए परिभाषाएँ और मशीन कोड दोनों ग़लत हैं। «पॉइंटिंग» का तो header file से कोई लेना-देना ही नहीं।
The answer is declarations. A header file such as stdio.h contains the declarations of functions, that is their name, return type and parameters, along with macros, constants and typedefs. This is how the compiler learns the correct way to call printf. The real code of a function is not in the header; it is already compiled and kept in the library, so implementations and machine code are both wrong. Pointing has nothing to do with a header file at all.
प्रश्न 4उत्तर + हल
निम्नलिखित में से कौन-सा कीवर्ड हेडर फाइलों को घोषित करने के लिए प्रयोग किया जाता है?
Which of the following keywords is used to declare the header files?
  1. Ainclude
  2. Bexclude
  3. Cstring
  4. Dnamespace

सही उत्तर / Answer: (A)

हल / Solution
सही उत्तर include है। Header file को program में जोड़ने के लिए #include लिखा जाता है, जैसे #include <stdio.h>। तकनीकी रूप से यह C का reserved keyword नहीं, बल्कि preprocessor directive है, पर दिए गए विकल्पों में header जोड़ने वाला शब्द यही है। exclude नाम का कोई directive या keyword C में नहीं है। string एक header (string.h) का नाम हो सकता है, header जोड़ने का शब्द नहीं। namespace C++ की सुविधा है, C में यह नहीं होता।
The answer is include. To add a header file to a program we write #include, for example #include <stdio.h>. Strictly speaking it is a preprocessor directive, not a reserved C keyword, but among these options it is the word used to bring in headers. C has no directive or keyword called exclude. string may be part of a header name like string.h, but it does not include anything. namespace belongs to C++, and plain C has no namespace feature.
प्रश्न 5उत्तर + हल
प्रोग्रामर अपनी कस्टम हेडर फाइल बना सकता है, जिसका अंत किससे होना चाहिए?
A programmer can create custom header files that must end with
  1. A.h एक्सटेंशन.h extension
  2. B.i एक्सटेंशन.i extension
  3. Cios एक्सटेंशनios extension
  4. D.a एक्सटेंशन.a extension

सही उत्तर / Answer: (A)

हल / Solution
सही उत्तर .h एक्सटेंशन है। प्रोग्रामर अपनी header file ख़ुद बना सकता है, जैसे myheader.h। इसमें अपने functions की घोषणा, macro और constant रखे जाते हैं। फिर #include "myheader.h" लिखकर इसे किसी भी program में जोड़ा जा सकता है। Standard headers की तरह custom header भी .h पर ख़त्म होती है। .i वह file है जो preprocessor के बाद बनती है। .a static library यानी archive file होती है। ios कोई C extension नहीं है।
The answer is .h extension. A programmer can write a custom header such as myheader.h. It holds declarations of our own functions, macros and constants. We then add it to any program with #include "myheader.h". Just like standard headers, a custom header ends with .h. A .i file is the output produced after preprocessing. A .a file is a static library, also called an archive. ios is not a C file extension at all, so it cannot be the answer.
प्रश्न 6उत्तर + हल
निम्न C program का आउटपुट क्या होगा? (मान लीजिए stdio.h शामिल किया गया है।)
int main()
{
int a=0;
a = printf("4");
printf("%d",a);
return 0;
}
What is the output of the following C program? (Assume stdio.h has been included.)
int main()
{
int a=0;
a = printf("4");
printf("%d",a);
return 0;
}
  1. A04
  2. Bcompiler error
  3. C40
  4. D41

सही उत्तर / Answer: (D)

हल / Solution
सही उत्तर 41 है। printf अपना काम करने के बाद छापे गए अक्षरों की गिनती लौटाता है। पहला printf पर्दे पर 4 छापता है और लौटाता है एक, जो a में रख दिया जाता है। दूसरा printf उसी a को %d से छापता है, यानी एक। पर्दे पर पहले 4 आता है और उसके बाद 1, इसलिए पूरा आउटपुट 41 बनता है। a की शुरुआती क़ीमत शून्य छपती ही नहीं, इसलिए 04 और 40 दोनों ग़लत हैं।
The answer is 41. After doing its work, printf returns the count of the characters it has printed. The first printf puts 4 on the screen and returns one, and that value is stored in a. The second printf prints the same a with %d, so it shows one. The screen first gets 4 and then 1, which makes the whole output 41. The starting value of a is never printed, so both 04 and 40 are wrong.
प्रश्न 7उत्तर + हल
«एकल वर्ण» (single character) के लिए नियंत्रण वर्ण (control character) कौन-सा है?
What is the control character for a single character?
  1. A%c
  2. B%d
  3. C%i
  4. D%p

सही उत्तर / Answer: (A)

हल / Solution
सही उत्तर %c है। printf और scanf में नियंत्रण वर्ण यानी प्रारूप निर्देशक (format specifier) बताता है कि मान किस प्रकार का है; एक अक्षर के लिए %c लिखते हैं। जैसे char ch = 'A'; पर printf में %c देने से A छपता है। %d और %i पूर्णांक के लिए हैं; %c की जगह %d लिखने पर अक्षर का ASCII मान छपेगा, अक्षर नहीं। %p pointer का पता छापने के लिए है, सो वह भी ग़लत है।
The answer is %c. In printf and scanf the control character, also called the format specifier, tells the function what kind of value it handles; %c is used for a single character. For example, after char ch = 'A'; printf with %c prints A. %d and %i are meant for integers, so %d in place of %c prints the ASCII value instead of the character. %p prints the address held in a pointer, so it is wrong here.
प्रश्न 8उत्तर + हल
बहु-शब्द (multi-word) स्ट्रिंग पढ़ने के लिए कौन अधिक उपयुक्त है?
Which is more appropriate for reading in a multi-word string?
  1. Agets()
  2. Bprintf()
  3. Cscanf()
  4. Dputs()

सही उत्तर / Answer: (A)

हल / Solution
सही उत्तर gets() है। यह एंटर दबाने तक की पूरी पंक्ति पढ़ लेता है और खाली जगह पर रुकता नहीं, इसलिए कई शब्दों वाला वाक्य एक बार में आ जाता है। scanf पहली खाली जगह पर ही रुक जाता है, सो उसे एक ही शब्द मिलता है। printf और puts कुछ पढ़ते ही नहीं, वे छापने वाली फंक्शन हैं। ध्यान रखिए, gets() लंबाई की सीमा नहीं जाँचता और C11 से हटा दिया गया है; नए program में fgets() लिखना चाहिए।
The answer is gets(). It reads the whole line until Enter is pressed and does not stop at a space, so a sentence of several words comes in at one go. scanf with %s stops at the first blank space, so it picks up only one word. printf and puts do not read anything at all; they are output functions. Note that gets() checks no length limit and was removed in C11, so fgets() should be used in new programs.
प्रश्न 9उत्तर + हल
डायनामिक मेमोरी आवंटन में प्रयुक्त malloc() फंक्शन किस हेडर फाइल में उपलब्ध है?
The malloc() function used in dynamic memory allocation is available in which header file?
  1. Astdio.h
  2. Bstdlib.h
  3. Cconio.h
  4. Dmem.h

सही उत्तर / Answer: (B)

हल / Solution
सही उत्तर stdlib.h है। malloc() program चलते समय heap से memory लेता है और उसका pointer लौटाता है। इसकी घोषणा standard header stdlib.h में होती है। इसी में calloc(), realloc() और free() भी घोषित हैं। इसलिए इन्हें लिखने से पहले #include <stdlib.h> जोड़ना पड़ता है। stdio.h में input-output functions होते हैं। conio.h Turbo C का ग़ैर-मानक console header है। mem.h भी Turbo C का header था, जिसमें memcpy() जैसे memory-block functions थे, malloc() नहीं।
The answer is stdlib.h. malloc() takes memory from the heap while the program runs and returns a pointer to it. Its declaration is in the standard header stdlib.h, along with calloc(), realloc() and free(). So we add #include <stdlib.h> before using these functions. stdio.h declares input-output functions. conio.h is a non-standard console header from Turbo C. mem.h was also a Turbo C header for memory-block functions like memcpy(), not for malloc(), so it is not correct.
प्रश्न 10उत्तर + हल
निम्नलिखित में से कौन-सा कथन सत्य है?
Which of the following statements is true?
  1. AC की library functions इनपुट-आउटपुट की सुविधा देती हैंC library functions provide I/O facilities
  2. BC में इनपुट-आउटपुट की सुविधा अंतर्निहित (inherent) हैC has inherent I/O facilities
  3. CC में इनपुट-आउटपुट की सुविधा नहीं हैC does not have I/O facilities
  4. D(a) और (c) दोनोंBoth (a) and (c)

सही उत्तर / Answer: (A)

हल / Solution
सही उत्तर पहला कथन है। C भाषा में छापने या पढ़ने का keyword ही नहीं है — न print, न read। यह काम library फंक्शन करती हैं, जैसे printf, scanf, getchar और fopen, और उनकी घोषणा stdio.h में रहती है। इसलिए यह कहना ग़लत है कि सुविधा भाषा में अंतर्निहित है। यह भी ग़लत है कि C में इनपुट-आउटपुट की सुविधा नहीं है, क्योंकि मानक library C का ही हिस्सा है। तीसरा कथन गिरने से चौथा विकल्प भी गिरता है।
The first statement is true. The C language has no keyword for printing or reading. That work is done by library functions such as printf, scanf, getchar and fopen, whose declarations sit in stdio.h. So it is wrong to say the facility is inherent in the language. It is equally wrong to say C has no I/O facilities at all, because the standard library is part of C. As the third statement fails, the fourth option falls with it.
आगे के 13 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 12उत्तर app में
C भाषा में हेडर फाइल के लिए निम्नलिखित में से कौन-सा मान्य है?
Which of the following is valid in C language for a header file?
  1. A#include<header file.h>
  2. B#include "header file.h"
  3. CA और B दोनोंBoth A & B
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
C भाषा में निम्नलिखित में से कौन-सा stdio.h हेडर फाइल का लाइब्रेरी फंक्शन है?
Which of the following is a library function of the stdio.h header file in C language?
  1. Agetc()
  2. Bputc()
  3. Cprintf()
  4. Dइनमें से सभीall of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
#include स्टेटमेंट कहाँ लिखा जाना चाहिए?
Where must the #include statement be written?
  1. Amain() से पहलेBefore main()
  2. Bसिर्फ़ main() के भीतरOnly inside main()
  3. Cmain() के बादAfter main()
  4. Dइसे कहीं भी लिखा जा सकता हैIt can be written anywhere
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
#include <somefile.h> और #include "somefile.h" ______ फ़ाइलें हैं।
#include <somefile.h> and #include "somefile.h" are ______ files.
  1. ALibrary, Library
  2. BObject, Executable
  3. CUser-created header, Library
  4. Dये सभी प्रकार की header file शामिल कर सकते हैंThey can include all types of header file
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में
मानक C लाइब्रेरी फ़ाइल #include <stdio.h> का उपयोग किया जाता है—
The standard C library file #include <stdio.h> is used to
  1. Aसहायक (utility) फंक्शन घोषित करने के लिएDeclare utility functions
  2. Bगणितीय (mathematical) फंक्शन घोषित करने के लिएDeclare mathematical functions
  3. Cसमय (time) संबंधी फंक्शन घोषित करने के लिएDeclare time functions
  4. Dस्ट्रिंग (string) संबंधी फंक्शन घोषित करने के लिएDeclare string handling functions
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
निम्नलिखित में से कौन-सा फंक्शन हेडर फाइल में पहले से घोषित होता है?
Which of the following functions is already declared in a header file?
  1. Aयूज़र-डिफ़ाइंड फंक्शनUser-defined function
  2. Bबिल्ट-इन फंक्शनBuilt-in function
  3. CC फंक्शनC function
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 21उत्तर app में
header file क्या होती है?
What is a header file?
  1. Aवह फ़ाइल जिसमें मानक लाइब्रेरी फंक्शन (standard library functions) होते हैंA file that contains standard library functions
  2. Bवह फ़ाइल जिसमें program का main() फंक्शन होता हैA file that contains the main() function of the program
  3. Cवह फ़ाइल जिसमें उपयोगकर्ता के बनाए फंक्शन (user-defined functions) होते हैंA file that contains user-defined functions
  4. Dवह फ़ाइल जो वर्तमान working directory में मौजूद होती हैA file that is present in the current working directory
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 22उत्तर app में
C भाषा में हेडर फाइल में क्या होता है?
What does a header file in C contain?
  1. Aकंपाइलर कमांडCompiler command
  2. Bलाइब्रेरी फंक्शनLibrary functions
  3. CC प्रोग्राम की हेडर जानकारीHeader information of C program
  4. Dफाइलों के लिए ऑपरेटरOperator for files
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Header File in C Language के सभी 23 प्रश्न — उत्तर, हल और अभ्यास

FliQi Question Bank app में topic-वार अभ्यास, कठिनाई-स्तर और आपकी प्रगति।

  • पहला test मुफ़्त
  • हिंदी + English
  • जाँचे हुए उत्तर और हल

यह topic किन परीक्षाओं में आता है

C Language के दूसरे topics

सभी topics