/***************************************************************************
* calculadora.c
*
* Simple calculadora que realiza las 4 operaciones basicas:
* suma, resta, multiplicacion y division. Free Software.
*
* Thu Nov 22 18:37:23 2007
* Copyleft <-C By Kerberos
* Email: kerberos_lite@yahoo.com.ar
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
int main()
{
float seleccion1;
float seleccion2;
int seleccion3;
float resultado;
int p;
printf ("
*************************
Calculadora Sencilla v1.1
*************************
");
principio:
printf ("Ingresa el tipo de operacion:
[1] Suma
[2] Resta
[3] Multiplicacion
[4] Division
");
scanf( "%i", &seleccion3 );
printf ("
Ingresa el primer numero:
");
fflush( stdout );
scanf( "%f", &seleccion1 );
printf ("Ingresa el segundo numero:
");
fflush( stdout );
scanf( "%f", &seleccion2 );
switch( seleccion3 )
{
case 1:
resultado = seleccion1 + seleccion2;
printf ("Resultado = %f
", resultado);
break;
case 2:
resultado = seleccion1 - seleccion2;
printf ("Resultado = %f
", resultado);
break;
case 3:
resultado = seleccion1 * seleccion2;
printf ("Resultado = %f
", resultado);
break;
case 4:
resultado = seleccion1 / seleccion2;
printf ("Resultado = %f
", resultado);
break;
}
printf( "
Deseas:
[1] Calcular Otro
[2] Salir
" );
fflush( stdout );
scanf( "%i", &p );
if ( p==1 )
{
printf ("
_____________________________________________________");
printf ("
");
goto principio;
}
else
{
return 0;
}
}
Comentarios sobre la versión: Versión 1 (0)
No hay comentarios