प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
Which C standard library function converts a string such as "3.75" into a double value?
सही उत्तर: ग) atof()
atof() (declared in stdlib.h) converts a string to double; atoi() converts to int, while itoa() and ftoa() are not standard C.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
To use the strlen() and strcpy() functions in a C program, which header file should be included?
सही उत्तर: ख) string.h
The string-handling functions such as strlen(), strcpy() and strcmp() are declared in string.h.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Which C standard library function reads formatted data from a character string (rather than from the keyboard)?
सही उत्तर: ख) sscanf()
sscanf() works like scanf() but takes its input from a string; sprintf() writes formatted output into a string.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int n = 5, i; for (i = 0; i < n; i++) n--; printf("%d %d", i, n); ?
सही उत्तर: घ) 3 2
Checks: 0 < 5 (n becomes 4), 1 < 4 (n = 3), 2 < 3 (n = 2), then 3 < 2 fails, so 3 2 is printed.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char s[] = "C programming"; int i, w = 1; for (i = 0; s[i]; i++) if (s[i] == ' ') w++; printf("%d", w); ?
सही उत्तर: ग) 2
There is one space, so w goes from 1 to 2: the program counts the words.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int a[] = {2, 7, 1, 8, 2}, i, m = 0; for (i = 1; i < 5; i++) if (a[i] > a[m]) m = i; printf("%d", m); ?
सही उत्तर: ख) 3
m holds the index of the largest element; the maximum 8 is at index 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int x = 1, y = 1; x += y += 2; printf("%d %d", x, y); ?
सही उत्तर: क) 4 3
Compound assignment is right-associative: y += 2 makes y = 3, then x += 3 makes x = 4.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char s[] = "abcdef"; printf("%s", s + strlen(s) / 2); ?
सही उत्तर: घ) def
strlen(s) / 2 = 3, so printing starts at s[3], giving "def".
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int i, j; for (i = 1; i <= 3; i++) { for (j = 3; j >= i; j--) printf("*"); printf("\n"); } What is printed on the second line?
सही उत्तर: ग) **
The inner loop runs 3 - i + 1 times: 3 stars, then 2, then 1, so line 2 is **.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
For positive integers a and b, the C expression (a + b - 1) / b computes:
सही उत्तर: ख) a / b rounded up (the ceiling)
Adding b - 1 before integer division rounds the quotient up; e.g. (7 + 2 - 1) / 2 = 4 = ceiling of 3.5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।