Dev - C++ - PROGRAMAR EN C. URGENTE

 
Vista:
sin imagen de perfil

PROGRAMAR EN C. URGENTE

Publicado por Carlos (2 intervenciones) el 09/04/2014 21:35:21
¿Alguien me puede programar esto en c? Se trata de un programa que si pulsas la opcion A te resuelva la ecuacion de segundo grado, si pulsas la opción B te calcule el volumen de un cono y sino que te salga del programa un mensaje gracioso. Hay que hacerlo con la sentencia switch.
Gracias.



MENU
====
A. Solution to ax2+bx+c=0
B. Volume of Cone
C. Print "funny" message

Choose your option:
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Makefile.win [Error] [clase] Error 1 (if this is the only error: please check your library includes)

Publicado por Carlos (2 intervenciones) el 09/04/2014 22:58:35
ME PODEIS DECIR QUE TENGO MAL?


ME SALE ESTE ERROR, AYUDA POR FAVOR URGENTE.
C:\Users\Carlos\Documents\Makefile.win [Error] [clase] Error 1 (if this is the only error: please check your library includes)



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
 
#include <math.h>
 
#define ROOT(a,b,c) (sqrt((b*b)-(4*a*c)))
#define PI 3.1416
 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
 
int main(int argc, char *argv[]) {
 
	int option=0;
	float a,b,c;
	float x,y;
	float r,h,volume;
	printf("MENU");
	printf("====");
	switch(option)
	{
		case 0:
			printf("A. solution to  ax2+bx+c=0");
			printf("Type coeficients:");
			scanf("%f,%f,%f",&a,&b,&c);
 
			if(a==0){
				printf("a have to be different to 0");
				return -1;
 
			}
			if((b*b-4*a*c)<0){
				printf("The value inside the root have to be positive or 0");
				return -2;
			}
 
		x=(-b+ROOT(a,b,c))/(2*a);
		y=(-b-ROOT(a,b,c))/(2*a);
		printf("\nSolution 1: %f",x);
		printf("\nSolution 2: %f",y);
 
 
		case 1:
			printf("B. solution to volumen of cone");
			printf("Please, enter the radius and the high separated by coma:");
			scanf("%f,%f",r,h);
			volume=(PI*r*r*h)/(3);
			printf("Volume:%f",volume);
 
		default:
			printf("F**K ME I'M ENGEENIER");
 
		}
 
	return 0;
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de JuanC

PROGRAMAR EN C. URGENTE

Publicado por JuanC (35 intervenciones) el 09/04/2014 23:44:25
te faltan los break; en cada case del switch...

Saludos, desde Baires, JuanC
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar