মেধাবী
Toggle menu

Consider the following variable declarations and definations in C .

(i) int var 9 =1 ;

(ii) int 9 var =2;

(iii) int + =3;

Choose the correct statement w.r.t above variables.

সঠিক উত্তর
Both i. & iii. are valid

বিস্তারিত ব্যাখ্যা

এই প্রশ্নের বিশেষজ্ঞ বিশ্লেষণ

<html lang="en"> <head> <meta charset="UTF-8"> <title>Explanation for C Variable Declarations and Definitions</title> <style> body { font-family: Arial, sans-serif; line-height: 1.5; margin: 20px; } code { background-color: #f9f9f9; padding: 2px 5px; border-radius: 4px; color: #d63384; } .code-block { background-color: #f9f9f9; padding: 10px; border-radius: 4px; overflow-x: auto; } .valid, .invalid { font-weight: bold; } .valid { color: green; } .invalid { color: red; } </style> </head> <body> <h1>Explanation for C Variable Declarations and Definitions</h1>

The given question asks about the validity of certain variable declarations in the C programming language:

<div class="code-block">

Here are the declarations and definitions:

<pre><code> (i) int var9 = 1; (ii) int 9var = 2; (iii) int + = 3; </code></pre> </div>

Let's analyze each one:

<h2>(i) <code>int var9 = 1;</code></h2>

This declaration is <span class="valid">valid</span>. According to C naming conventions, variable names can include letters (both uppercase and lowercase), digits, and the underscore character, but they must start with a letter or an underscore. In this case, <code>var9</code> starts with a letter and includes a digit, making it a perfectly valid variable name.

<h2>(ii) <code>int 9var = 2;</code></h2>

This declaration is <span class="invalid">invalid</span>. Variable names in C cannot start with a digit. Since <code>9var</code> begins with the digit '9', this violates the naming rules and is therefore an invalid declaration.

<h2>(iii) <code>int + = 3;</code></h2>

This declaration is <span class="invalid">invalid</span>. The '+' character is not allowed in variable names as it is an operator in C. Variable names can only contain letters, digits, and underscores, and must start with a letter or an underscore. Therefore, using the '+' character in the variable name makes it invalid.

Given the above breakdown, none of the statements provided in the choices ('Both i. & iii. are valid', 'Only i. is valid', 'Both i. and ii. are valid ', 'All of these') correctly describe the validity of the variable declarations. However, the correct answer amongst the provided choices should be:

<div class="code-block">

<code>Only i. is valid</code>

</div>

This is because (i) is the only valid declaration according to C naming conventions for variables.

<footer>

References:

</footer> </body> </html>

সকল অপশন

রেফারেন্স মাত্র

Both i. & iii. are valid সঠিক
Only i. is valid
Both i. and ii. are valid
All of these

প্রশ্ন তথ্য

বিষয়
আই সি টি
শ্রেণী
চাকুরী প্রস্তুতি - ব্যাংক
মার্ক
1.00

অ্যাপে আরও ১ লক্ষ+ প্রশ্ন অনুশীলন করুন

বিনামূল্যে • ৪.৯★ রেটিং • ৫০K+ ডাউনলোড

ডাউনলোড করুন

মেধাবী অ্যাপ

বিনামূল্যে • ৪.৯★

ডাউনলোড