What is the output of the following C code?
#include
int main(){
int arr[5] = {1,2,3,4,5};
int *p = (arr+2);
printf("%d",p[-1]);
return 0;
}
A
2
B
3
C
Undefined behavior
D
Compilation error
উত্তরের বিবরণ
#include <stdio.h>
int main() {
int arr[5] = {1,2,3,4,5};
int *p = (arr + 2);
printf("%d", p[-1]);
return}
1. int arr[5] = {1,2,3,4,5};
এখানে একটি অ্যারে আছে
—
arr[0] = 1
arr[1] = 2
arr[2] = 3
arr[3] = 4
arr[4] = 5
int *p = (arr + 2);
arr হচ্ছে অ্যারের প্রথম উপাদানের ঠিকানা (অর্থাৎ &arr[0])।
তাই arr + 2 মানে হলো &arr[2], অর্থাৎ
তৃতীয় উপাদানের মান। অর্থাৎ 3।
কিন্তু প্রশ্নে আউটপুট বের করতে বলেছে
p[-1] এর অর্থাৎ *P=arr[2] এর আগের ঠিকানার
মান বের করতে বলেছে
যেটা *p=&arr[1] যার মান হলো
2. এটাই ফাইনাল আউটপুট।

0
Updated: 2 days ago
The minimum number of NAND gates required to implement an OR gate is:
Created: 2 days ago
A
1
B
2
C
3
D
4
Answer: গ)
3
Explanation:

0
Updated: 2 days ago
Which one is true for a DFA?
Created: 2 days ago
A
DFA can have ε-transitions
B
DFA accepts all context-free languages
C
DFA accepts regular languages
D
DFA can have multiple transitions for the same input from a state
Deterministic Finite Automaton (DFA) হলো একটি তাত্ত্বিক গণনামূলক মডেল যা regular languages চিনতে ব্যবহৃত হয়। এটি প্রতিটি ইনপুটের জন্য সুনির্দিষ্ট ও একক পরবর্তী অবস্থা নির্ধারণ করে, অর্থাৎ কোনো অস্পষ্টতা (nondeterminism) থাকে না।
বিস্তারিতভাবে:
-
Deterministic: প্রতিটি state এবং input symbol-এর জন্য কেবল একটি নির্দিষ্ট next state থাকে।
-
No ε-transitions: DFA-তে ε (epsilon) ট্রানজিশন থাকে না, অর্থাৎ কোনো ইনপুট ব্যবহার না করেই অবস্থান পরিবর্তন করা যায় না।
-
Language Acceptance: DFA শুধুমাত্র regular languages গ্রহণ করতে সক্ষম। এটি context-free বা context-sensitive ভাষা সনাক্ত করতে পারে না, কারণ তাতে stack বা অতিরিক্ত মেমরি প্রয়োজন হয়।
-
Operational Principle: একটি DFA একটি নির্দিষ্ট ইনপুট স্ট্রিং পুরোটা স্ক্যান করে, এবং শেষ পর্যন্ত accept state-এ পৌঁছালে সেই স্ট্রিংটি গ্রহণ করা হয়।
ভুল বিকল্পগুলো:
-
(ক) DFA-তে ε-transitions থাকতে পারে → ভুল; এটি কেবল NFA (Nondeterministic Finite Automaton)-এ সম্ভব।
-
(খ) DFA সব context-free ভাষা গ্রহণ করে → ভুল; DFA-র কোনো stack memory নেই, তাই context-free ভাষা গ্রহণ করতে পারে না।
-
(ঘ) DFA-তে একই ইনপুটের জন্য একাধিক ট্রানজিশন থাকতে পারে → ভুল; এটি determinism-এর বিপরীত।
অতএব, সঠিক উত্তর হলো (গ) DFA accepts regular languages, কারণ DFA কেবলমাত্র regular set বা language-কেই সনাক্ত করতে পারে।

0
Updated: 2 days ago
Which of the following is a combinational circuit?
Created: 2 days ago
A
Counter
B
Flip flop
C
Multiplexor
D
Register
Answer: গ)
Multiplexor
Explanation:
A combinational circuit is a digital circuit whose
output depends only on the present inputs, not on past inputs or stored
data.
Multiplexer (MUX):
It is a combinational circuit.
It selects one input line from many and forwards it to the output based on
select lines.
No memory element, so output = function of current inputs only

0
Updated: 2 days ago