This code is for finding the missing number in array but after running this code no output is visible what is wrong in this code ?
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n , a[n] , sum ;
cin>>n;
for (int i = 0; i < n; ++i)
{
cin >> a[i];
}
sum = n*(n+1)/2;
// cout<<sum;
for(int i=0; i<n;i++)
{
sum=sum-a[i];
}
cout << sum;
//return 0;
}
Aucun commentaire:
Enregistrer un commentaire