Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

added 83 characters in body
Source Link
avirk
  • 3.1k
  • 7
  • 41
  • 58
int main()
{
 clrscr();
 int x[3];
 int n;
 cout<<"Enter the array size= ";
 cin>>n;
 cout<<"Enter the elements for array= ";
 for(int i=0;i<n;i++)
 {
 cin>>x[i] ;
 }
 for(i=0;i<n;i++)
 {
 cout<<"x["<<i<<"]="<<x[i]<<"\n";
 }
 getch();
 return 0;
}

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

enter image description here

int main()
{
 clrscr();
 int x[3];
 int n;
 cout<<"Enter the array size= ";
 cin>>n;
 cout<<"Enter the elements for array= ";
 for(int i=0;i<n;i++)
 {
 cin>>x[i] ;
 }
 for(i=0;i<n;i++)
 {
 cout<<"x["<<i<<"]="<<x[i]<<"\n";
 }
 getch();
 return 0;
}

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

int main()
{
 clrscr();
 int x[3];
 int n;
 cout<<"Enter the array size= ";
 cin>>n;
 cout<<"Enter the elements for array= ";
 for(int i=0;i<n;i++)
 {
 cin>>x[i] ;
 }
 for(i=0;i<n;i++)
 {
 cout<<"x["<<i<<"]="<<x[i]<<"\n";
 }
 getch();
 return 0;
}

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

enter image description here

Post Reopened by Lightness Races in Orbit, ildjarn, Gilles 'SO- stop being evil', Bo Persson, Yakov Galka
Post Closed as "not a real question" by Community Bot, BЈовић, Aron Rotteveel, Fred Foo, Bala R
deleted 13 characters in body
Source Link
ildjarn
  • 63.3k
  • 9
  • 135
  • 219
int main()
{ clrscr(); int x[3]; int n; cout<<"Enter the array size= "; 
cin>>n; cin>>n;
cout<<"Enter the elements for array= "; for(int i=0;i<n;i++) 
{ {
cin>>x[i] ; 
} cin>>x[i] ;
 for(i=0;i<n;i++) }
 for(i=0;i<n;i++)
 { {
 cout<<"x["<<i<<"]="<<x[i]<<"\n"; cout<<"x["<<i<<"]="<<x[i]<<"\n";
 }
 getch();
 return 0;
}

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

int main()
{ clrscr(); int x[3]; int n; cout<<"Enter the array size= "; 
cin>>n; 
cout<<"Enter the elements for array= "; for(int i=0;i<n;i++) 
{ 
cin>>x[i] ; 
} for(i=0;i<n;i++) 
 { 
 cout<<"x["<<i<<"]="<<x[i]<<"\n"; 
 }
 getch();
 return 0;
}

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

int main()
{ clrscr(); int x[3]; int n; cout<<"Enter the array size= "; cin>>n;
cout<<"Enter the elements for array= "; for(int i=0;i<n;i++) {
 cin>>x[i] ;
 }
 for(i=0;i<n;i++)
 {
 cout<<"x["<<i<<"]="<<x[i]<<"\n";
 }
 getch();
 return 0;
}

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

int main()
{
clrscr();
int x[3];
int n;
cout<<"Enter the array size= ";
cin>>n;
cout<<"Enter the elements for array= ";
for(int i=0;i<n;i++)
{
cin>>x[i] ;
}
for(i=0;i<n;i++)
{
cout<<"x["<<i<<"]="<<x[i]<<"\n";
}
getch();
return 0;
}

int main() 
{ 
clrscr(); 
int x[3]; 
int n; 
cout<<"Enter the array size= "; 
cin>>n; 
cout<<"Enter the elements for array= "; 
for(int i=0;i<n;i++) 
{ 
cin>>x[i] ; 
} 
 for(i=0;i<n;i++) 
 { 
 cout<<"x["<<i<<"]="<<x[i]<<"\n"; 
 } 
 getch(); 
 return 0; 
} 

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

int main()
{
clrscr();
int x[3];
int n;
cout<<"Enter the array size= ";
cin>>n;
cout<<"Enter the elements for array= ";
for(int i=0;i<n;i++)
{
cin>>x[i] ;
}
for(i=0;i<n;i++)
{
cout<<"x["<<i<<"]="<<x[i]<<"\n";
}
getch();
return 0;
}

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

int main() 
{ 
clrscr(); 
int x[3]; 
int n; 
cout<<"Enter the array size= "; 
cin>>n; 
cout<<"Enter the elements for array= "; 
for(int i=0;i<n;i++) 
{ 
cin>>x[i] ; 
} 
 for(i=0;i<n;i++) 
 { 
 cout<<"x["<<i<<"]="<<x[i]<<"\n"; 
 } 
 getch(); 
 return 0; 
} 

When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.

output

Source Link
avirk
  • 3.1k
  • 7
  • 41
  • 58
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /