DIGIT-ARC read-only archive · snapshot: July 23, 2026

Help adding numbers in C++

25 posts · originally from https://geek.digit.in/community/threads/help-adding-numbers-in-c.172808/

©mß
©mß Original post #1
Apr 17, 2013 at 5:11 PM
Dos.PNG
This code is what I wrote.
After typing first no. and then the second no. and then when I press enter, no result is shown and program terminates.
What is wrong in the code?
Our teacher asked to add ourselves using our BRAIN.
I am unable to understand,is this method right?

I am right now using Turbo C++.
So,do i have to press Alt+F5 to get the ans or it should give me ans when I press Cntrl+F9?
harshilsharma63
Apr 17, 2013 at 8:04 PM
The code is perfect but the problem is the lord or crap Turbo C. Just make the program in some IDE and it will run. ANd please please ^100000000000 stop using turbo C :pullhair::pan::sniper::flamethrower:
coderunknown
Apr 17, 2013 at 8:34 PM
can't help. most university still recommend using this ancient stuff. learned C++ this way just to pass and get the first step in world of programming.
krishnandu.sarkar
Apr 17, 2013 at 9:40 PM
Well I agree, Turbo C is crap but students have no way, as universities and colleges force it.

@OP replace...

int main() with void main()

and return 0; with getch();
nightcrawler
Apr 17, 2013 at 11:23 PM
Stop using Turbo C++. It uses all non standard function calls. Why are you using conio.h? Stop using it. It is non-standard library. Also don't use clrscr(). Again Same non-standard function. Also I would not recommend using getch(), again a non standard function. While you may ask as to why not to use them. Using such calls generally creates a habit that tends to continue as you go along. If you are serious about programming as a career, then start using standard C++ practices in your code. It will help you believe me.

God Why do they use Turbo C++ still especially when good free compilers and IDEs are available?

Use the following code snippet

Code:
#include <iostream>
#include <limits>

int main(int argc, char*argv[])        {
      //Code Start
      //Code Goes here
      //Cod End
      cin.ignore( numeric_limits<streamsize>::max(), '\n' );
      return iValue; // your main function return value to system
}

That should work for you.
harshilsharma63
Apr 18, 2013 at 6:47 AM
@OP; even if your college used TurboC, even then you should use Code::Blocks or (the better) Eclipse.
krishnandu.sarkar
Apr 18, 2013 at 10:42 AM
Stop using Turbo C++. It uses all non standard function calls. Why are you using conio.h? Stop using it. It is non-standard library. Also don't use clrscr(). Again Same non-standard function. Also I would not recommend using getch(), again a non standard function. While you may ask as to why not to use them. Using such calls generally creates a habit that tends to continue as you go along. If you are serious about programming as a career, then start using standard C++ practices in your code. It will help you believe me.

God Why do they use Turbo C++ still especially when good free compilers and IDEs are available?

Use the following code snippet

Code:
#include <iostream>
#include <limits>

int main(int argc, char*argv[])        {
      //Code Start
      //Code Goes here
      //Cod End
      cin.ignore( numeric_limits<streamsize>::max(), '\n' );
      return iValue; // your main function return value to system
}

That should work for you.

Well, I doubt whether this piece of code will get accepted by the college.

But I agree with you and others. Like we all said, what I suggested is non standard programming and one should not practice it.

But another truth is that, there's no way if you are a college student and have to submit assignments. So as harshilsharma63 said, use Code::Blocks at home for practicing and modify the code for submission.
nightcrawler
Apr 18, 2013 at 11:31 AM
That is a cause of concern then. The education, especially the IT education in India sucks big time. No scope for creativity and thinking out of the box, I remember the time when some of us tried coding in different ways, the faculty used to give less marks (sometimes 0) simply because it was "not a proper way to code" and did not match the code given in the book or something. It was more of a case of them not understanding the code...oh things haven't changed over the years I guess...:-(
Nerevarine
Apr 18, 2013 at 12:00 PM
OBSTINATE TEACHERS !!!!!!!!!!!!
I hated TC because of the damn blue screen
harshilsharma63
Apr 18, 2013 at 2:27 PM
OBSTINATE TEACHERS !!!!!!!!!!!!
I hated TC because of the damn blue screen
At least in dept. (CSE), turbo C is officially banned. If a student is found to have used Turbo C for making project or any assignment, his/her marks are deducted!
©mß
©mß #11
Apr 18, 2013 at 2:58 PM
Well this is my first ever code written by me on my second class.
So,my teacher taught us to write in this way just asked us to add on our own.
I too hate that bright eye penetrating BLUE colour.
harshilsharma63
Apr 18, 2013 at 3:12 PM
Well this is my first ever code written by me on my second class.
So,my teacher taught us to write in this way just asked us to add on our own.
I too hate that bright eye penetrating BLUE colour.
If thats the case, you are still far from becoming used to the non-standard functions in the crap. Switch to Code Blocks of Eclipse.
krishnandu.sarkar
Apr 18, 2013 at 6:50 PM
Well this is my first ever code written by me on my second class.
So,my teacher taught us to write in this way just asked us to add on our own.
I too hate that bright eye penetrating BLUE colour.

Well that's good. Your teacher is teaching you the standard way of writing C programs.

In that case do what @nightcrawler suggested.
gameranand
Apr 19, 2013 at 10:50 PM
Well I just use Code::Blocks and if some teacher ask me to write in Turbo then I just ask them to install Code::Blocks and usually they don't ask again. :D:D
©mß
©mß #15
Apr 22, 2013 at 5:48 PM
exe file.PNG
So,why is this error coming?
I created the .exe file with Turbo C++ of whose screenshot I posted earlier.

Moreover, how do you insert image in spoiler?
I tried but failed as you can see. LOLS
harshilsharma63
Apr 22, 2013 at 6:00 PM
So,why is this error coming?
I created the .exe file with Turbo C++ of whose screenshot I posted earlier.

Moreover, how do you insert image in spoiler?
I tried but failed as you can see. LOLS

> My hypothesis: TurbiC is a 16 bit program so the EXEs generated by it are also 16 bit which cannot be run on a 32/64 bit machine.

> Enclose the link to the image in IMG tags:


> You still haven't switched to an IDE.
Shah
Shah #17
Apr 22, 2013 at 7:24 PM
So,why is this error coming?
I created the .exe file with Turbo C++ of whose screenshot I posted earlier.

Moreover, how do you insert image in spoiler?
I tried but failed as you can see. LOLS

We already told you that TC++ is just a peice of carp and not to use it. Anyway, Try running that compiled program in Win95 or Win98. It would work.
harshilsharma63
Apr 22, 2013 at 7:36 PM
We already told you that TC++ is just a peice of carp and not to use it. Anyway, Try running that compiled program in Win95 or Win98. It would work.
Yeah, it's meant for that :rofl:
©mß
©mß #19
Apr 23, 2013 at 11:56 AM
I downloaded eclipse for C++ and when I typed all the lines same as of TC++, it is not accepting them.
It says like cout,cin is not supported.
Is it different in eclipse

I changed the compatibility to Win95&98.
Still same error persists.
nightcrawler
Apr 23, 2013 at 1:45 PM
I downloaded eclipse for C++ and when I typed all the lines same as of TC++, it is not accepting them.
It says like cout,cin is not supported.
Is it different in eclipse

I am sure you have missed putting
Code:
using namespace std;
at the top of your code. See what Turbo C++ does for you?

Add the above bit and your code should work just fine in eclipse. Remember that Eclipse is just an IDE (Integrated Development Environment). It will follow the syntax grammer of that language for which it has been configured. So no, it is not differenct in eclipes. These are C++ specific syntax. Since cin, cout etc are part of std namespace you have to either reference that in your code or specify something like std::cin etc. Readup a bit on namespaces and their uses etc as well.
harshilsharma63
Apr 23, 2013 at 4:43 PM
I downloaded eclipse for C++ and when I typed all the lines same as of TC++, it is not accepting them.
It says like cout,cin is not supported.
Is it different in eclipse

I changed the compatibility to Win95&98.
Still same error persists.

the structure of the program is:

<preprocessors>
<definations>
<main function>

write it as:
Code:
#include<iostream>
using namespace std;

int main()
{
     cout << "blah blah blah...";
     return 0;
}

remember, its "iostream", not "iostream.h".
©mß
©mß #22
Apr 26, 2013 at 2:41 PM
Now bye-bye to TC++.
Now we'll learn Python.
CBSE ordered to teach Python instead of C++ for it's more demand in market.
harshilsharma63
Apr 26, 2013 at 3:09 PM
Now bye-bye to TC++.
Now we'll learn Python.
CBSE ordered to teach Python instead of C++ for it's more demand in market.
:clap2: I wonder when will my university will come to know about the reality.
©mß
©mß #24
Apr 26, 2013 at 4:13 PM
If it's implemented here then next might be your university.
BTW which university? DU?