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

Input Output Functions in C language — प्रश्न और उत्तर

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

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

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

भाषा
प्रश्न 1उत्तर + हल
निम्न program का आउटपुट क्या है?
#include<stdio.h>
int main()
{
printf("Hello Boss.");
}
What is the output of the program?
#include<stdio.h>
int main()
{
printf("Hello Boss.");
}
  1. AHello Boss.
  2. Bhello boss
  3. Cकोई आउटपुट नहींNo output
  4. Dकंपाइलर त्रुटिCompiler error

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

हल / Solution
printf() को उद्धरण चिह्नों के भीतर जो पाठ दिया जाता है वह ज्यों का त्यों पर्दे पर छपता है — न बड़े-छोटे अक्षर बदलते हैं और न बिंदु हटता है। इसलिए यहाँ Hello Boss. वैसा ही दिखेगा। दूसरा विकल्प सारे अक्षर छोटे कर देता है, जो printf नहीं करता। stdio.h जुड़ा है, main() मौजूद है और कोष्ठक संतुलित हैं, सो न कोई त्रुटि आती है और न आउटपुट ख़ाली रहता है।
Whatever text is handed to printf() inside quotation marks is printed on the screen exactly as it stands: the case of the letters is not changed and the full stop is not dropped. So Hello Boss. appears just like that. The second option lowers every letter, which printf never does. stdio.h is included, main() is present and the brackets are balanced, so there is neither an error nor an empty output.
प्रश्न 2उत्तर + हल
निम्नलिखित में से कौन-सा कैरेक्टर ओरिएंटेड (character oriented) कंसोल I/O फंक्शन है?
Which of the following is a character oriented console I/O function?
  1. Agetchar() तथा putchar()getchar() and putchar()
  2. Bgets() तथा puts()gets() and puts()
  3. Cscanf() तथा printf()scanf() and printf()
  4. Dfgets() तथा fputs()fgets() and fputs()

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

हल / Solution
getchar() एक बार में एक अक्षर पढ़ता है और putchar() एक बार में एक अक्षर छापता है, इसलिए यही जोड़ा अक्षर-आधारित कंसोल I/O कहलाता है। gets() और puts() पूरी पंक्ति यानी string पर काम करते हैं, सो वे string वाले function हैं। scanf() और printf() format देखकर किसी भी प्रकार का मान पढ़ते-लिखते हैं, इसलिए उन्हें formatted I/O कहा जाता है। fgets() तथा fputs() में stream बताना पड़ता है, वे फ़ाइल से जुड़े रहते हैं।
getchar() reads one character at a time and putchar() prints one character at a time, so this pair is the character oriented console input and output. gets() and puts() work on a whole line, that is, on a string, so they belong to the string group. scanf() and printf() read and write values of any type by looking at a format string, which makes them formatted functions. fgets() and fputs() need a stream, so they are tied to files.
प्रश्न 3उत्तर + हल
ग़लत statement की पहचान कीजिए।
Identify the wrong statement.
  1. Aputchar(65)
  2. Bputchar('x')
  3. Cputchar("x")
  4. Dputchar('\n')

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

हल / Solution
putchar() का prototype int putchar(int c) है, यानी यह एक character या उसका int code लेकर छापता है। putchar(65) ASCII 65 यानी A छापता है। putchar('x') character x छापता है और putchar('\n') नई लाइन देता है। पर "x" double quotes में है, इसलिए यह string literal है। इसका मान एक address होता है, character नहीं। pointer को int की जगह देना ग़लत है, इसलिए putchar("x") ग़लत statement है।
The prototype of putchar() is int putchar(int c), so it takes one character, or its int code, and prints it. putchar(65) prints ASCII 65, which is A. putchar('x') prints the character x and putchar('\n') gives a new line. But "x" is in double quotes, so it is a string literal. Its value is an address, not a character. Passing a pointer where an int is expected is wrong, so putchar("x") is the wrong statement.
प्रश्न 4उत्तर + हल
त्रुटि होने पर printf() function कौन-सा मान लौटाता है?
Which value does the printf() function return when an error occurs?
  1. Aधनात्मक मान (positive value)Positive value
  2. Bशून्यZero
  3. Cऋणात्मक मान (negative value)Negative value
  4. Dइनमें से कोई नहींNone of these

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

हल / Solution
काम ठीक हो जाने पर printf() छपे अक्षरों की गिनती लौटाता है, इसलिए सफलता में मान धनात्मक रहता है। लिखते समय गड़बड़ हो जाए — जैसे जिस stream पर लिखा जा रहा था वह बिगड़ जाए — तो वह ऋणात्मक मान लौटाकर यही बताता है कि लिखाई पूरी नहीं हुई। शून्य का अर्थ सिर्फ़ यह होता है कि कुछ भी नहीं छपा, वह त्रुटि का संकेत नहीं है। एक निश्चित उत्तर मौजूद है, सो चौथा विकल्प भी नहीं बनता।
When the work goes through, printf() returns the count of characters printed, so on success the value stays positive. If something goes wrong while writing, for example the stream being written to fails, it returns a negative value, and that is how it reports that the output was not completed. Zero only means that nothing was printed, which is not a sign of an error. A definite answer is present, so the fourth option does not hold either.
प्रश्न 5उत्तर + हल
कौन-सा फ़ंक्शन keyboard से मान प्राप्त करता है? (RPSC ACP programmer 2011)
Which function receives a value from the keyboard? (RPSC ACP programmer 2011)
  1. Aprintf()
  2. Bscanf()
  3. CA और B दोनोंboth A & B
  4. Dइनमें से कोई नहींnone of these

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

हल / Solution
scanf() C का formatted input फ़ंक्शन है। यह keyboard यानी standard input से data पढ़ता है और दिए गए address वाले variable में रख देता है। जैसे scanf("%d", &a) एक integer पढ़कर a में रखता है। printf() इसका उलटा काम करता है, यानी data को screen पर दिखाता है। printf() कोई मान नहीं पढ़ता, इसलिए "दोनों" ग़लत है। सही उत्तर मौजूद है, इसलिए "कोई नहीं" भी ग़लत है। सही उत्तर scanf() है।
scanf() is the formatted input function of C. It reads data from the keyboard, that is standard input, and stores it in the variable whose address is given. For example, scanf("%d", &a) reads an integer into a. printf() does the opposite job: it shows data on the screen. printf() does not read any value, so both A and B is wrong. The right answer is present, so none of these is wrong too.
प्रश्न 6उत्तर + हल
C भाषा में printf() और scanf() फ़ंक्शन का default return type क्या है?
What is the default return type of the printf() and scanf() functions in C language?
  1. Achar
  2. Binteger
  3. Cheader file
  4. Dउपरोक्त सभीAll of the above

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

हल / Solution
printf() और scanf() दोनों का return type int है, यानी integer। printf() छापे गए characters की गिनती लौटाता है। scanf() बताता है कि कितने मान सफलतापूर्वक पढ़े गए। जैसे x = printf("Hello") के बाद x में 5 आता है। char इनका return type नहीं है। header file कोई data type है ही नहीं, हाँ इन फ़ंक्शन का declaration stdio.h में होता है। पहला और तीसरा विकल्प ग़लत हैं, इसलिए "उपरोक्त सभी" भी ग़लत है।
Both printf() and scanf() have the return type int, that is, integer. printf() returns the number of characters printed. scanf() tells how many values were read successfully. For example, after x = printf("Hello"), x holds 5. char is not their return type. A header file is not a data type at all, though these functions are declared in stdio.h. Options 1 and 3 are wrong, so All of the above is wrong too.
प्रश्न 7उत्तर + हल
C में printf() library function का return type क्या है?
What is the return type of the printf() library function in C?
  1. Aint
  2. Bchar
  3. Cfloat
  4. Dclass

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

हल / Solution
printf() का prototype int printf(const char *format, ...) है, इसलिए इसका return type int है। यह छापे गए characters की गिनती लौटाता है। जैसे x = printf("Hello") करने पर screen पर Hello छपता है और x में 5 आता है। output में कोई गड़बड़ हो तो यह ऋणात्मक मान लौटाता है। char और float इसके return type नहीं हैं। class C++ की अवधारणा है, C भाषा में class होती ही नहीं। इसलिए सही उत्तर int है।
The prototype of printf() is int printf(const char *format, ...), so its return type is int. It returns the number of characters it printed. For example, x = printf("Hello") prints Hello on the screen and puts 5 in x. If an output error occurs, it returns a negative value. char and float are not its return type. class is a C++ idea and does not exist in C. So the correct answer is int.
प्रश्न 8उत्तर + हल
C में scanf() library function का return type क्या है?
What is the return type of the scanf() library function in C?
  1. Aint
  2. Bchar
  3. Cfloat
  4. Dclass

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

हल / Solution
scanf() का prototype int scanf(const char *format, ...) है, यानी यह int लौटाता है। यह मान बताता है कि कितने input सफलतापूर्वक पढ़कर variables में रखे गए। जैसे scanf("%d%d", &a, &b) दोनों मान ठीक मिलने पर 2 लौटाता है। input ख़त्म हो जाए या पढ़ने से पहले गड़बड़ हो तो EOF लौटता है, जो एक ऋणात्मक int है। char और float इसका return type नहीं हैं। class C++ की अवधारणा है, C में होती ही नहीं।
The prototype of scanf() is int scanf(const char *format, ...), so it returns an int. This value tells how many inputs were read and stored in variables successfully. For example, scanf("%d%d", &a, &b) returns 2 when both values are read. If input ends or fails before anything is read, it returns EOF, which is a negative int. char and float are not its return type. class is a C++ idea and does not exist in C.
प्रश्न 9उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
int a,b;
scanf("%d",&a,&b);
What will be the output of the following C code?
int a,b;
scanf("%d",&a,&b);
  1. Aसिर्फ़ एक input लेता हैtakes only one input
  2. Bcompiler error
  3. Cदो input लेता हैTakes two input
  4. Dकुछ नहींNothing

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

हल / Solution
scanf() उतने ही मान पढ़ता है जितने format string में specifier हैं। यहाँ format में सिर्फ़ एक %d है, इसलिए एक integer पढ़कर a में रखा जाता है। &b फ़ालतू argument है। C standard के अनुसार फ़ालतू arguments छोड़ दिए जाते हैं, इसलिए b को कुछ नहीं मिलता। यह valid code है, इसलिए compiler error नहीं। दो input के लिए scanf("%d%d", &a, &b) लिखना पड़ता। program input के लिए रुकता है, इसलिए "कुछ नहीं" भी ग़लत है।
scanf() reads only as many values as there are specifiers in the format string. Here the format has just one %d, so one integer is read and stored in a. &b is an extra argument. Standard C says extra arguments are ignored, so b gets nothing. The code is valid, so there is no compiler error. To read two inputs you would write scanf("%d%d", &a, &b). The program does wait for input, so Nothing is also wrong.
प्रश्न 10उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
scanf("%d");
What will be the output of the following C code?
scanf("%d");
  1. A0
  2. Bcompiler error
  3. CGarbage
  4. Dकुछ नहींNothing

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

हल / Solution
scanf("%d") में %d तो है, पर मान रखने के लिए कोई address नहीं दिया गया। ऐसा code compile हो जाता है, compiler बस warning दे सकता है, इसलिए compiler error नहीं आती। यह statement सिर्फ़ keyboard से पढ़ने की कोशिश करता है। इसमें printf() जैसा कोई output वाला फ़ंक्शन नहीं है, इसलिए screen पर कुछ नहीं छपता। address न होने से यह undefined behavior भी है। 0 या garbage छपने की कोई वजह नहीं, इसलिए सही उत्तर Nothing है।
In scanf("%d") there is a %d, but no address is given to store the value. Such code still compiles; the compiler may only give a warning, so there is no compiler error. The statement only tries to read from the keyboard. It has no output function like printf(), so nothing appears on the screen. The missing address also makes it undefined behaviour. There is no reason for 0 or garbage to be printed, so the answer is Nothing.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 20उत्तर app में
इस C कोड का आउटपुट क्या है?
int main()
{
int x;
printf("Hello World! %d \n", x);
return 0;
}
What is the output of this C code?
int main()
{
int x;
printf("Hello World! %d \n", x);
return 0;
}
  1. AHello World! x;
  2. BHello World! के बाद कोई junk valueHello World! followed by a junk value
  3. CCompile time error
  4. Dgarbage
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 26उत्तर app में
निम्नलिखित कोड को compile करके चलाने पर क्या होगा?
main()
{
printf("%d",main);
}
What will happen after compiling and running the following code?
main()
{
printf("%d",main);
}
  1. AError
  2. Bअनंत (Infinite) चलेगाInfinite
  3. Cकोई address print होगाSome address will be printed
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 29उत्तर app में
इस C कोड का आउटपुट क्या है?
int main()
{
printf("Hello World! %d \n", x);
return 0;
}
What is the output of this C code?
int main()
{
printf("Hello World! %d \n", x);
return 0;
}
  1. AHello World! x;
  2. BHello World! के बाद कोई junk valueHello World! followed by a junk value
  3. CCompile time error
  4. DHello World!
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Input Output Functions in C language के सभी 33 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

C Language के दूसरे topics

सभी topics