Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 15:04

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Simple Calculator

Discussion on Simple Calculator within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2011
Posts: 362
Received Thanks: 41
Simple Calculator

Here|s a simple calculator i made , may someone can use it or need it!
Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

float f_addiere(float zahl1,float zahl2){
	float summe;
	summe=zahl1+zahl2;
	return summe;
}
float f_subtra(float zahl1,float zahl2){
	float summe;
	summe=zahl1-zahl2;
	return summe;
}
float f_multi(float zahl1,float zahl2){
	float summe;
	summe=zahl1*zahl2;
	return summe;
}
float f_divi(float zahl1,float zahl2){
	float summe;
	summe=zahl1/zahl2;
	return summe;
}
int i_addiere(int zahl1,int zahl2){
	int summe;
	summe=zahl1+zahl2;
	return summe;
}
int i_subtra(int zahl1,int zahl2){
	int summe;
	summe=zahl1-zahl2;
	return summe;
}
int i_multi(int zahl1,int zahl2){
	int summe;
	summe=zahl1*zahl2;
	return summe;
}
int i_divi(int zahl1,int zahl2){
	int summe;
	summe=zahl1/zahl2;
	return summe;
}


int main(){
	float zahl1,zahl2,ergebnis;
	int zahli1,zahli2,ergebniss;
	char wahl,operant;
	printf("Mit welchen Zahlen moechten sie Rechnen? [I,F]\n");
	wahl=getch();
	if (wahl=='i'){
		printf("Bitte zwei Zahlen eingeben: ");
		scanf("%i %i",&zahli1,&zahli2);
		printf("Mit welchen Operant moechten sie Rechnen?\n");
		operant=getch();
		if(operant=='+'){
			printf("Ihr Ergebnis ist : %i \n",i_addiere(zahli1,zahli2));
		}
		else if(operant=='-'){
			printf("Ihr Ergebnis ist : %i \n",i_subtra(zahli1,zahli2));
		}
		else if(operant=='*'){
			printf("Ihr Ergebnis ist : %i \n",i_multi(zahli1,zahli2));
		}
		else if(operant=='/'){
			printf("Ihr Ergebnis ist : %i \n",i_divi(zahli1,zahli2));
		}
	}
	else if(wahl=='f'){
		printf("Bitte zwei Zahlen eingeben: ");
		scanf("%f %f",&zahl1,&zahl2);
		printf("Mit welchen Operant moechten sie Rechnen?\n");
		operant=getch();
		if(operant=='+'){
			printf("Ihr Ergebnis ist : %.2f \n",f_addiere(zahl1,zahl2));
		}
		else if(operant=='-'){
			printf("Ihr Ergebnis ist : %.2f  \n",f_subtra(zahl1,zahl2));
		}
		else if(operant=='*'){
			printf("Ihr Ergebnis ist : %.2f  \n",f_multi(zahl1,zahl2));
		}
		else if(operant=='/'){
			printf("Ihr Ergebnis ist : %.2f  \n",f_divi(zahl1,zahl2));
		}
	}
	system("PAUSE");
	return 0;
}
Rullx3 is offline  
Old 03/22/2013, 17:46   #2
 
Devil0s's Avatar
 
elite*gold: 12
Join Date: Jan 2011
Posts: 676
Received Thanks: 44
Also für den Anfang ist das OK, aber um nen richtig guten Taschenrechner zu programmieren, solltest du mal nen Blick werfen. Dein Taschenrechner ist nämlich sehr Fehleranfällig. Ausserdem kann er lediglich die vier Grundrechenarten und mit zwei Zahlen rechnen.
Die nächste Stufe wäre dann halt ein Parser für mathematische Formeln, was sicher auch ein interessantes Projekt sein dürfte.
Devil0s is offline  
Thanks
1 User
Old 03/22/2013, 21:32   #3
 
elite*gold: 0
Join Date: Jan 2011
Posts: 362
Received Thanks: 41
Ja würde ich bald mit anfangen, ist ja auch nur ein simples ding schnell im unterricht zusammen gefriemelt, zurzeit sitze ich an der aufgabe conways game of life zu programmieren
Rullx3 is offline  
Old 03/23/2013, 13:54   #4
 
elite*gold: 0
Join Date: Mar 2013
Posts: 116
Received Thanks: 32
Sie sind ziemlich gut Progammierung
trussik is offline  
Reply


Similar Threads Similar Threads
Simple Composition Calculator
09/20/2006 - CO2 Exploits, Hacks & Tools - 9 Replies
I maked i simple tool in .NET 2 C# You need Framework .NET2! New English Version



All times are GMT +2. The time now is 15:04.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.