Sup Sup Forumsrothers, i need some help

sup Sup Forumsrothers, i need some help
i must work a program that recognize numbers separately to multiplicate it, having only one data entering

ex.: int a, b, c, d, e;
>printf("enter with your id")
54321
>scanf("%d""%d""%d""%d""%d", &a, &b, &c, &d, &e);


*then i need to take each number to multiplicate em like
5*6+4*5+3*4+3*3+1*2

>the problem
i dont know hot to select each number separately

pls, help me b

getc() is your friend

You mean getch()?

Or modulos and divide by 10 to get each digit of the number

Yes

input it as a whole string and then isdigit every letter and act accordingly if it is (convert it to int and send it to int array or something where you can work with it), if there are 2 or more digits in a row just merge them and convert to number

That would imply dynamic memory usage, with malloc and realloc as you dont know how large the string is gonna be. getch() is best bet, or maybe modulos + division to get every digit of the number

Should i use getch or modulo?

you can use getch() in a loop and check for the return character so that you can exit the loop. And do the operations while in the loop

Can you pre write it to me? As an example

Hmm, im starting to get your explanation

getch() - now deprecated has been moved over to _getch(). They are either retarded or trolling you. If you want help add me on discord at:
Kill_Maddie#1265

Int x;

x=54321;

while (x>0)
{
a= x%10
}

Also why are you using Dev C++? Not exactly a good IDE... no offense

These guys are retarded and suggesting a deprecated function call... holy shit you guys are fucking stupid. Use _getch() >_>

With modulus + divide
int digit;

while(x > 0) {
digit = x % 10;
x = x / 10;
}

c++ pic.. c code?

You both are what's wrong with programmers today. I said getch() cause that is what i remember from the last time i touched C. If it's indeed replaced by _getch() (which i assume it does the same fucking shit), then why are you saying it's not a valid solution? KYS pls

not optimized at all, just wrote it in 1min

So, i must use getch in a loop to select each number separately then make the multiplication?
Sorry for my bad english

int inputs[5];

for i = 0 to i = 4
inputs[i] = getch - '0';

int output = 0;
for i = 0 to i = 4
output += (i +1) * inputs[i]

Are we doing c or c++

C++

Deprecated functions are functions which are intended to be removed at one point or another. Using getch() is a short-term solution as it very well may be removed. Also deprecated functions tend to have more problems than their counter-parts. It would be like saying it is reasonable to use the memcpy() function despite it being one of the easiest ways to fuck things up. What have you done for the industry? Fuck off

getch(), or _getch() as pointed by other users automatically captures each character from the keyboard as soon as you press that key. So it would be something like

char c;

while((c=_getch()) != "return character") {

transform c to a number and store in a variable
and then do the operations you need to do.

}

Take note that "return character" means you gotta get the code for the return key on the keyboard, which i do not remember right now.

Honestly I am not sure how you typed that without feeling ashamed. Please educate yourself.

Dude....

It... does... the .... same... fucking... thing...

Change the fucking getch() to _getch() since you are worried so much about that and be done with it. The essence of the solution is the same, dumbfucks. That is what i am trying to say.

cin >> a >> b >> c >> d;
then you want to multiply them all together??

Also, who gives a shit if it is deprecated. IF you ever went to a college or even studied it you would know people in college, even professors, don't give a shit whether it's deprecated or not. So, unless you are coding for something you are going to sell, you don't care about that bullshit. Just use it and get it done. Kids these fucking days who think they know what they are fucking talking about.

So you think it is appropriate to get in the habit of using deprecated functions? What if he goes and works for an industry and writes his code with getch() just because it solves the problem? Then what happens when they remove getch() and you are asked to update your code to C++ 12? Now let's say he used to 100 times in his code. That means 100 lines are broken on update.. how do you not get this?

You think professors letting students get away with bad habits makes those habits a good thing? Jesus you are stupid. It can cause issues if C++ removes the getch() function.

Read

What i am saying is that it's perfectly OK to do this for academic purposes. What you should care about is the algorithm, that you manage to get at the solution of a problem. Obviously, for real world applications, you want to be more rigorous with what tools you are going to be using.

Ty all guys

can you fags stop arguing over a goddamn c++ function

Why not just promote good habits while learning? Your premise is flawed. I'm saying learning bad habits is a BAD idea.

> asking for homework help on a Tibetan throat-singing imageboard

You will soon learn, that all tools do get deprecated. Have fun when your _getch() gets replaced with alphagetch() and you still get the errors you so worry about. If you are taking so much time in memorizing a function name, you are doing something wrong. You should get in the habit of updating your knowledge when coding for production value, paying more attention to algorithms than function names. My solution works. Your _getch() does the same shit as the getch() i remember, and guess what? The algorithm, and thus the solution, won't change.

Also people need to stop including the std namespace. It is a terribly stupid way to go about writing code. takes 1/16 of a second longer to type out std::cout

int main()
{
string s;
getline(cin,s);
int sum = 0;
for(int i=0;i

You keep falling back on "it works" as a premise. We are not discussing if it works or not rather which thing is better to use. I do not memorize anything in programming. I've just programmed enough that I remember the content. You dumb fucks keep promoting bull shit because you have limited practice in C++. It is embarrassing for you.

Also another problem with those commenting is they are not including spaces for readability. Holy shit learn to put a fucking space.

Create a macro that maps getch() to _getch(). Done.

You see, the problem is that you care about stupid shit that is trivial. This is obvious a homework for a class that may be, AT MOST, for a college level course. And you haven't said a single thing that may actually make his algorithm better, like checking that the character _getch() captures is a number and not an alpha character so that it can skip it. Yet here you are arguing about deprecated bs that no one cares about at a college level.

I am not promoting anything, i just mentioned getch() because that is what i remember from memory. I am too busy with higher level languages that do all the crap you worry about for free and without me having to think about it.

Well no that would be retarded since most modern IDEs you can just replace all with. Your solution although a solution is a dumb one.

...

scripter... okay I am done talking with you. That is utterly embarrassing. Enjoy your at most shitty 40 dollar an hour pay.

So you admit there are two simple solutions to this non-issue. Yet you continue to argue that it is a problem. Ok m80.

If you are doing the same loop 3 times why are you not just using recursion and injecting functionality?

Java is scripting? Ruby is scripting? C# is scripting?

One solution is better than another solution. The premise is over which one to use not which one works. They both work. Duh.

every loop is recursion

Ty bro, very much (:

Holy shit you don't understand run time environments. This is just going down hill.

>thinking JIT compilation == scripting
embarrassing

step 1: stop using devc++

it's a shit IDE, if you must use one use Visual Studio, or if you want something more lightweight use code::blocks

No shit sherlock. AKA the solution. Nested for loops.

>runtime environment
...Annnnnnnnnnnnd i think, we that post, can safely conclude that you are a moron. Peace out.

It is you dumb fuck. Just google it. Holy shit you are top tier retarded.

Thanks for pointing that out. Most of these people seem retarded as hell.

have you fucks never heard of atoi()?

The INITIAL "premise" is your argument that using getch() is a problem. I and others argue that it is not an issue, especially given the requirements in this case. Who cares which solution works best if getch() were removed? The point is that, as you have admitted, multiple simple solutions exist.

Recursion is not a programming exclusive term. All it stands for is a repetitive procedure. Your retarded bait where you say for loops are recursion thinking they are not recursion is stupid as they are recursion.

kek
Google what exactly?
Keep digging that hole, faggot. Watching retards struggle is fun.

Yes but my solution is better. This is not a hard concept.

That java is in fact a scripting language. This is not something, someone that understands programming would debate. You are telling me it is not a scripting language?

Or be a man and use emacs for everything

Java is a compiled language. A compiler compiles it into byte code which is fed to a JIT compiler at runtime to transform it into machine code.

Javascript is a scripting language, though the two have little in common other than the name...

>>Sup Forums

>Java
>scripting language

Oh boy. Are you thinking of JavaScript?

why am i banned

Cuz ur gay

>Yes but my solution is better.
Not necessarily. It depends on the program requirements. If you're working on a program that requires a costly audit for each individual file and you do a find/replace on hundreds of files, your manager is going to show you the door and give me your job when I tell him that I could have made the fix by modifying a single file.