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

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

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

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

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

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

#include <stdio.h>

    void main()

    {

        int a=10;

        int *p = a;

        int *r = &p;

        printf("%d", (**r));

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

#include <stdio.h>

    void main()

    {

        int a=10;

        int *p = a;

        int *r = &p;

        printf("%d", (**r));

    }
  1. A1
  2. BCompile time error
  3. Ca का पताAddress of a
  4. Dकचरा मानJunk value

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

हल / Solution
यहाँ r का प्रकार int * है, यानी एक ही स्तर का pointer। *r एक int देता है। printf में **r लिखा है, यानी उस int को फिर dereference करना, जो संभव नहीं। इसलिए compiler त्रुटि देता है — indirection requires pointer operand। साथ ही int *p = a; में int मान सीधे pointer में रखा गया है, जिसे आज का compiler भी रोकता है। program बनता ही नहीं, इसलिए कुछ नहीं छपता।
Here r has type int *, so it is a single-level pointer. *r gives an int, and the printf uses **r, which tries to dereference that int again. That is not allowed, so the compiler stops with an error like indirection requires pointer operand. Also, int *p = a; puts a plain int into a pointer, which modern compilers also reject. The program never builds, so nothing like 1, an address or junk is printed.
प्रश्न 2उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?

#include <stdio.h>

    void main()

    {

        int k = 5;

        int *p = &k;

        int **m  = &p;

        **m = 6;

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

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

#include <stdio.h>

    void main()

    {

        int k = 5;

        int *p = &k;

        int **m  = &p;

        **m = 6;

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

    }
  1. A5
  2. BCompile time error
  3. C6
  4. Dकचरा मान (Junk)Junk

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

हल / Solution
यहाँ p में k का पता है और m में p का पता है, यानी m एक pointer टू pointer है। *m से p मिलता है, और **m से वह मिलता है जिसे p point करता है, यानी k। इसलिए **m = 6; सीधे k में 6 रख देता है। फिर k छापने पर 6 आता है। 5 पुराना मान था। प्रकार सही मेल खाते हैं, इसलिए compile error नहीं। k initialize है, इसलिए कचरा भी नहीं।
Here p holds the address of k and m holds the address of p, so m is a pointer to a pointer. *m gives p, and **m gives what p points to, which is k. So **m = 6; stores 6 directly into k, and printing k gives 6. The value 5 is the old value that has now been changed. All the types match, so there is no compile error. Since k is initialized, no junk value appears.
प्रश्न 3उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?

#include <stdio.h>

    void main()

    {

        int k = 5;

        int *p = &k;

        int **m  = &p;

        printf("%d%d%d\n", k, *p, **p);

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

#include <stdio.h>

    void main()

    {

        int k = 5;

        int *p = &k;

        int **m  = &p;

        printf("%d%d%d\n", k, *p, **p);

    }
  1. A5 5 5
  2. B5 5 कचरा मान5 5 junk value
  3. C5 कचरा कचरा5 junk junk
  4. DCompile time error

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

हल / Solution
यहाँ p का प्रकार int * है, यानी इसमें सिर्फ़ एक स्तर का पता है। *p से k का मान 5 मिलता है, जो एक int है। printf में **p लिखा है, यानी उस int को फिर से dereference करना। int कोई pointer नहीं है, इसलिए compiler त्रुटि देता है — indirection requires pointer operand। शायद लिखने वाला **m लिखना चाहता था, जिससे 5 5 5 छपता। पर जैसा लिखा है, program बनता ही नहीं, इसलिए कोई मान नहीं छपता।
Here p has type int *, so it has only one level of address. *p gives the value of k, which is 5, an int. The printf uses **p, which tries to dereference that int again. An int is not a pointer, so the compiler stops with an error like indirection requires pointer operand. Perhaps **m was intended, which would print 5 5 5. But as written, the program never builds, so no values are printed.
प्रश्न 4उत्तर + हल
निम्नलिखित में से कौन सा लॉजिकल ऑपरेशन पॉइंटर्स पर लागू किया जा सकता है?

(प्रारंभिक मान मानते हुए int *a = 2; int *b = 3;)
Which of following logical operation can be applied to pointers?

(Assuming initialization int *a = 2; int *b = 3;)
  1. Aa | b
  2. Ba ^ b
  3. Ca & b
  4. Dइनमें से कोई नहींNone of the mentioned

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

हल / Solution
|, ^ और & bitwise operators हैं। C में इनके दोनों operands पूर्णांक प्रकार के होने चाहिए। a और b pointers हैं, इसलिए a | b, a ^ b या a & b लिखते ही compiler त्रुटि देता है — invalid operands to binary expression। pointers पर सिर्फ़ कुछ ही काम चलते हैं: पूर्णांक जोड़ना-घटाना, दो pointers घटाना और उनकी तुलना करना। इसलिए दिए गए तीनों में से कोई भी लागू नहीं होता, और उत्तर 'इनमें से कोई नहीं' है।
The symbols |, ^ and & are bitwise operators, and in C both their operands must be integers. Here a and b are pointers, so a | b, a ^ b or a & b gives a compile error like invalid operands to binary expression. Only a few operations work on pointers: adding or subtracting an integer, subtracting two pointers and comparing them. So none of the three applies, and the answer is None of the mentioned.
प्रश्न 5उत्तर + हल
32-बिट मशीन में *ptr का आकार क्या है (इनिशियलाइज़ेशन को int *ptr = 10; मानकर)?
What is the size of *ptr in a 32-bit machine (Assuming initialization as int *ptr = 10;)?
  1. A1
  2. B2
  3. C4
  4. D8

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

हल / Solution
यहाँ ptr एक int pointer है, इसलिए *ptr का प्रकार int है। sizeof(*ptr) असल में sizeof(int) के बराबर होता है। 32-बिट मशीन पर int का आकार 4 byte होता है, इसलिए उत्तर 4 है। ध्यान दीजिए, sizeof सिर्फ़ प्रकार देखता है, ptr में रखे पते 10 पर जाकर कुछ पढ़ता नहीं। 1 byte char का आकार है। 2 byte पुराने 16-बिट compilers का int है। 8 byte double का आकार है।
Here ptr is an int pointer, so *ptr has the type int. That means sizeof(*ptr) is the same as sizeof(int). On a 32-bit machine an int takes 4 bytes, so the answer is 4. Note that sizeof only looks at the type and never reads anything at address 10. One byte is the size of a char, 2 bytes is an int on old 16-bit compilers, and 8 bytes is the size of a double.
प्रश्न 6उत्तर + हल
निम्नलिखित में से कौन-सा अंकगणितीय operation pointers a और b पर लागू किया जा सकता है?

(मान लीजिए int *a = (int *)2; int *b = (int *)3;)
Which of the following arithmetic operation can be applied to pointers a and b?

(Assuming initialization as int *a = (int *)2; int *b = (int *)3;)
  1. Aa + b
  2. Ba – b
  3. Ca * b
  4. Da / b

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

हल / Solution
दो pointers के बीच C सिर्फ़ घटाने की अनुमति देता है। a – b बताता है कि दोनों पतों के बीच कितने तत्व हैं, इसलिए इसका अर्थ बनता है। दो पतों को जोड़ने, गुणा करने या भाग देने से कोई उपयोगी पता नहीं बनता। इसलिए a + b, a * b और a / b पर compiler त्रुटि देता है। ध्यान रहे, घटाने का परिणाम तभी भरोसेमंद है जब दोनों pointers एक ही array में हों।
Between two pointers, C allows only subtraction. The result of a – b tells how many elements lie between the two addresses, so it has a meaning. Adding, multiplying or dividing two addresses gives no useful address, so a + b, a * b and a / b all cause a compile error. Keep in mind that the subtraction result is only reliable when both pointers point into the same array.
प्रश्न 7उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?

#include <stdio.h>

    int main()

    {

        int *p = (int *)2;

        int *q = (int *)3;

        printf("%d", p + q);

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

#include <stdio.h>

    int main()

    {

        int *p = (int *)2;

        int *q = (int *)3;

        printf("%d", p + q);

    }
  1. A2
  2. B3
  3. C5
  4. DCompile time error

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

हल / Solution
C में दो pointers को आपस में जोड़ने की अनुमति नहीं है। दो पतों का जोड़ किसी काम की जगह नहीं बताता, इसलिए p + q लिखते ही compiler त्रुटि देता है — invalid operands to binary +। pointer में कोई पूर्णांक जोड़ा जा सकता है, जैसे p + 1, और दो pointers को घटाया जा सकता है। पर pointer + pointer मना है। program बनता ही नहीं, इसलिए 2, 3 या 5 कुछ भी नहीं छपता।
C does not allow adding two pointers together. The sum of two addresses does not point to any meaningful place, so p + q makes the compiler stop with an error like invalid operands to binary +. You can add an integer to a pointer, as in p + 1, and you can subtract one pointer from another, but pointer plus pointer is not allowed. Since the program never builds, nothing like 2, 3 or 5 is printed.
प्रश्न 8उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?

    #include <stdio.h>

    void main()

    {

        int x = 0;

        int *ptr = &x;

        printf("%d\n", *ptr);

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

    #include <stdio.h>

    void main()

    {

        int x = 0;

        int *ptr = &x;

        printf("%d\n", *ptr);

    }
  1. Ax का पताAddress of x
  2. Bकचरा मान (Junk value)Junk value
  3. C0
  4. DRun time error

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

हल / Solution
यहाँ x = 0 है और ptr = &x, यानी ptr में x का पता है। printf में *ptr छापा जा रहा है। * उस पते पर जाकर वहाँ रखा मान देता है, जो x का मान 0 है। इसलिए आउटपुट 0 आता है। x का पता तब छपता जब ptr को %p से छापते। x पहले से initialize है, इसलिए कचरा मान नहीं आता। ptr एक वैध variable को point करता है, इसलिए run time error भी नहीं होता।
Here x is 0 and ptr = &x, so ptr holds the address of x. The printf prints *ptr. The * goes to that address and gives the value stored there, which is 0. So the output is 0. The address would print only if ptr itself were printed with %p. Since x is initialized, there is no junk value. Since ptr points to a valid variable, there is no run time error.
प्रश्न 9उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?

    #include <stdio.h>

    void main()

    {

        int x = 0;

        int *ptr = &5;

        printf("%p\n", ptr);

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

    #include <stdio.h>

    void main()

    {

        int x = 0;

        int *ptr = &5;

        printf("%p\n", ptr);

    }
  1. A5
  2. B5 का पताAddress of 5
  3. Cकुछ नहींNothing
  4. DCompile time error

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

हल / Solution
& operator सिर्फ़ उन्हीं चीज़ों पर लगता है जिनकी memory में जगह हो, जैसे variable। इन्हें lvalue कहते हैं। 5 एक constant है, इसकी अपनी कोई पता वाली जगह नहीं होती। इसलिए &5 लिखते ही compiler त्रुटि देता है — cannot take the address of an rvalue। program बनता ही नहीं, तो कुछ छपने का सवाल ही नहीं। इसलिए '5', '5 का पता' और 'कुछ नहीं' तीनों ग़लत हैं।
The & operator works only on things that have a place in memory, such as variables. These are called lvalues. The value 5 is a constant with no address of its own. So writing &5 makes the compiler stop with an error like cannot take the address of an rvalue. The program is never built, so nothing is printed at all. That is why 5, Address of 5 and Nothing are all wrong.
प्रश्न 10उत्तर + हल
C प्रोग्राम में पॉइंटर्स का उपयोग करने का कारण है
The reason for using pointers in a C program is
  1. Aपॉइंटर्स अलग-अलग functions को अपने local variables साझा करने और बदलने देते हैंPointers allow different functions to share and modify their local variables
  2. Bबड़े structure को पास करना, ताकि structure की पूरी नकल से बचा जा सकेTo pass large structures so that complete copy of the structure can be avoided
  3. Cपॉइंटर्स linked list और binary tree जैसी जटिल linked data structures बनाना संभव करते हैंPointers enable complex linked data structures like linked lists and binary trees
  4. Dउपरोक्त सभीAll of the above

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

हल / Solution
तीनों कारण सही हैं। पहला, किसी variable का पता दूसरे function को देने पर वह function उसी variable को बदल सकता है, जैसे swap(&a, &b) में। दूसरा, बड़ा structure पास करते समय पूरी नकल बनाने की जगह सिर्फ़ उसका पता भेजा जाता है। इससे समय और memory दोनों बचते हैं। तीसरा, linked list और tree में हर node अगले node का पता रखता है, जो pointer से ही संभव है। इसलिए उत्तर 'उपरोक्त सभी' है।
All three reasons are correct. First, passing the address of a variable lets another function change that same variable, as in swap(&a, &b). Second, when a large structure is passed, only its address is sent instead of making a full copy, which saves time and memory. Third, in linked lists and trees each node stores the address of the next node, which is only possible with pointers. So the answer is All of the above.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 11उत्तर app में
वेरिएबल का एड्रेस प्राप्त करने के लिए हम वेरिएबल के नाम से पहले _________ चिह्न लिखते हैं।
In order to fetch the address of the variable we write preceding _________ sign before variable name
  1. Aप्रतिशत (%)Percent(%)
  2. Bअल्पविराम (,)Comma(,)
  3. Cएम्परसेंड (&)Ampersand(&)
  4. Dतारांकन (*)Asterisk(*)
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 12उत्तर app में
वाइल्ड पॉइंटर क्या है?
What is wild pointer?
  1. Aऐसा pointer जो स्वभाव से wild हैPointer which is wild in nature
  2. Bऐसा pointer जिसका कोई मान नहीं हैPointer which has no value
  3. Cऐसा pointer जो initialize नहीं किया गया हैPointer which is not initialized
  4. Dकोई नहींNone
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में
निम्नलिखित में से कौन-सा कथन नीचे दिए गए कथन में प्रयुक्त k के बारे में सही है?

char ****k;
Which of the following statements is correct about k used in the below statement?

char ****k;
  1. Ak एक pointer टू pointer टू pointer टू char हैk is a pointer to a pointer to a pointer to a char
  2. Bk एक pointer टू pointer टू pointer टू pointer टू char हैk is a pointer to a pointer to a pointer to a pointer to a char
  3. Ck एक char pointer का pointer हैk is a pointer to a char pointer
  4. Dk एक pointer टू pointer टू char हैk is a pointer to a pointer to a char
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
एक pointer है
A pointer is
  1. Aएक keyword जो variables बनाने के लिए प्रयोग होता हैA keyword used to create variables
  2. Bएक variable जो किसी instruction का address रखता हैA variable that stores address of an instruction
  3. Cएक variable जो किसी दूसरे variable का address रखता हैA variable that stores address of another variable
  4. Dउपरोक्त सभीAll of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 19उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट ज्ञात कीजिए।
void main()
{
int array[10];
int *i = &array[2], *j = &array[5];
int diff = j-i;
printf("%d", diff);
}
Find the output of the following program.
void main()
{
int array[10];
int *i = &array[2], *j = &array[5];
int diff = j-i;
printf("%d", diff);
}
  1. A3
  2. B6
  3. Cकचरा मान (Garbage value)Garbage value
  4. Dत्रुटिError
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
निम्नलिखित में से कौन सा float पॉइंटर घोषित करने का सही तरीका है?
Which of the following is the correct way of declaring a float pointer?
  1. Afloat ptr;
  2. Bfloat *ptr;
  3. C*float ptr;
  4. Dउपरोक्त में से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 21उत्तर app में
निम्नलिखित प्रोग्राम कोड का आउटपुट क्या होगा?
#include <stdio.h>
void main()
{
int i=3, *j, **k;
j = &i;
k = &j;
printf("%d%d%d", *j, **k, *(*k));
}
What will be the output of the following program code?
#include <stdio.h>
void main()
{
int i=3, *j, **k;
j = &i;
k = &j;
printf("%d%d%d", *j, **k, *(*k));
}
  1. A444
  2. B000
  3. C333
  4. D433
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 22उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?
#include <stdio.h>
void main()
{
int i = 10;
void *p = &i;
printf("%d\n", *(int*)p);
}
What will be the output of the following program?
#include <stdio.h>
void main()
{
int i = 10;
void *p = &i;
printf("%d\n", *(int*)p);
}
  1. ACompile time त्रुटिCompile time error
  2. BSegmentation fault या रन टाइम crashSegmentation fault/runtime crash
  3. C10
  4. Dअपरिभाषित व्यवहार (undefined behavior)Undefined behavior
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 23उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?
void main()
{
int i = 10;
void *p = &i;
printf("%d\n", (int)*p);
}
What will be the output of the following program?
void main()
{
int i = 10;
void *p = &i;
printf("%d\n", (int)*p);
}
  1. ACompile time त्रुटिCompile time error
  2. BSegmentation fault या रन टाइम crashSegmentation fault/runtime crash
  3. C10
  4. Dअपरिभाषित व्यवहार (undefined behavior)Undefined behavior
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 24उत्तर app में
कथन int **a;
The statement int **a;
  1. Aअमान्य हैis illegal
  2. Bमान्य है पर अर्थहीन हैis legal but meaningless
  3. Cवाक्य-रचना (syntax) और अर्थ (semantics) दोनों से सही हैis syntactically and semantically correct
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 25उत्तर app में
आउटपुट निर्धारित कीजिए।
#include <stdio.h>
void main()
{
char *p = NULL;
char *q = 0;
if(p)
printf(" p ");
else
printf("nullp");
if(q)
printf("q");
else
printf(" nullq");
}
Determine the output.
#include <stdio.h>
void main()
{
char *p = NULL;
char *q = 0;
if(p)
printf(" p ");
else
printf("nullp");
if(q)
printf("q");
else
printf(" nullq");
}
  1. Ap q
  2. Bcompiler पर निर्भरDepends on the compiler
  3. Cx nullq, जहाँ NULL के मान के अनुसार x, p या nullp हो सकता हैx nullq where x can be p or nullp depending on the value of NULL
  4. Dnullp nullq
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 26उत्तर app में
निम्नलिखित पॉइंटर घोषणा पर टिप्पणी कीजिए।
int *ptr, p;
Comment on the following pointer declaration.
int *ptr, p;
  1. Aptr इंटीजर का पॉइंटर है, p नहीं हैptr is a pointer to integer, p is not
  2. Bptr और p, दोनों इंटीजर के पॉइंटर हैंptr and p, both are pointers to integer
  3. Cptr इंटीजर का पॉइंटर है, p हो भी सकता है और नहीं भीptr is pointer to integer, p may or may not be
  4. Dptr और p, दोनों इंटीजर के पॉइंटर नहीं हैंptr and p both are not pointers to integer
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 27उत्तर app में
निम्नलिखित कथन का क्या अर्थ है?

int (*ptr) [5];
What does the following statement mean?

int (*ptr) [5];
  1. Aptr, 5 integers का एक array हैptr is an array of 5 integers
  2. Bptr, 5 integers के एक array का pointer हैptr is a pointer to an array of 5 integers
  3. Cptr, 5 integers के pointers का एक array हैptr is array of pointers to 5 integers
  4. Dptr, एक array का pointer हैptr is an pointer to array
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 28उत्तर app में
इस C कोड का आउटपुट क्या है?
int main()
{
int ary[4] = {1, 2, 3, 4};
int *p[4];
int i;
for ( i = 0; i < 4; i++) {
p[i] = &ary[i];
}
printf("%d\n", *p[0]);
return 0;
}
What is the output of this C code?
int main()
{
int ary[4] = {1, 2, 3, 4};
int *p[4];
int i;
for ( i = 0; i < 4; i++) {
p[i] = &ary[i];
}
printf("%d\n", *p[0]);
return 0;
}
  1. A1
  2. B3
  3. C2
  4. Dत्रुटिError
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Pointer in C Language के सभी 55 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

C Language के दूसरे topics

सभी topics