Ana sayfa
/
Teknoloji
/
Question: Given the C++ programming code at which line there is a logical err 1 #include <iostre am> 2 using namespace std; 3 int main(void) 4 5 char let ter; 6 cout<<"E nter a ch arac ter :": 7 cin>> let ter; 8 if(let ter ='A') 9 cout<<"H ello": 10 return 0: 11 12 Select one: a. 5 b. 7 c. 8 a

Soru

Question: Given the C++ programming code at which line there is a logical err
1 #include <iostre am>
2 using namespace std;
3 int main(void)
4
5	char let ter;
6	cout<<"E nter a ch arac ter :":
7
cin>> let ter;
8	if(let ter ='A')
9	cout<<"H ello":
10 return 0:
11
12
Select one:
a. 5
b. 7
c. 8
a

Question: Given the C++ programming code at which line there is a logical err 1 #include <iostre am> 2 using namespace std; 3 int main(void) 4 5 char let ter; 6 cout<<"E nter a ch arac ter :": 7 cin>> let ter; 8 if(let ter ='A') 9 cout<<"H ello": 10 return 0: 11 12 Select one: a. 5 b. 7 c. 8 a

Çözüm

4.6244 Voting
avatar
Sibel
Kıdemli · 10 yıl öğretmeni
Uzman doğrulaması

Cevap

The logical error is at line 8. The condition `if(letter = 'A')` uses a single equals sign (`=`), which is an assignment operator, instead of the equality operator (`==`). This means that it assigns the value `'A'` to `letter` instead of checking if `letter` is equal to `'A'`. The correct line should be:<br /><br />```cpp<br />if(letter == 'A')<br />```<br /><br />Therefore, the correct answer is:<br /><br />c. 8
Derecelendirmek için tıklayın: