need to answer

What si the output of the following code:
int vb[8]
char dd[10]
for (int i= 0; i < 8; i++0
cin >> vb[i];
for (int i = 0; i <10; i++0
dd[i] ='A"
vb[3] = vb[3]--;
vb[2] = vb[6] + vb[4];
vb[1] = vb[3];
vb[3] = vb[5] + vb[1];
dd[2] = ''B';
dd[3]= 'C';
dd[4] = 'C'
For (int i = 0; i < 8; i++)
cout << vb[i] << dd[i] << endl;
A bunch of syntax errors from the compiler? Did I get it right?
No its a question how can write the out put
alreem wrote:
What si the output of the following code:


Well, with simple header and footer added, my compiler gave:
try.cpp:11:8: warning: missing terminating ' character
 dd[i] ='A"
        ^
try.cpp:11:8: error: missing terminating ' character
 dd[i] ='A"
        ^~~
try.cpp:16:9: error: empty character constant
 dd[2] = ''B';
         ^~~
try.cpp:16:12: warning: missing terminating ' character
 dd[2] = ''B';
            ^
try.cpp:16:12: error: missing terminating ' character
 dd[2] = ''B';
            ^~
try.cpp: In function 'int main()':
try.cpp:7:1: error: expected initializer before 'char'
 char dd[10]
 ^~~~
try.cpp:8:16: error: 'i' was not declared in this scope
 for (int i= 0; i < 8; i++0
                ^
try.cpp:10:27: error: expected ')' before numeric constant
 for (int i = 0; i <10; i++0
                           ^
try.cpp:11:1: error: expected ';' before 'dd'
 dd[i] ='A"
 ^~
try.cpp:12:16: warning: statement has no effect [-Wunused-value]
 vb[3] = vb[3]--;
                ^
try.cpp:13:1: error: 'vb' was not declared in this scope
 vb[2] = vb[6] + vb[4];
 ^~
try.cpp:16:1: error: 'dd' was not declared in this scope
 dd[2] = ''B';
 ^~
try.cpp:16:9: error: unable to find character literal operator 'operator""B' with 'char' argument
 dd[2] = ''B';
Last edited on
Even assuming fixing all the silly syntax errors, and the undefined behaviour of vb[3], we're still left with the unknown of what you type in for cin >> vb[i];
The code is idiotic and does nothing interesting at all, no matter what the input.
Where did you get this crap?
The easy way to check is to write a correct program and put it between [ code ] [ /code ].
Then click the gear at the top-right of code block.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream>
using namespace std;

int main()
{
  int vb[8];
  char dd[10];

  for (int i= 0; i < 8; i++)
    cin >> vb[i];
  for (int i = 0; i <10; i++)
    dd[i] ='A';
  vb[3] = vb[3]--;
  vb[2] = vb[6] + vb[4];
  vb[1] = vb[3];
  vb[3] = vb[5] + vb[1];
  dd[2] = 'B';
  dd[3] = 'C';
  dd[4] = 'C';
  for (int i = 0; i < 8; i++)
    cout << vb[i] << dd[i] << endl;

  return 0;
}
Last edited on
Topic archived. No new replies allowed.