FliQi Education App Download
विषय-वार प्रश्न-बैंक

C Language — प्रश्न-बैंक

2,107 जाँचे हुए प्रश्न · 35 topics · 6 पिछले वर्षों के पेपरों से

Topics

और: Types of Errors of C Language · Comments of C Language · Command Line Arguments of C Language · Keywords of C Language · Software · Escape character · Identifiers of C Language · File Handling of C Language · Const (Read Only Variable) of C Language · Buffer Concept in C Language (कम प्रश्न — app में)

किन परीक्षाओं में

नमूना प्रश्न

भाषा
प्रश्न 1उत्तर + हल Operator in C Language
इस C प्रोग्राम कोड का आउटपुट क्या है?

#include<stdio.h>

int main()

{

int x = -2;

x = x >> 1;

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

}
What is the output of this C program code?

#include<stdio.h>

int main()

{

int x = -2;

x = x >> 1;

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

}
  1. A1
  2. B-1
  3. C-2
  4. D-4

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

हल / Solution
ऋणात्मक संख्या भीतर दो का पूरक (two's complement) रूप में रखी जाती है, सो 32 बिट में -2 के सारे बिट एक होते हैं और आख़िरी शून्य। दायाँ खिसकाव (right shift) पर चिह्न वाला बिट बना रहता है, इसलिए सारे बिट एक हो जाते हैं और वही -1 दिखाता है। मानक संकलकों में यही अंकगणितीय खिसकाव चलता है, सो आउटपुट -1 आता है और विकल्प 2 सही है। -4 तो गुणा करने जैसा नतीजा होता।
A negative number is stored in two's complement form, so in 32 bits -2 has all bits set to one except the last. On a right shift the sign bit is preserved, so every bit becomes one, and that pattern stands for -1. Mainstream compilers all use this arithmetic shift, so the output is -1 and option 2 is correct. A value of -4 would come from multiplying instead of dividing.
प्रश्न 2उत्तर + हल Array in C Language
_______ एक समांगी संरचना है जो _______ सूचकांक से शुरू होता है।
An _______ is a homogenous structure and starts with _______ index number.
  1. Aस्ट्रिंग, एकStrings, one
  2. Bशब्दकोष, शून्यDictionary, zero
  3. Cव्यूह, शून्यArray, zero
  4. Dव्यूह, एकArray, one

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

हल / Solution
व्यूह यानी ऐरे (array) एक समांगी (homogeneous) संरचना है — उसके सारे सदस्य एक ही डेटा प्रकार के होते हैं। C में उसका सूचकांक (index) शून्य से शुरू होता है, इसलिए n सदस्यों वाले ऐरे के सूचकांक शून्य से n−1 तक चलते हैं। स्ट्रिंग भी भीतर से अक्षरों का ऐरे ही है, पर उसका सूचकांक एक से शुरू नहीं होता; और शब्दकोष C की कोई संरचना ही नहीं है। इसलिए «व्यूह, शून्य» सही जोड़ा है।
An array is a homogeneous structure, which means every element in it has the same data type. In C its index starts at zero, so an array of n elements uses the indexes zero to n−1 and its last element is reached as a[n-1]. A string is itself an array of characters, but its index does not begin at one, and a dictionary is not a C structure at all. Hence Array, zero is the correct pair.
प्रश्न 3उत्तर + हल Control Statements in C Language
निम्नलिखित में से कौन सा C कथन वाक्य-रचना की दृष्टि से सही है?
Which of the following C statement is syntactically correct?
  1. Afor (;;);
  2. Bfor (;);
  3. Cfor ();
  4. Dfor (.);

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

हल / Solution
for की वाक्य-रचना में कोष्ठक के भीतर ठीक दो अर्ध-विराम चाहिए, क्योंकि वे तीन खानों को अलग करते हैं — शुरुआत, शर्त और वृद्धि। खाने ख़ाली छोड़े जा सकते हैं, पर अर्ध-विराम नहीं छोड़े जा सकते। इसी से पहला रूप पूरी तरह वैध है और वह अनंत लूप बनाता है। दूसरे में एक अर्ध-विराम कम है, तीसरे में एक भी नहीं, और चौथे में बिंदु का कोई अर्थ नहीं — तीनों पर कंपाइलर त्रुटि देता है।
The syntax of for needs exactly two semicolons inside the parentheses, because they separate the three slots: initialisation, condition and increment. The slots themselves may be left empty, but the semicolons may not be dropped. That is why the first form is perfectly legal and builds an endless loop. The second has one semicolon too few, the third has none, and a lone dot in the fourth means nothing, so all three fail to compile.
प्रश्न 4उत्तर + हल Structure in C Language
typedef डिक्लेरेशन क्या है?
What is typedef declaration?
  1. Aकोई नया प्रकार नहीं बनाता हैDoes not create a new type
  2. Bयह केवल कुछ मौजूदा प्रकार के लिए एक नया नाम जोड़ता हैIt merely adds a new name for some existing type
  3. Cकोई नया प्रकार नहीं बनाता है, यह केवल कुछ मौजूदा प्रकार के लिए एक नया नाम जोड़ता हैDoes not create a new type, It merely adds a new name for some existing type
  4. Dउल्लिखित में से कोई नहींNone of the mentioned

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

हल / Solution
typedef कोई नया डाटा टाइप (data type) नहीं बनाता; वह किसी पहले से मौजूद टाइप को दूसरा नाम, यानी उपनाम (alias), दे देता है। typedef int integer; लिखने पर integer और int एक ही टाइप रहते हैं, कोई तीसरा टाइप नहीं बनता। विकल्प 1 और 2 इसी एक बात के आधे-आधे हिस्से हैं, इसलिए अकेले अधूरे हैं। विकल्प 3 दोनों हिस्से साथ कहता है, सो पूरी परिभाषा वही है, और विकल्प 4 ग़लत है क्योंकि सही कथन मौजूद है।
A typedef does not create a new data type. It only gives an existing type a second name, that is an alias. After typedef int integer; the names integer and int mean exactly the same type, so nothing new comes into being. Options 1 and 2 are the two halves of this single idea, so each alone is incomplete. Option 3 states both halves, which is the full definition.
प्रश्न 5उत्तर + हल Function in C Language
इस C कोड का आउटपुट क्या है?

#include<stdio.h>

int x = 5;

void main(){

    int x = 3;

    printf("%d", x);

    {

        int x = 4;

    }

    printf("%d", x);

}
What is the output of this C code?

#include<stdio.h>

int x = 5;

void main(){

    int x = 3;

    printf("%d", x);

    {

        int x = 4;

    }

    printf("%d", x);

}
  1. A3 3
  2. B3 4
  3. C3 5
  4. Dरन टाइम एररRun time error

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

हल / Solution
बाहर x का मान पाँच है, पर main के भीतर नया x बनता है जिसका मान तीन है और जो बाहर वाले को ढक देता है। पहला printf इसी भीतरी चर को देखता है, सो तीन छपता है। आगे के कोष्ठक-खंड में एक और x बनता है जिसका मान चार है, पर वह उसी खंड तक सीमित है और कोष्ठक बंद होते ही मिट जाता है। दूसरा printf फिर main वाले x को पढ़ता है, इसलिए दोबारा तीन आता है।
Outside, x has the value five, but inside main a new x with value three hides it. The first printf sees this inner variable, so it prints three. The block in braces that follows creates yet another x with value four, yet that variable lives only inside that block and dies as soon as the brace closes. The second printf therefore reads main's own x once more and prints three again.
प्रश्न 6उत्तर + हल Data Type in C Language
C प्रोग्रामिंग में float डेटा टाइप की रेंज क्या है?
What is the range of the float data type in C programming?
  1. A0 to 4294967295
  2. B-3.4e38 to +3.4e38
  3. C-1.7e308 to +1.7e308
  4. D-1.7e4932 to +1.7e4932

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

हल / Solution
float 4 byte यानी 32 bit में रखा जाता है, जिसमें आठ bit घातांक (exponent) के लिए होते हैं। इसी वजह से उसका मान लगभग -3.4e38 से +3.4e38 तक जा सकता है। पहला विकल्प unsigned long int की पूर्णांक सीमा है। तीसरा विकल्प 8 byte वाले double की सीमा है और चौथा 10 byte वाले long double की। इसलिए float के लिए दूसरा विकल्प ही सही बैठता है।
A float is kept in 4 bytes, that is 32 bits, of which eight bits are given to the exponent. That is why its value can run from about -3.4e38 to +3.4e38. The first option is the integer range of an unsigned long int. The third option is the range of the 8 byte double and the fourth that of the 10 byte long double. So only the second option fits a float.
प्रश्न 7उत्तर + हल Storage Classes in C Language
निम्नलिखित कोड का आउटपुट क्या होगा?

#include<stdio.h>

int main()

{

extern int var;

printf("The value of var is %d", var);

return 0;

}
What will be the output of the following code?

#include<stdio.h>

int main()

{

extern int var;

printf("The value of var is %d", var);

return 0;

}
  1. A0
  2. Bगार्बेजgarbage
  3. Cकोई आउटपुट नहींNo output
  4. Dलिंकिंग एररLinking error

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

हल / Solution
extern वाली पंक्ति सिर्फ़ घोषणा है, परिभाषा नहीं — वह compiler से कहती है कि var कहीं और बना हुआ है। पूरे प्रोग्राम में var की परिभाषा कहीं दी ही नहीं गई, इसलिए संकलन तो हो जाता है पर जोड़ते समय लिंकर को वह चिह्न मिलता ही नहीं। तब «undefined reference» जैसी लिंकिंग एरर आती है। चूँकि प्रोग्राम चल ही नहीं पाता, शून्य या गार्बेज छपने का सवाल नहीं उठता।
The extern line is only a declaration and not a definition; it tells the compiler that var is created somewhere else. Nowhere in the program is var actually defined, so compilation succeeds but the linker cannot find that symbol while joining the object files. It then reports an undefined reference, which is a linking error. Since the program never runs, neither zero nor garbage can ever be printed.
प्रश्न 8उत्तर + हल String in C Language
निम्नलिखित सी कोड का आउटपुट क्या होगा?

#include <stdio.h>

    void main()

    {

        char *a[3][3] = {{"hey", "hi", "hello"}, {"his", "her", "hell"}

        , {"hellos", "hi's", "hmm"}};

        printf("%s", a[1][1]);

    }
What will be the output of the following C code?

#include <stdio.h>

    void main()

    {

        char *a[3][3] = {{"hey", "hi", "hello"}, {"his", "her", "hell"}

        , {"hellos", "hi's", "hmm"}};

        printf("%s", a[1][1]);

    }
  1. Aher
  2. Bhi
  3. Cकम्पाइल टाइम एररCompile time error
  4. Dhis

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

हल / Solution
a एक 3×3 की दो-आयामी array है, जिसका हर खाना एक string का पता रखता है। index शून्य से शुरू होता है। a[1] दूसरी पंक्ति है, यानी his, her और hell। उसमें a[1][1] दूसरा खाना है, यानी her। इसलिए आउटपुट her है। his तो a[1][0] है और hi a[0][1] है। double quotes के भीतर single quote लिखना पूरी तरह सही है, इसलिए कोई compile error नहीं आता।
a is a 3x3 two-dimensional array, and each cell holds the address of a string. Indexing starts from zero. a[1] is the second row: his, her and hell. a[1][1] is the second cell of that row, which is her. So the output is her. his is a[1][0] and hi is a[0][1]. A single quote inside double quotes is fully valid, so there is no compile error.
प्रश्न 9उत्तर + हल Tokens in C Language
निम्नलिखित में से कौन-से C में टोकन हैं?
Which of the following are tokens in C?
  1. Aआइडेंटिफायर (Identifiers)Identifiers
  2. Bकॉन्स्टेंट (Constants)Constants
  3. Cकीवर्ड (Keywords)Keywords
  4. Dउपरोक्त सभीAll of the mentioned

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

हल / Solution
C के टोकन छह वर्गों में आते हैं: keyword, identifier, constant, string, operator और special symbol। जैसे float rate = 7.5; में float एक keyword है, rate एक identifier है, 7.5 एक constant है, = एक operator है और ; एक special symbol है। identifier, constant और keyword तीनों ही टोकन के वर्ग हैं। इसलिए A, B या C अकेले अधूरे हैं और सही उत्तर D है।
C tokens fall into six classes: keywords, identifiers, constants, string literals, operators and special symbols. In the statement float rate = 7.5; float is a keyword, rate is an identifier, 7.5 is a constant, = is an operator and ; is a special symbol. Since identifiers, constants and keywords are each a class of token, none of A, B or C alone is complete, and the answer is D.
प्रश्न 10उत्तर + हल Preprocessor in C Language
निम्नलिखित C कोड का आउटपुट क्या होगा?

#include <stdio.h>

    #define MIN 0);

    #ifdef MIN

    #define MAX 10

    #endif

    int main()

    {

        printf("%d %d\n", MAX, MIN

        return 0;

    }
What will be the output of the following C code?

#include <stdio.h>

    #define MIN 0);

    #ifdef MIN

    #define MAX 10

    #endif

    int main()

    {

        printf("%d %d\n", MAX, MIN

        return 0;

    }
  1. A10 0
  2. Bprintf की गलत syntax के कारण कम्पाइल टाइम एररCompile time error due to illegal syntax for printf
  3. Cअपरिभाषित व्यवहारUndefined behaviour
  4. DMIN के गलत मान के कारण कम्पाइल टाइम एररCompile time error due to illegal MIN value

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

हल / Solution
MIN का पाठ "0);" है। #ifdef MIN सिर्फ़ यह देखता है कि MIN परिभाषित है या नहीं, उसका मान नहीं, इसलिए MAX 10 बन जाता है। अब printf("%d %d\n", MAX, MIN फैलकर printf("%d %d\n", 10, 0); बनता है। अधूरा दिखने वाला printf macro से पूरा हो जाता है। इसलिए कोड सही चलता है और 10 0 छपता है। preprocessor macro के पाठ में कोष्ठक या semicolon पर आपत्ति नहीं करता, इसलिए विकल्प 2 और 4 ग़लत हैं।
The text of MIN is "0);". #ifdef MIN only checks whether MIN is defined, not its value, so MAX becomes 10. Then printf("%d %d\n", MAX, MIN expands to printf("%d %d\n", 10, 0);. The printf that looks incomplete is completed by the macro. So the code runs and prints 10 0. The preprocessor does not object to brackets or a semicolon in a macro, so options 2 and 4 are wrong, and so is option 3.
C Language का पूरा प्रश्न-बैंकहर topic के सारे प्रश्न, हल और अभ्यास — FliQi Question Bank app में