Let x be an integer which can take a value of 0 or 1. The statement if (x == 0) x =1 ; else x =0 ; is equivalent to which one of the following ?
সঠিক উত্তর
সঠিক উত্তর: x =1 -x ;
Let x be an integer which can take a value of 0 or 1. The statement if (x == 0) x =1 ; else x =0 ; is equivalent to which one of the following ?
সঠিক উত্তর
সঠিক উত্তর: x =1 -x ;
ভুল বা সঠিক হলে সাথে সাথেই ব্যাখ্যা সহ উত্তর দেখতে পারবেন।
কোন মাধ্যমে আলোর পালস ব্যবহৃত হয়?
অপটিক্যাল ফাইবার এক রকমের যোগাযোগ মাধ্যম, এতে সিগন্যাল বা ডাটা আলোর মাধ্যমে একস্থান থেকে অন্য স্থানে প্রেরণ করা হয়।
আই সি টি বিষয়ে ১০ টি গুরুত্বপূর্ণ প্রশ্ন
১০ মার্কের MCQ কুইজএই প্রশ্নের বিশেষজ্ঞ বিশ্লেষণ
Let x be an integer which can take a value of 0 or 1. The statement <code>if (x == 0) x =1 ; else x =0 ;</code> is equivalent to which one of the following?
x = 1 + x;
x = x - 1;
x = 1 - x;
x = 1 % x;
The correct answer is: x = 1 - x;
To understand why the statement <code>x = 1 - x;</code> is equivalent to <code>if (x == 0) x = 1; else x = 0;</code>, consider the logical flow of the given if-else statement:
When <code>x == 0</code>: The statement <code>x = 1;</code> is executed.
When <code>x == 1</code>: The statement <code>x = 0;</code> is executed.
Now, let's analyze each choice to see which one replicates this behavior:
<code>x = 1 + x;</code> <br>This does the following:
If <code>x = 0</code>, then <code>x = 1 + 0 = 1</code>.
If <code>x = 1</code>, then <code>x = 1 + 1 = 2</code>.
Therefore, it does not correctly replicate the behavior of the given if-else statement.
<code>x = x - 1;</code> <br>This does the following:
If <code>x = 0</code>, then <code>x = 0 - 1 = -1</code>.
If <code>x = 1</code>, then <code>x = 1 - 1 = 0</code>.
Again, this does not correctly replicate the behavior because <code>x</code> can become -1, which is not a valid outcome based on the original problem constraints (i.e., <code>x</code> can only be 0 or 1).
<code>x = 1 - x;</code> <br>This does the following:
If <code>x = 0</code>, then <code>x = 1 - 0 = 1</code>.
If <code>x = 1</code>, then <code>x = 1 - 1 = 0</code>.
Hence, this choice perfectly replicates the behavior of the given if-else statement.
<code>x = 1 % x;</code> <br>This choice is problematic because it attempts to divide by zero when <code>x</code> is 0, which will result in a runtime error. Therefore, it is not a valid transformation of the given problem.
Therefore, upon examination of each choice, we conclude that the correct answer is: x = 1 - x;
রেফারেন্স মাত্র
আই সি টি বিষয়ের আরও প্রশ্ন