Why are the different output of C++ and C# compiler? -
Why are the different output of C++ and C# compiler? -
i have been asked questions before time want know difference between compiler of c++ , c#.
static void main(string[] args) { int n; int[] ar = new int[50]; console.write("enter size of array= "); n = int.parse(console.readline()); (int = 0; < n; i++) { ar[i] = int.parse(console.readline()); } (int = 0; < n; i++) { console.writeline("ar[" + + "]=" + ar[i]); } console.read(); } output c++ coding of array int main() { clrscr(); int x[10]; int n; cout << "enter array size= "; cin >> n; cout << "enter elements array= "; for(int = 0; < n; i++) { cin >> x[i]; } for(int = 0; < n; i++) { cout << "x[" << << "]=" << x[i] << "\n"; } getch(); homecoming 0; } output here question when m giving same input c# asking 4 elements input , leave 0 before digit. when m going same input in c++ considering 0 digit separate input m giving digit , took less input entered.
even both languages follow oop approach. difference between both compiler. why these taking lots of different input , generating different output.
one more bother me why c++ compiler not reading 0 lastly element , print 7 input 07 according above output should 0 not 7.
this finish guess borland c++ trying interpret number leading 0 octal (which standard convention '0x' prefix hexadecimal). since 08 isn't valid octal number (only 0-7 valid digit octal) splitting 2 inputs.
try entering '010' , if programme prints out 8 you'll know interpreting leading 0 octal.
you trying forcefulness cin interpret input decimal changing input line to:
cin >> dec >> x[i]; c# c++ compiler-construction
Comments
Post a Comment