C प्रोग्राम में स्टेटमेंट कहाँ से शुरू होना चाहिए?
Where should a statement begin in a C program?
Aपहले कॉलम सेfrom the first column
B7वें कॉलम सेfrom the 7th column
C10वें कॉलम सेfrom the 10th column
Dकिसी भी कॉलम सेfrom any column
सही उत्तर / Answer: (D)
हल / Solution
C एक free-form भाषा है। इसमें compiler spaces, tabs और खाली lines को अनदेखा कर देता है। इसलिए statement किसी भी column से शुरू हो सकता है, और एक line में कई statements भी लिखे जा सकते हैं। Indentation सिर्फ़ पढ़ने में आसानी के लिए किया जाता है। पुरानी FORTRAN में statement 7वें column से शुरू करना पड़ता था, इसी से विकल्प 2 बना है। C में ऐसी कोई रोक नहीं है।
C is a free-form language. The compiler ignores spaces, tabs and blank lines. So a statement can begin from any column, and several statements can even be written on one line. Indentation is used only to make code easier to read. Old FORTRAN required statements to start from the 7th column, which is where option 2 comes from. C has no such rule, so the answer is from any column.
निम्नलिखित C प्रोग्राम का output क्या होगा? main() { extern int i; i = 20; printf("%d", sizeof(i)); }
What is the output of the following C program? main() { extern int i; i = 20; printf("%d", sizeof(i)); }
A2
B4
Ccompiler के अनुसार अलग-अलग होगाWould vary from compiler to compiler
Dत्रुटि, i परिभाषित नहीं हैError, i undefined
सही उत्तर / Answer: (D)
हल / Solution
सही विकल्प : (D) त्रुटि, i परिभाषित नहीं है extern केवल यह घोषित करता है कि चर कहीं और परिभाषित है। वह चर के लिए मेमोरी नहीं जुटाता, बस compiler से कहता है कि नाम मान लो। यहाँ पूरे प्रोग्राम में i की असली परिभाषा है ही नहीं, इसलिए जोड़ते समय linker उसे ढूँढ़ नहीं पाता और त्रुटि देता है। आकार छपने की नौबत ही नहीं आती, इसलिए 2 या 4 कोई उत्तर नहीं बनता।
Correct option : (D) Error, i undefined extern only declares that the variable is defined somewhere else. It reserves no memory and merely tells the compiler to accept the name. In this program no real definition of i exists anywhere, so at link time the linker cannot find it and reports an error. The program never reaches the point of printing a size, so neither 2 nor 4 can be the answer.
C में printf(), puts() और putchar() तीनों output फ़ंक्शन हैं। printf() formatted output देता है। puts() एक string छापकर नई लाइन देता है। putchar() एक character छापता है। getchar() इनसे अलग है। यह keyboard यानी standard input से एक character पढ़ता है, इसलिए यह input फ़ंक्शन है। ध्यान दीजिए, C case-sensitive है और असली नाम छोटे अक्षरों में लिखे जाते हैं, जैसे getchar()। इसलिए output function न होने वाला विकल्प Getchar() है।
In C, printf(), puts() and putchar() are all output functions. printf() gives formatted output. puts() prints a string and then a new line. putchar() prints one character. getchar() is different. It reads one character from the keyboard, that is standard input, so it is an input function. Note that C is case-sensitive and the real names are written in lower case, like getchar(). So the option that is not an output function is Getchar().
निम्नलिखित में से कौन एक द्वितीयक स्थिरांक (secondary constant) है?
Which of the following is a secondary constant?
Aarray
Bpointer
Cunion
Dये सभीAll of these
सही उत्तर / Answer: (D)
हल / Solution
C के constants को primary और secondary में बाँटा जाता है। Primary में integer, real और character constant आते हैं, जो एक सीधा मान रखते हैं। Secondary constant वे हैं जो primary से मिलकर बनते हैं, जैसे array, pointer, structure, union और enum। दिए गए तीनों विकल्प array, pointer और union secondary constant हैं। कोई एक विकल्प अकेले पूरा उत्तर नहीं देता, इसलिए 'ये सभी' सही उत्तर है।
C constants are divided into primary and secondary types. Primary constants are integer, real and character constants, each holding a single direct value. Secondary constants are built from primary ones, such as array, pointer, structure, union and enum. All three given options, array, pointer and union, are secondary constants. No single option alone gives the complete answer, so 'All of these' is the correct choice here.
निम्नलिखित में से कौन-सी C में मान्य घोषणा (declaration) नहीं है? 1. short int x; 2. signed short x; 3. short x; 4. unsigned short x;
Which of the following is not a valid declaration in C? 1. short int x; 2. signed short x; 3. short x; 4. unsigned short x;
A3 और 43 and 4
Bकेवल 2only 2
Cकेवल 1only 1
Dसभी मान्य हैंAll are valid
सही उत्तर / Answer: (D)
हल / Solution
C में short, long, signed और unsigned को modifier कहते हैं। इनके साथ int लिखना ज़रूरी नहीं, वह अपने आप मान लिया जाता है। इसलिए short x; का अर्थ short int x; है। signed short x; का अर्थ signed short int x; है। unsigned short x; का अर्थ unsigned short int x; है। चारों घोषणाएँ बिना error के compile होती हैं। इसलिए सही उत्तर "सभी मान्य हैं" है।
In C, short, long, signed and unsigned are modifiers. Writing int after them is optional, because int is assumed. So short x; means short int x;. signed short x; means signed short int x;. unsigned short x; means unsigned short int x;. All four declarations compile without any error. So the correct answer is "All are valid", and the other options are wrong.
संबंध ऑपरेटर (relational operator) बाएँ से दाएँ जुड़ते हैं, इसलिए हर पंक्ति में पहले 9 > 8 जाँचा जाता है और वह सच होकर 1 बनता है। अब x में 1 > 7 झूठा, सो शून्य; y में 1 > 0 सच, सो एक; z में 1 > 1 झूठा, सो शून्य। छपकर 0 1 0 आता है और विकल्प 2 सही है। ध्यान रखिए, गणित जैसी शृंखला यहाँ नहीं बनती।
Relational operators associate from left to right, so in each line 9 > 8 is tested first and yields 1. For x, 1 > 7 is false, giving zero; for y, 1 > 0 is true, giving one; for z, 1 > 1 is false, giving zero. The printed result is 0 1 0, so option 2 is correct. Note that such a comparison is not a chain as in mathematics.
C कितने बुनियादी लूपिंग ढाँचों (looping constructs) का समर्थन करता है?
C supports how many basic looping constructs?
A2
B3
C4
D6
सही उत्तर / Answer: (B)
हल / Solution
C में तीन बुनियादी लूप हैं — for, while और do-while। for और while पहले शर्त जाँचते हैं, इसलिए इन्हें entry-controlled लूप कहते हैं। do-while पहले body चलाता है और बाद में शर्त देखता है, इसलिए यह exit-controlled है और कम से कम एक बार ज़रूर चलता है। goto से भी दोहराव बन सकता है, पर वह लूप का ढाँचा नहीं माना जाता। इसलिए सही उत्तर 3 है; 2, 4 और 6 ग़लत गिनती हैं।
C has three basic loops: for, while and do-while. The for and while loops check the condition first, so they are entry-controlled loops. The do-while loop runs its body first and checks the condition afterwards, so it is exit-controlled and always runs at least once. A goto can also repeat code, but it is not a looping construct. So the answer is 3, and the counts 2, 4 and 6 are wrong.
ऐरे और पॉइंटर्स के साथ C प्रोग्राम का आउटपुट क्या है?
#include<stdio.h>
void change(int[]);
int main(){
int a[3] = {20,30,40};
change(a);
printf("%d %d", *a, a[0]);
return 0;
}
void change(int a[]){
a[0] = 10;
}
What is the output of C Program with arrays and pointers?
#include<stdio.h>
void change(int[]);
int main(){
int a[3] = {20,30,40};
change(a);
printf("%d %d", *a, a[0]);
return 0;
}
void change(int a[]){
a[0] = 10;
}
A20 20
B10 20
C10 10
D20 30
सही उत्तर / Answer: (C)
हल / Solution
किसी फंक्शन को पूरा ऐरे भेजने पर सदस्यों की नक़ल नहीं बनती, सिर्फ़ उसका आधार पता जाता है। इसलिए change() के भीतर पहला सदस्य दस करने से असली ऐरे ही बदल जाता है। लौटकर तारा वाला रूप और a[0] दोनों उसी पहले सदस्य को पढ़ते हैं, सो दोनों जगह दस छपता है। साधारण चर में ऐसा नहीं होता — वहाँ नक़ल जाती है और भीतर का बदलाव बाहर नहीं दिखता।
Passing a whole array to a function does not copy its elements; only its base address travels. So setting the first element to ten inside change() really changes the original array. Back in main both the starred form and a[0] read that same first element, so ten is printed in both places. An ordinary variable behaves differently: a copy is passed and a change inside is not visible outside.
इस C कोड का आउटपुट क्या है? int main() { int *ptr, a = 10; ptr = &a; *ptr += 1; printf("%d,%d\n", *ptr, a); }
What is the output of this C code? int main() { int *ptr, a = 10; ptr = &a; *ptr += 1; printf("%d,%d\n", *ptr, a); }
A10,10
B10,11
C11,10
D11,11
सही उत्तर / Answer: (D)
हल / Solution
ptr = &a से ptr, a की ओर इशारा करता है। *ptr += 1 का अर्थ है *ptr = *ptr + 1, यानी उस पते पर रखा मान, जो ख़ुद a है, 11 हो जाता है। अब *ptr और a एक ही मेमोरी खाना हैं, इसलिए दोनों 11 छपते हैं। आउटपुट 11,11 है। 10 वाले विकल्प भूल जाते हैं कि *ptr बदलने से a बदलता है, और 11,10 दोनों को अलग कॉपी मान लेता है।
ptr = &a makes ptr point to a. The statement *ptr += 1 means *ptr = *ptr + 1, so the value at that address, which is a itself, becomes 11. Now *ptr and a are the same memory location, so both print 11. The output is 11,11. Options with 10 forget that changing *ptr changes a, and 11,10 wrongly treats them as separate copies.
रिकर्सन से अपेक्षित परिणाम पाने के लिए किस C कीवर्ड का उपयोग करना ज़रूरी है?
What is the C keyword that must be used to achieve expected result using Recursion?
Aprintf
Bscanf
Cvoid
Dreturn
सही उत्तर / Answer: (D)
हल / Solution
recursion में हर कॉल का नतीजा अपनी पिछली कॉल तक पहुँचाना होता है। यह काम return करता है। जैसे fact(n) में return n * fact(n-1) लिखा जाता है। base case पर भी return 1 से रुकना होता है। बिना return के नतीजा ऊपर तक नहीं पहुँचता। printf और scanf कीवर्ड नहीं, लाइब्रेरी फ़ंक्शन हैं। void सिर्फ़ यह बताता है कि फ़ंक्शन कुछ नहीं लौटाता।
In recursion, the result of each call must be passed back to the call before it, and return does this. For example, fact(n) uses return n * fact(n-1), and the base case stops with return 1. Without return, the result never reaches the top. printf and scanf are library functions, not keywords, and void only says that a function returns nothing.
आगे के 10 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
निम्न code को देखिए। typedef union unox { char cox; int gox; } uox; struct mox { char box; uox lox; } fox; निम्न में से कौन-सा statement सही assignment करता है?
Look at the following code. typedef union unox { char cox; int gox; } uox; struct mox { char box; uox lox; } fox; Which of the following statements makes a correct assignment?