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

Format Specifiers of C Language — प्रश्न और उत्तर

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

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

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

भाषा
प्रश्न 1उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

        int a;

                printf("Enter number: ");

                scanf("%5d", &a); //input 1234567

                printf("%d", a);

                return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

        int a;

                printf("Enter number: ");

                scanf("%5d", &a); //input 1234567

                printf("%d", a);

                return 0;

}
  1. A1234567
  2. B12345
  3. C123
  4. D54321

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

हल / Solution
scanf में %5d जैसी चौड़ाई बताती है कि ज़्यादा से ज़्यादा कितने अक्षर पढ़े जाएँ। इनपुट 1234567 में से सिर्फ़ पहले 5 अंक, यानी 12345, a में जाते हैं। बचे हुए 67 input buffer में रह जाते हैं। इसलिए 'Enter number:' संदेश के बाद printf 12345 छापता है। पूरा 1234567 सिर्फ़ सादे %d से पढ़ा जाता। 123 और 54321 का कोई आधार नहीं — scanf न 3 अंक पढ़ता है, न उन्हें उलटता है।
In scanf, a width like %5d limits how many characters are read. From the input 1234567, only the first 5 digits, 12345, are read into a. The remaining 67 stays in the input buffer. So after the prompt Enter number:, printf prints 12345. The full 1234567 would be read only with plain %d. 123 and 54321 have no basis: scanf neither reads 3 digits here nor reverses them.
प्रश्न 2उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

char str[10];

int x;

scanf("%d:%4s",&x,str);// Enter 10:FliQi as input

printf("%d : %s",x, str);

return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

char str[10];

int x;

scanf("%d:%4s",&x,str);// Enter 10:FliQi as input

printf("%d : %s",x, str);

return 0;

}
  1. A10 : FliQi
  2. B10 : FliQ
  3. C0 : FliQi
  4. DGarbage: FliQ

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

हल / Solution
फ़ॉर्मेट "%d:%4s" के तीन हिस्से हैं। %d से x में 10 जाता है। फ़ॉर्मेट का colon इनपुट के colon से मिलता है, इसलिए वह छोड़ दिया जाता है। फिर %4s ज़्यादा से ज़्यादा 4 अक्षर पढ़ता है, इसलिए str में FliQ जाता है और आख़िरी i buffer में रह जाता है। printf से 10 : FliQ छपता है। FliQi के लिए चौड़ाई 4 नहीं होनी चाहिए, और x सही पढ़ा गया, इसलिए 0 या garbage ग़लत है।
The format "%d:%4s" has three parts. %d reads 10 into x. The colon in the format must match the colon in the input, so it is skipped. Then %4s reads at most 4 characters, so str gets FliQ and the last i stays in the buffer. printf("%d : %s") prints 10 : FliQ. FliQi would need %s without width 4, and x is read correctly, so 0 or garbage is wrong.
प्रश्न 3उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

char ch=65;

printf("%c\n", ch);

return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

char ch=65;

printf("%c\n", ch);

return 0;

}
  1. A65
  2. BA
  3. CCompile Time Error
  4. Da

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

हल / Solution
char वेरिएबल असल में एक छोटा पूर्णांक रखता है, इसलिए char ch = 65 बिलकुल सही है, कोई compile error नहीं। 65 बड़े अक्षर A का ASCII कोड है। %c मान को अक्षर के रूप में छापता है, इसलिए आउटपुट A है और फिर नई पंक्ति आती है। 65 देखना हो तो %d लगाना पड़ता। छोटे a का कोड 97 है, वह 65 से नहीं बन सकता। मान कैसे दिखे, यह specifier तय करता है।
A char variable holds a small integer, so char ch = 65 is valid and gives no compile error. The value 65 is the ASCII code of the capital letter A. The %c specifier prints the value as a character, so the output is A, followed by a new line. The number 65 would appear with %d. Small a has code 97, so it cannot come from 65. The specifier decides how the value looks.
प्रश्न 4उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

char ch;

scanf("%c", &ch); // input is 97

printf("%d\n", ch-32);

return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

char ch;

scanf("%c", &ch); // input is 97

printf("%d\n", ch-32);

return 0;

}
  1. A65
  2. BA
  3. C25
  4. Da

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

हल / Solution
%c एक ही अक्षर पढ़ता है, इसलिए इनपुट 97 में से ch में सिर्फ़ '9' जाता है। '9' का ASCII कोड 57 है, क्योंकि '0' का कोड 48 है और '9' = 48 + 9। ch - 32 से 57 - 32 = 25 मिलता है, और %d उसे 25 छापता है। 65 वाला विकल्प मानता है कि पूरी संख्या 97 पढ़ी गई, जो %c कभी नहीं करता। A या a छपने के लिए printf में %c चाहिए था।
%c reads a single character, so from the input 97 scanf stores only '9' in ch. The ASCII code of '9' is 57, since '0' is 48 and '9' is 48 + 9. The expression ch - 32 gives 57 - 32 = 25, and %d prints it as 25. The option 65 assumes the whole number 97 was read, which %c never does. A and a would need %c in printf.
प्रश्न 5उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

char ch;

scanf("%c", &ch); // input is 65

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

return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

char ch;

scanf("%c", &ch); // input is 65

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

return 0;

}
  1. A65
  2. BA
  3. C54
  4. D6

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

हल / Solution
%c सिर्फ़ एक अक्षर पढ़ता है, इसलिए इनपुट 65 में से scanf केवल अक्षर '6' लेता है। '5' buffer में रह जाता है। अक्षर '6' का ASCII कोड 54 है, क्योंकि '0' का कोड 48 है और '6' = 48 + 6। printf का %d ch का अंकीय कोड छापता है, इसलिए आउटपुट 54 है। 65 या A तभी आते जब पूरी संख्या पढ़ी जाती, और 6 छपने के लिए printf में %c चाहिए था।
%c reads only one character, so from the input 65 scanf takes just the character '6'. The '5' stays in the buffer. The character '6' has ASCII code 54, because '0' is 48 and '6' is 48 + 6. printf with %d prints the numeric code of ch, so the output is 54. 65 and A would need scanf to read the whole number, and 6 would need %c in printf.
प्रश्न 6उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

char ch;

scanf("%c", &ch); // input is A

printf("%c\n", ch);

return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

char ch;

scanf("%c", &ch); // input is A

printf("%c\n", ch);

return 0;

}
  1. A65
  2. BA
  3. C97
  4. Da

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

हल / Solution
scanf का %c इनपुट से ठीक एक अक्षर पढ़ता है। उपयोगकर्ता A टाइप करता है, इसलिए ch में अक्षर 'A' जाता है, जिसका ASCII मान 65 है। printf का %c उसी मान को अक्षर के रूप में छापता है, इसलिए आउटपुट A है और फिर नई पंक्ति आती है। 65 तभी छपता जब %d लगाया जाता। 97 छोटे a का कोड है, और यहाँ अक्षर का case कहीं नहीं बदलता।
scanf with %c reads exactly one character from the input. The user types A, so ch stores the character 'A', whose ASCII value is 65. printf with %c prints the stored value as a character, so the output is A, followed by a new line. The number 65 would appear only with %d. 97 is the ASCII code of small a, and nothing here changes the letter case.
प्रश्न 7उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

char str[20];

scanf("%s", str); // input is FliQi Education

printf("%s\n", str);

return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

char str[20];

scanf("%s", str); // input is FliQi Education

printf("%s\n", str);

return 0;

}
  1. AFliQi
  2. BFliQi Education
  3. CEducation
  4. DPrint Nothing

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

हल / Solution
scanf का %s पहली whitespace — यानी space, tab या नई पंक्ति — आने तक ही अक्षर पढ़ता है। इनपुट FliQi Education है, इसलिए str में सिर्फ़ FliQi जाता है और अंत में '\0' जुड़ता है। Education शब्द input buffer में बिना पढ़े रह जाता है। फिर printf FliQi और नई पंक्ति छापता है। space समेत पूरी पंक्ति पढ़नी हो तो scanf के %s की जगह fgets() लगाया जाता है।
scanf with %s reads characters only up to the first whitespace, like a space, tab or new line. The input is FliQi Education, so scanf stores only FliQi in str and adds '\0' at the end. The word Education stays unread in the input buffer. printf then prints FliQi and a new line. To read the whole line with spaces, you would use fgets() instead of scanf with %s.
प्रश्न 8उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

int a = 0;

scanf("%i", &a); // input is 010 

printf("%d ", a);

scanf("%i", &a); //input is 0xf 

printf("%d", a);

return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

int a = 0;

scanf("%i", &a); // input is 010 

printf("%d ", a);

scanf("%i", &a); //input is 0xf 

printf("%d", a);

return 0;

}
  1. A10 15
  2. B10 f
  3. C8 15
  4. D8 f

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

हल / Solution
scanf में %i संख्या को उसके आगे लगे prefix के आधार पर पढ़ता है। इनपुट 010 शून्य से शुरू होता है, इसलिए उसे octal माना जाता है — 1×8 + 0 = 8। इनपुट 0xf, 0x से शुरू होता है, इसलिए hexadecimal है — f = 15। printf का %d दोनों मानों को दशमलव में छापता है, इसलिए आउटपुट 8 15 है। scanf में %d होता तो 010 से 10 मिलता। printf का %d कभी अक्षर f नहीं छापता।
%i in scanf reads the number in the base shown by its prefix. Input 010 starts with 0, so it is read as octal: 1×8 + 0 = 8. Input 0xf starts with 0x, so it is read as hexadecimal: f = 15. printf with %d shows both values in decimal, so the output is 8 15. With %d in scanf, 010 would give 10. printf with %d never prints the letter f.
प्रश्न 9उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

                char name[] = "FliQi Education";

printf("%s\n", name);

                return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

                char name[] = "FliQi Education";

printf("%s\n", name);

                return 0;

}
  1. AF
  2. BFliQi Education
  3. CFliQi
  4. DEducation

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

हल / Solution
name ऐरे में string "FliQi Education" रखी है, और compiler उसके अंत में null अक्षर '\0' जोड़ देता है। %s दिए गए पते से अक्षर छापना शुरू करता है और '\0' मिलने तक छापता रहता है। printf बीच की space पर नहीं रुकता, इसलिए दोनों शब्द छपते हैं और फिर नई पंक्ति आती है। आउटपुट FliQi Education है। space पर रुकना सिर्फ़ scanf के %s में होता है। अकेला F छापने के लिए name[0] के साथ %c चाहिए।
The array name stores the string "FliQi Education", and the compiler adds a null character '\0' at the end. %s prints characters starting from the given address until it reaches '\0'. printf does not stop at the space, so both words are printed, followed by a new line. The output is FliQi Education. Only scanf with %s stops at a space. F alone would need %c with name[0].
प्रश्न 10उत्तर + हल
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

    int a = 100;

    printf("%o\n", a);

                return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

    int a = 100;

    printf("%o\n", a);

                return 0;

}
  1. A100
  2. B144
  3. C80
  4. DCompile Time Error

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

हल / Solution
%o पूर्णांक को octal, यानी आधार 8 में छापता है। 100 को बदलिए: 100 ÷ 8 = 12, शेष 4; फिर 12 ÷ 8 = 1, शेष 4; फिर 1 ÷ 8 = 0, शेष 1। शेषफल नीचे से ऊपर पढ़ने पर 144 बनता है। जाँच: 1×64 + 4×8 + 4 = 100। इसलिए आउटपुट 144 है। 100 तो %d से छपता, 80 का octal से कोई संबंध नहीं, और कोड में कोई compile error भी नहीं है।
%o prints an integer in octal, that is, base 8. To convert 100: 100 ÷ 8 = 12 remainder 4, then 12 ÷ 8 = 1 remainder 4, then 1 ÷ 8 = 0 remainder 1. Reading the remainders from bottom to top gives 144. Check: 1×64 + 4×8 + 4 = 100. So the output is 144. 100 would come from %d, 80 has no link with octal 100, and the code has no compile error.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 11उत्तर app में
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

    float a = 15.26;

    printf("%f ", a);

    printf("%e", a);

                    return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

    float a = 15.26;

    printf("%f ", a);

    printf("%e", a);

                    return 0;

}
  1. A15.26 15.26
  2. B15.260000 15.26
  3. C15.260000 1.526000e+01
  4. D15.26 1.526000e+01
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 12उत्तर app में
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

int a=-10;

                printf("%u ", -10);

                printf("%u", 10);

                return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

int a=-10;

                printf("%u ", -10);

                printf("%u", 10);

                return 0;

}
  1. A10 10
  2. B-10 10
  3. C4294967286 10
  4. DGarbage 10
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

                int x = 65;

                printf("%d %i", x, x);

                return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

                int x = 65;

                printf("%d %i", x, x);

                return 0;

}
  1. A65 A
  2. BA 65
  3. C65 65
  4. DA A
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
निम्नलिखित स्निपेट का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

                char ch = 'A';

                printf("%c\n", ch);

                return 0;

}
What will be the output of the following snippet?

#include <stdio.h>

int main()

{

                char ch = 'A';

                printf("%c\n", ch);

                return 0;

}
  1. AA
  2. B65
  3. C97
  4. Da
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
निम्नलिखित C कोड का आउटपुट क्या होगा?

            #include <stdio.h>

            int main()

        {

            char str[] ="Too Good";

                printf("\n %7s",str);

            return 0;

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

            #include <stdio.h>

            int main()

        {

            char str[] ="Too Good";

                printf("\n %7s",str);

            return 0;

        }
  1. AToo Good
  2. BToo G
  3. CToo Go
  4. DToo
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
निम्नलिखित C कोड का आउटपुट क्या होगा?

            #include <stdio.h>

            int main()

        {

            char str[] = "Hello Nancy";

            printf("\n %.7s", str) ;

            return 0;

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

            #include <stdio.h>

            int main()

        {

            char str[] = "Hello Nancy";

            printf("\n %.7s", str) ;

            return 0;

        }
  1. AHello Nan
  2. BHello
  3. CHello N
  4. DHello Nancy
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
C प्रोग्राम का आउटपुट क्या है?

int main()

{

    float a=654.123456f;

    printf("%3.3f,%3.2f",a,a);

    return 0;

}
What is the output of C program?

int main()

{

    float a=654.123456f;

    printf("%3.3f,%3.2f",a,a);

    return 0;

}
  1. A654,654
  2. B654.123456,654.123456
  3. C654.123,654.12
  4. D654.000,654.00
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 23उत्तर app में
C प्रोग्राम का आउटपुट क्या है?

    #include <stdio.h>

    int main()

    {

        int a=123;

        printf("*%06d*",a);

        return 0;

    }
What is the output of C program?

    #include <stdio.h>

    int main()

    {

        int a=123;

        printf("*%06d*",a);

        return 0;

    }
  1. A*123*
  2. B*6123*
  3. C*000123*
  4. D*006123*
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 24उत्तर app में
फ़ॉर्मेट स्पेसिफ़ायर के बारे में सही कथन चुनें।
Choose a correct statement about format specifiers.
  1. A%f फ़्लोट स्थिरांक को दशमलव के बाद 6 अंकों की शुद्धता से प्रिंट करता है%f prints float constants with 6 digits of precision
  2. B%lf डबल (double) स्थिरांक प्रिंट करता है%lf prints double constants
  3. C%Lf long double स्थिरांक प्रिंट करता है%Lf prints long double constants
  4. Dउपरोक्त सभीAll the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 25उत्तर app में
एक मान्य C प्रारूप विनिर्देशक (format specifier) चुनें:
Choose a valid C format specifier:
  1. A%d पूर्णांक स्थिरांक प्रिंट करता है%d prints integer constants
  2. B%u अहस्ताक्षरित (unsigned) पूर्णांक स्थिरांक प्रिंट करता है%u prints unsigned integer constants
  3. C%ld हस्ताक्षरित (signed) long और %lu अहस्ताक्षरित (unsigned) long स्थिरांक प्रिंट करता है%ld prints signed long and %lu prints unsigned long constants
  4. Dउपरोक्त सभीAll the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 26उत्तर app में
C लैंग्वेज में प्रारूप विनिर्देशक (format specifier) क्या है?
What is a format specifier in C language?
  1. Aप्रारूप विनिर्देशक संकलक को बताता है कि किसी वेरिएबल के मान को पहले से तय तरीक़े से बरता जाए।A format specifier tells compiler to treat a variable value in predefined way.
  2. Bअलग-अलग प्रकार के डेटा को प्रिंट करने के लिए अलग-अलग प्रारूप विनिर्देशक लगते हैं।Different format specifiers are used to print different type of data.
  3. Cफ़ॉर्मेट स्पेसिफ़ायर से फ़ाइलों में डेटा को तय प्रारूप में लिखा जाता है।Format specifiers are used to write data to files in a formatted way.
  4. Dउपरोक्त सभीAll the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 27उत्तर app में
प्रारूप पहचानकर्ता %u का प्रयोग किसके लिए किया जाता है?
The format identifier %u is used for?
  1. AInteger (पूर्णांक)Integer
  2. Bfloat
  3. CDecimal (दशमलव)Decimal
  4. Dunsigned decimal (अहस्ताक्षरित दशमलव)unsigned decimal
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 29उत्तर app में
किसी integer संख्या को यदि आप left align करना चाहते हैं तो उसके format specifier में क्या जोड़ना होगा?
If you want to left align an integer, what must be added to its format specifier?
  1. A-
  2. B+
  3. C*
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Format Specifiers of C Language के सभी 37 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

C Language के दूसरे topics

सभी topics