Evening, very early in the morning (04:45) actually. I'm very new to C, self taught using online tutorials, and I'm trying to create a small, extremely simple program to run equations for me so that I don't have to repeat tediously typing in calculations on my calculator in physics.
So far, it's all working, runs on a simple directory ( Enter '1' for addition, '2' for subtraction, and so on ) on a branching approach, ( if and else if's ) which works very well until I started inputting all of the equations I have to use, which number in over three dozen. And the directory takes up space.
Now it's rather confusing. I also got it to work on a single character ( Enter 'a' for addition etc ) but there are only 26 letters, and more equations than that. Not helping much.
What I was looking for was the ability to type in an array of characters, such as 'addition', which would then be taken by the if statement and then carries out the addition function.
Here's a snippet; as you can see, very simple. What I wanted was to be able to replace the '1' with the word 'addition' and achieve the same effect. Hope that I make sense.
printf("\n\n\n Choose Operation\n >: ");
if ( operation == 1 )
float iadd1, iadd2;
printf("\nOperation: Addition\n\n First Number: ");
printf(" Second Number: ");
printf("\nResult: %f\n\n\n\n", iadd1 + iadd2);
I've scanned the FAQ, and most of the tutorials, but as I browsed I became increasingly out of my depth. If there isn't a simple solution, then I understand, please say so, and that'll be the end of it.
And if I sound unbelievably simple and....noobish, then...well, I've only been using C for two days.
Much appreciate your help, thanks.
- Harry Manners