Primary Data Types in C: int, char, float, double and Sizes Notes in Hindi & English : प्राथमिक डेटा प्रकार: int, char, float, double की मेमोरी और रेंज और 20 महत्वपूर्ण MCQ प्रश्न (Rajasthan IT Exam)

Post a Comment

PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Primary Data Types in C: int, char, float, double and Sizes (प्राथमिक डेटा प्रकार: int, char, float, double की मेमोरी और रेंज) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।

Overview: C defines four fundamental (primary) arithmetic data types—char, int, float, and double—plus the empty incomplete type void, whose exact memory sizes depend on the compiler and target architecture. On typical 32/64-bit systems, char is 1 byte, int is 4 bytes, float is 4 bytes (IEEE-754 single precision), and double is 8 bytes (IEEE-754 double precision).

अध्याय सार: C भाषा में चार प्राथमिक (Primary) डेटा प्रकार—char, int, float और double—तथा एक रिक्त प्रकार void होते हैं, जिनका वास्तविक मेमोरी आकार कंपाइलर और सिस्टम आर्किटेक्चर पर निर्भर करता है। आधुनिक 32/64-बिट सिस्टम पर सामान्यतः char 1 बाइट, int 4 बाइट, float 4 बाइट (IEEE-754 सिंगल प्रिसिजन) तथा double 8 बाइट (डबल प्रिसिजन) मेमोरी लेते हैं।

Primary Data Types in C: int, char, float, double and Sizes: Detailed Notes & Architecture (प्राथमिक डेटा प्रकार: int, char, float, double की मेमोरी और रेंज)

1. char & int: Minimum Guarantees, Ranges & Two's Complement (char और int: न्यूनतम सीमाएं, रेंज और Two's Complement)

[EN] By ISO C definition, sizeof(char) is always exactly 1 byte (at least CHAR_BIT = 8 bits per <limits.h>), storing integer ASCII/UTF-8 byte codes from -128..127 (signed) or 0..255 (unsigned); note that plain char's default signedness is implementation-defined (signed on x86, unsigned on many ARM ABIs). For int, ISO C guarantees at least 16 bits (-32,767 to +32,767, seen on 16-bit Turbo C as 2 bytes), while modern 32-bit/64-bit platforms allocate 4 bytes (32 bits), giving Two's Complement range -2,147,483,648 to +2,147,483,647 (-2^31 to 2^31 - 1).

[HI] ISO C मानक में sizeof(char) सदैव 1 बाइट (कम से कम 8 बिट) होता है, जो 'A' (65) जैसे अक्षर का संख्यात्मक कोड रखता है। C में int कम से कम 16 बिट का होना अनिवार्य है (16-बिट Turbo C में 2 बाइट: -32,768 से +32,767), जबकि आधुनिक 32/64-बिट कंपाइलर int को 4 बाइट (32 बिट) देते हैं जिसकी रेंज -2,147,483,648 से +2,147,483,647 होती है।

2. float & double: IEEE-754 Binary Layout & Precision (float और double: IEEE-754 संरचना और दशमलव सटीकता)

[EN] Real numbers in C follow IEEE-754 floating-point encoding. A 4-byte (32-bit) float splits into 1 sign bit, 8 exponent bits (bias 127), and 23 explicit mantissa bits, providing roughly 6 to 7 significant decimal digits (FLT_DIG = 6 in <float.h>) across ~1.17e-38 to 3.40e+38. An 8-byte (64-bit) double allocates 1 sign bit, 11 exponent bits (bias 1023), and 52 mantissa bits, achieving 15 to 17 significant decimal digits (DBL_DIG = 15) up to ~1.79e+308. Unmarked decimal literals like 3.14 default to double unless suffixed with f.

[HI] दशमलव संख्याओं के लिए C में IEEE-754 मानक उपयोग होता है। 4-बाइट (32-बिट) float में 1 साइन, 8 एक्सपोनेंट व 23 मैंटिसा बिट्स होते हैं, जो लगभग 6-7 अंकों की सटीकता देता है। 8-बाइट (64-बिट) double में 1 साइन, 11 एक्सपोनेंट और 52 मैंटिसा बिट्स होने से 15-17 दशमलव अंकों तक सटीक मान मिलता है; बिना सफिक्स वाले 3.14 जैसे लिटरल डिफ़ॉल्ट रूप से double होते हैं।

3. The void Type & C Standard Size Ordering (void प्रकार और C मानक का आकार क्रम (sizeof))

[EN] Although grouped among primary types, void represents an incomplete 'empty' type with three essential roles: (1) indicating a function returns no value (void print_line(void)), (2) declaring zero parameters (int main(void) — unlike int f() in C89-C17 which meant unspecified parameters!), and (3) generic untyped pointers (void *) holding any object address. ISO C never hardcodes byte sizes for int/double, enforcing only: 1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long) and sizeof(float) <= sizeof(double) <= sizeof(long double).

[HI] void एक अपूर्ण (Incomplete) प्रकार है जिसके तीन उपयोग हैं: कुछ न लौटाने वाले फंक्शन (void display(void)), शून्य पैरामीटर दर्शाना, तथा जेनेरिक पॉइंटर (void *) बनाना जो किसी भी डेटा का पता रख सके। मानक के अनुसार sizeof(void) अवैध है (GCC एक्सटेंशन में 1), तथा 1 == sizeof(char) <= sizeof(int) व sizeof(float) <= sizeof(double) सदैव सत्य रहता है।

4. Format Specifiers, Implicit Truncation & <stdint.h> (फॉर्मेट स्पेसिफायर्स, प्रिसिजन लॉस और <stdint.h>)

[EN] Passing mismatched printf/scanf specifiers triggers Undefined Behavior: use %c for char, %d or %i for int, %f for float, %lf in scanf for double (in printf, variadic float arguments promote to double so %f and %lf both work), and %zu for sizeof's size_t return type. Assigning a double to an int silently truncates toward zero (int x = 3.9; becomes 3), while assigning double to float drops precision beyond ~7 digits. When fixed exact bit widths are vital (network protocols, hardware registers), C99 <stdint.h> provides int8_t, int32_t, and uint64_t.

[HI] printf/scanf में गलत स्पेसिफायर (%c, %d, %f, scanf में %lf, sizeof हेतु %zu) अपरिभाषित व्यवहार उत्पन्न करता है। ध्यान रहे कि int x = 3.9; करने पर दशमलव भाग बिना राउंडिंग के कटकर 3 हो जाता है। सटीक बिट चौड़ाई (जैसे नेटवर्किंग या एम्बेडेड कोड) के लिए C99 का <stdint.h> हेडर int8_t, int32_t, uint64_t प्रदान करता है।

Syntax, Formula & Technical Example (Primary Data Types in C: int, char, float, double and Sizes)

#include <stdio.h>
#include <limits.h>
#include <float.h>

int main(void) {
    char c = 'A';            int i = INT_MAX;
    float f = 3.14159265f;   double d = 3.141592653589793;
    printf("char=%zuB('%c'=%d) int=%zuB(max=%d)\n", sizeof(c), c, c, sizeof(i), i);
    printf("float=%zuB(%.7f) double=%zuB(%.15lf)\n", sizeof(f), f, sizeof(d), d);
    return 0;
}

Primary Data Types in C: int, char, float, double and Sizes Quick Reference & Comparison Table

Primary Data TypeTypical Size (32/64-bit)Precision / Range & Specifier
char1 Byte (8 bits; sizeof == 1 always)-128..127 (signed) or 0..255 (unsigned); %c
int4 Bytes (2B on 16-bit Turbo C)-2,147,483,648 to +2,147,483,647; %d / %i
float4 Bytes (IEEE-754 Single Precision)1+8+23 bits; ~6-7 decimal digits precision; %f
double8 Bytes (IEEE-754 Double Precision)1+11+52 bits; ~15-17 decimal digits; %lf (scanf)

Primary Data Types in C: int, char, float, double and Sizes Top 20 Bilingual MCQs with Answers

Q1. Which C expression is guaranteed by the ISO C standard to ALWAYS evaluate to 1 on every compliant hardware architecture?

(ISO C मानक के अनुसार किस व्यंजक (Expression) का मान हर कंपाइलर व हार्डवेयर पर सदैव 1 होना सुनिश्चित है?)

(A) sizeof(char)

(B) sizeof(int)

(C) sizeof(float)

(D) sizeof(void *)

Correct Answer: (A)

[EN] ISO C defines one byte as the storage size of a char, making sizeof(char) equal to 1 by definition even on exotic DSPs.

[HI] ISO C परिभाषा के अनुसार 1 बाइट का अर्थ char का आकार है, इसलिए sizeof(char) हर आर्किटेक्चर पर सदैव 1 होता है।

Q2. What is the minimum bit width and range that ISO C guarantees for an 'int' (as seen in 16-bit compilers like Turbo C)?

(ISO C मानक किसी 'int' के लिए न्यूनतम कितनी बिट चौड़ाई व रेंज सुनिश्चित करता है (जैसे 16-बिट Turbo C में)?)

(A) At least 4 bits

(B) Strictly 64 bits on all machines

(C) At least 16 bits (2 bytes: -32,768 to +32,767 in Two's Complement)

(D) Exactly 8 bits (1 byte)

Correct Answer: (C)

[EN] While modern desktops use 32-bit (4-byte) int, standard C permits 16-bit int on small/embedded targets.

[HI] आधुनिक सिस्टम में int 4 बाइट का होता है, परंतु C मानक न्यूनतम 16 बिट (2 बाइट: -32,768 से +32,767) की गारंटी देता है।

Q3. In IEEE-754 32-bit single-precision 'float', how are the 32 bits partitioned?

(IEEE-754 के 32-बिट सिंगल-प्रिसिजन 'float' में 32 बिट्स किस प्रकार विभाजित होते हैं?)

(A) 8 Sign bits, 8 Exponent bits, 16 Mantissa bits

(B) 1 Sign bit, 8 Exponent bits, 23 Mantissa bits

(C) 1 Sign bit, 15 Exponent bits, 16 Mantissa bits

(D) 1 Sign bit, 11 Exponent bits, 20 Mantissa bits

Correct Answer: (B)

[EN] Single precision uses bias-127 8-bit exponent and 23 explicit significand bits (yielding ~7 decimal digits of precision).

[HI] 32-बिट float में 1 साइन बिट, 8 एक्सपोनेंट बिट (bias 127) और 23 मैंटिसा बिट्स होते हैं।

Q4. Approximately how many significant decimal digits of precision does a 64-bit IEEE-754 'double' reliably maintain?

(64-बिट IEEE-754 'double' लगभग कितने सार्थक दशमलव अंकों तक सटीक (Precision) मान बनाए रखता है?)

(A) 30 to 35 decimal digits

(B) 15 to 17 decimal digits

(C) 6 to 7 decimal digits

(D) 3 to 4 decimal digits

Correct Answer: (B)

[EN] With 52 explicit mantissa bits (+1 implicit leading bit = 53 bits), log10(2^53) ~ 15.95 decimal digits.

[HI] 52 मैंटिसा बिट्स (+1 इम्प्लिसिट) होने से double 15 से 17 दशमलव अंकों तक की सटीकता प्रदान करता है।

Q5. What is the default data type of an unsuffixed floating-point literal such as '3.14159' in C?

(C में बिना किसी सफिक्स के लिखे गए दशमलव लिटरल '3.14159' का डिफ़ॉल्ट डेटा टाइप क्या होता है?)

(A) float

(B) decimal

(C) long double

(D) double

Correct Answer: (D)

[EN] Unsuffixed floating constants are typed as double; appending 'f' (3.14f) makes a float and 'L' (3.14L) makes a long double.

[HI] बिना सफिक्स के रियल लिटरल डिफ़ॉल्ट रूप से double होते हैं; float बनाने के लिए अंत में f लगाना पड़ता है।

Q6. Which header file provides compile-time maximum and minimum limit macros such as INT_MAX, INT_MIN, and CHAR_BIT?

(INT_MAX, INT_MIN और CHAR_BIT जैसे पूर्णांक सीमा मैक्रोज़ किस हेडर फाइल में परिभाषित होते हैं?)

(A) <ctype.h>

(B) <float.h>

(C) <limits.h>

(D) <math.h>

Correct Answer: (C)

[EN] <limits.h> defines integer type limits and bit counts, whereas <float.h> defines FLT_DIG, DBL_MAX, and floating-point limits.

[HI] पूर्णांक प्रकारों की सीमाएं <limits.h> में तथा दशमलव प्रकारों की सीमाएं <float.h> में परिभाषित होती हैं।

Q7. Why does 'scanf("%f", &d);' fail with corrupted data when d is declared as 'double d;'?

(यदि 'double d;' घोषित हो, तो 'scanf("%f", &d);' लिखने पर गलत मान क्यों आता है?)

(A) %f tells scanf to write a 4-byte float into an 8-byte double pointer; double requires %lf in scanf

(B) scanf cannot read floating-point numbers at all

(C) %f is reserved exclusively for integers in scanf

(D) double uses ASCII strings instead of binary

Correct Answer: (A)

[EN] Unlike printf (where float automatically promotes to double), scanf receives raw addresses and must know exact target byte width via %lf.

[HI] printf में float स्वतः double बन जाता है, पर scanf एड्रेस लेता है इसलिए double में 8 बाइट लिखने हेतु %lf अनिवार्य है।

Q8. Which format specifier is the ISO C99 standard choice to print the return value of sizeof(int) portably?

(sizeof(int) के रिटर्न मान (size_t) को पोर्टेबल रूप से प्रिंट करने के लिए मानक C99 फॉर्मेट स्पेसिफायर कौन सा है?)

(A) %f

(B) %d

(C) %c

(D) %zu

Correct Answer: (D)

[EN] sizeof yields an unsigned integer type size_t, whose dedicated printf specifier is %zu.

[HI] sizeof ऑपरेटर size_t प्रकार का मान लौटाता है, जिसे प्रिंट करने का सटीक मानक स्पेसिफायर %zu है।

Q9. What value does 'int k = 9.99;' store in k, and what prints for 'char ch = 65; printf("%c", ch);'?

('int k = 9.99;' में k का मान क्या होगा तथा 'char ch = 65; printf("%c", ch);' क्या प्रिंट करेगा?)

(A) k = 9.99 and ch causes a compile error

(B) k = 9 (fractional part truncated toward zero) and ch prints 'A'

(C) k = 10 (rounded up) and ch prints '65'

(D) k = 0 and ch prints 'a'

Correct Answer: (B)

[EN] Floating-to-integer conversion discards the fractional digits without rounding, and ASCII 65 maps to uppercase 'A'.

[HI] float/double को int में डालने पर दशमलव भाग कटकर k = 9 बनता है और ASCII 65 पर 'A' प्रिंट होता है।

Q10. Which statement accurately describes the 'void' data type in standard C?

(मानक C में 'void' डेटा टाइप के बारे में कौन सा कथन बिल्कुल सही है?)

(A) void is an incomplete type that cannot declare variables directly, used for no-return functions, empty param lists, and void* pointers

(B) sizeof(void) is guaranteed to return 0 in ISO C

(C) void v = 0; is the standard way to create a typeless variable

(D) void occupies 4 bytes just like int

Correct Answer: (A)

[EN] You cannot allocate an object of type void, nor apply sizeof(void) in strict ISO C, yet void* can hold any object address.

[HI] void एक अपूर्ण टाइप है जिसका वेरिएबल नहीं बनाया जा सकता, पर यह void* जेनेरिक पॉइंटर और बिना रिटर्न वाले फंक्शन के लिए प्रयोग होता है।

Q11. What happens when assigning 'float f = 123456789.0;' on a typical IEEE-754 system?

(सामान्य IEEE-754 सिस्टम पर 'float f = 123456789.0;' लिखने पर क्या प्रभाव पड़ता है?)

(A) Compiler syntax error: float overflow

(B) f automatically expands to 8 bytes at runtime

(C) f stores exact 123456789.0 with zero rounding

(D) Precision loss occurs beyond ~7 significant digits (value rounds to ~123456792.0)

Correct Answer: (D)

[EN] A 23-bit mantissa (~16.7 million) cannot represent all 9 decimal digits exactly, so trailing precision is rounded.

[HI] float केवल ~7 सार्थक अंकों तक सटीक रहता है, इसलिए 9 अंकों की संख्या में प्रिसिजन लॉस (राउंडिंग) हो जाता है।

Q12. Which C99 header guarantees exact fixed-width integers like int32_t and uint8_t across all platforms?

(सभी प्लेटफॉर्म पर बिल्कुल सटीक बिट आकार (जैसे int32_t, uint8_t) पाने के लिए कौन सा C99 हेडर उपयोग होता है?)

(A) <stdint.h>

(B) <stdlib.h>

(C) <stdio.h>

(D) <stdarg.h>

Correct Answer: (A)

[EN] <stdint.h> eliminates ambiguity around whether int is 16-bit or 32-bit by defining exact-width typedefs.

[HI] <stdint.h> में int8_t, int16_t, int32_t, uint64_t जैसे निश्चित चौड़ाई वाले टाइप परिभाषित होते हैं।

Q13. In the C standard, how does 'int f()' differ from 'int f(void)' prior to C23?

(C23 से पहले मानक C में 'int f()' और 'int f(void)' के बीच क्या अंतर था?)

(A) Both mean zero parameters identically in C89

(B) int f(void) takes strictly zero parameters, while int f() means an unspecified parameter list

(C) int f(void) is a syntax error in ANSI C

(D) int f() takes infinite parameters via va_list

Correct Answer: (B)

[EN] In C89/C99/C11/C17, empty parentheses in a function declaration disable parameter-count checking, whereas (void) enforces zero arguments (C23 unified them).

[HI] C89-C17 में f() अज्ञात पैरामीटर दर्शाता था जिससे प्रोटोटाइप जांच नहीं होती थी, जबकि f(void) सख्ती से शून्य तर्क सुनिश्चित करता है।

Q14. In a 32-bit or 64-bit typical C environment, what is the total memory consumed by: char c; int a; float b; double d; (ignoring struct padding)?

(सामान्य 32/64-बिट C वातावरण में char c; int a; float b; double d; (पैडिंग छोड़कर) कुल कितनी मेमोरी लेते हैं?)

(A) 15 bytes (1 + 2 + 4 + 8)

(B) 20 bytes (4 + 4 + 4 + 8)

(C) 12 bytes (1 + 2 + 4 + 5)

(D) 17 bytes (1 + 4 + 4 + 8)

Correct Answer: (D)

[EN] 1 byte (char) + 4 bytes (int) + 4 bytes (float) + 8 bytes (double) = 17 bytes total.

[HI] char (1) + int (4) + float (4) + double (8) मिलाकर कुल 17 बाइट्स मेमोरी उपयोग होती है।

Q15. Why is 'char' legally categorized as an integer arithmetic type inside C?

(C में 'char' को कानूनी रूप से एक पूर्णांक अंकगणितीय (Integer) प्रकार क्यों माना जाता है?)

(A) Because char holds floating-point fractions

(B) It stores small integer character codes (e.g., ASCII) and supports +, -, <, > arithmetic directly

(C) Because char cannot store letters

(D) Because char is 4 bytes wide like int

Correct Answer: (B)

[EN] Statements like 'ch = ch + 32;' convert uppercase ASCII 'A' (65) directly to lowercase 'a' (97).

[HI] char वास्तव में छोटे पूर्णांक (ASCII कोड) रखता है, अतः 'A' + 32 करने पर सीधे 'a' (97) प्राप्त हो जाता है।

Q16. Which statement about Primary Data Types in C is FALSE?

(C में प्राथमिक डेटा प्रकारों (Primary Data Types) के संदर्भ में निम्नलिखित में से कौन सा कथन असत्य (FALSE) है?)

(A) The ISO C standard strictly mandates that int must be 4 bytes (32 bits) on every CPU and compiler

(B) void * can store the memory address of any data type

(C) sizeof(char) is always 1 byte across all C implementations

(D) double provides greater range and precision than float

Correct Answer: (A)

[EN] C only mandates int >= 16 bits and sizeof(short) <= sizeof(int) <= sizeof(long); 16-bit platforms legitimately use 2-byte int.

[HI] ISO C कभी int को हर जगह 4 बाइट होने की बाध्यता नहीं देता; यह न्यूनतम 16 बिट (2 बाइट) सुनिश्चित करता है।

Q17. Within Primary Data Types in C: int, char, float, double and Sizes, which primary data type directly maps to: "1 Byte (8 bits; sizeof == 1 always)"?

(Primary Data Types in C: int, char, float, double and Sizes में कौन सा Primary Data Type सीधे "1 Byte (8 bits; sizeof == 1 always)" से संबंधित है?)

(A) int

(B) float

(C) char

(D) double

Correct Answer: (C)

[EN] In Primary Data Types in C: int, char, float, double and Sizes, 'char' handles '1 Byte (8 bits; sizeof == 1 always)' (-128..127 (signed) or 0..255 (unsigned); %c).

[HI] Primary Data Types in C: int, char, float, double and Sizes में 'char' का कार्य/विवरण '1 Byte (8 bits; sizeof == 1 always)' (-128..127 (signed) or 0..255 (unsigned); %c) है।

Q18. Which option accurately describes 'int' in Primary Data Types in C: int, char, float, double and Sizes?

(Primary Data Types in C: int, char, float, double and Sizes के संदर्भ में 'int' की सही विशेषता कौन सी है?)

(A) 4 Bytes (2B on 16-bit Turbo C)

(B) 8 Bytes (IEEE-754 Double Precision)

(C) 1 Byte (8 bits; sizeof == 1 always)

(D) 4 Bytes (IEEE-754 Single Precision)

Correct Answer: (A)

[EN] 'int' provides '4 Bytes (2B on 16-bit Turbo C)' — key point: -2,147,483,648 to +2,147,483,647; %d / %i.

[HI] 'int' का मुख्य विवरण '4 Bytes (2B on 16-bit Turbo C)' है (-2,147,483,648 to +2,147,483,647; %d / %i)।

Q19. In Primary Data Types in C: int, char, float, double and Sizes, identify the correct parameter for the specification: "4 Bytes (IEEE-754 Single Precision)".

(Primary Data Types in C: int, char, float, double and Sizes में "4 Bytes (IEEE-754 Single Precision)" विवरण किस विकल्प के लिए सही है?)

(A) double

(B) float

(C) char

(D) int

Correct Answer: (B)

[EN] 'float' corresponds to '4 Bytes (IEEE-754 Single Precision)' (1+8+23 bits; ~6-7 decimal digits precision; %f).

[HI] 'float' का संबंध '4 Bytes (IEEE-754 Single Precision)' (1+8+23 bits; ~6-7 decimal digits precision; %f) से है।

Q20. Considering Primary Data Types in C: int, char, float, double and Sizes, what key behavior defines 'double'?

(Primary Data Types in C: int, char, float, double and Sizes में 'double' की मुख्य भूमिका या मान क्या है?)

(A) 8 Bytes (IEEE-754 Double Precision)

(B) 1 Byte (8 bits; sizeof == 1 always)

(C) 4 Bytes (IEEE-754 Single Precision)

(D) 4 Bytes (2B on 16-bit Turbo C)

Correct Answer: (A)

[EN] 'double' represents '8 Bytes (IEEE-754 Double Precision)' (1+11+52 bits; ~15-17 decimal digits; %lf (scanf)).

[HI] 'double' का अर्थ/मान '8 Bytes (IEEE-754 Double Precision)' है (1+11+52 bits; ~15-17 decimal digits; %lf (scanf))।

Primary Data Types in C: int, char, float, double and Sizes — Exam FAQs

Q1: Why do many Indian exam books say int is 2 bytes, whereas GCC prints 4 bytes?

कई भारतीय परीक्षा पुस्तकों में int का आकार 2 बाइट क्यों लिखा होता है, जबकि आधुनिक GCC 4 बाइट दिखाता है?

[EN] Older curriculum books assumed 16-bit MS-DOS compilers (like Turbo C), where CPU word size was 16 bits (2 bytes). On modern 32-bit and 64-bit operating systems (GCC, Clang, MSVC), int is 4 bytes (32 bits).

[HI] पुरानी पुस्तकें 16-बिट MS-DOS (Turbo C) पर आधारित थीं जहाँ int 2 बाइट था। आधुनिक 32/64-बिट कंपाइलरों (GCC/Clang/MSVC) में int 4 बाइट (32 बिट) का होता है।

Q2: Why does printf("%f", d) work for a double, while scanf("%f", &d) fails?

double के लिए printf में %f काम कर जाता है, लेकिन scanf में %f क्यों विफल हो जाता है?

[EN] Under C's default argument promotions, any float passed to variadic printf is automatically promoted to double, so %f expects a double. In scanf, you pass a pointer (&d) without promotion, so %f writes 4 bytes while %lf writes all 8 bytes.

[HI] printf में वेरिएडिक तर्क नियम से float स्वतः double में बदल जाता है (अतः %f व %lf दोनों चलते हैं), पर scanf में एड्रेस (&d) जाता है जहाँ 8-बाइट double भरने हेतु %lf अनिवार्य है।

Q3: Can a C program declare a variable of type void or take sizeof(void)?

क्या C में void प्रकार का वेरिएबल बनाया जा सकता है या sizeof(void) निकाला जा सकता है?

[EN] No—void is an incomplete type with no size or value, so 'void x;' and 'sizeof(void)' are invalid in standard ISO C (GCC enables sizeof(void) == 1 only as a non-standard pointer-arithmetic extension).

[HI] नहीं—void एक अपूर्ण प्रकार है, इसलिए 'void x;' और मानक ISO C में 'sizeof(void)' दोनों अवैध हैं (GCC एक्सटेंशन में यह अपवादस्वरूप 1 देता है)।

Related Posts

  • Loading related posts...

Post a Comment

Search Topic Notes & 20 MCQs (Hindi / English)