Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void addition ( double operand1, double operand2, double *ergebnis){
- *ergebnis = operand1 + operand2;
- }
- void subtraktion ( double operand1, double operand2, double *ergebnis){
- *ergebnis = operand1 - operand2;
- }
- void multiplikation ( double operand1, double operand2, double *ergebnis){
- *ergebnis = operand1 * operand2;
- }
- void division (double operand1, double operand2, double *ergebnis){
- *ergebnis = operand1 / operand2;
- }
- int main (void)
- {
- double operand1, operand2, ergebnis;
- char operator1;
- printf("Dies ist ein Taschenrechnerprogramm fuer die vier Grundrechenarten!\n\n");
- printf("Geben Sie bitte nun den ersten Operanden ein!\n");
- scanf_s("%lf", &operand1);
- printf("Geben Sie bitte den zweiten Operator ein\n");
- scanf("%lf",&operand2);
- printf("Geben Sie bitte nun den Operator ein!\n");
- scanf_s("%c",&operator1);
- if(operator1 == '+' ) {
- printf ("\n\n");
- addition (operand1, operand2, &ergebnis);
- printf ("%5.2f", operand1);
- printf (" + ");
- printf ("%5.2f", operand2);
- printf (" = ");
- printf ("%5.2f ", ergebnis);
- }
- if(operator1 == 2) {
- printf ("\n\n");
- subtraktion (operand1, operand2, &ergebnis);
- printf ("%5.2f", operand1);
- printf (" - ");
- printf ("%5.2f", operand2);
- printf (" = ");
- printf ("%5.2f", ergebnis);
- }
- if (operator1 == 3) {
- printf ("\n\n");
- multiplikation (operand1, operand2, &ergebnis);
- printf ("%5.2f", operand1);
- printf (" * ");
- printf ("%5.2f", operand2);
- printf (" = ");
- printf ("%5.2f", ergebnis);
- }
- if (operator1 == 4) {
- printf ("\n\n");
- division (operand1, operand2, &ergebnis);
- printf ("%5.2f", operand1);
- printf (" / ");
- printf ("%5.2f", operand2);
- printf (" = ");
- printf ("%5.2f", ergebnis);
- }
- getchar ();
- getchar ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement