Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99280

Why does my code's output go wrong at the end?

$
0
0

Today I have tried setting up vscode for c++ compiling and after compiling a simple cpp program I saw that the output is wrong and i have no idea why.

Here is my code: https://pastebin.com/iLSVHW7T

#include <iostream>

using namespace std;

int main(){
    int x[3],i,n;
    cin>>n;
    for(i=0;i<=n;i++)
    cin>>x[i];
    for(i=0;i<=n;i++)
    cout<<x[i]<<"";
}

This image shows what is going wrong.

Thanks for your time.


Viewing all articles
Browse latest Browse all 99280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>