if-else

Páginas: 4 (811 palabras) Publicado: 2 de marzo de 2014
PROGRAMAS DE IF, IF-ELSE
PROGRAMA 1: COMPARA UN NÚMERO CON 0
1. #include
2. main()
3. {
4. float numero;
5. printf ("Programa que compara numeros");
6. printf ("\n Dame el numero ahconvertir \n");
7. scanf ("%f", &numero);
8. if (numero >0.0 )
9. {
10. printf ("\n\t\t %.2f es positivo\n", numero);
11. }
12. if (numero 0.0) entonces escribir “El numero es positivo”
7.si(num=0.0) {
18. x1= (-b + sqrt(d)) /(2*a);
19. x2= (-b - sqrt(d)) /(2*a);
20. printf ("la raiz 1 = %.2f La raiz 2= %.2f \n", x1, x2);
21. }
22. Else {
23. printf("La raiz es imaginaria x1 =x2\n %f = %f", d );
24. }
25. }
26. Else {
27. printf("\n\t a debe ser difente de 0, ecuacion indeterminada.");
28. }
29. }
30.
31. PSEUDOCODIGO
1. Inicio
2. Declarar enteros yflotantes a,b,c,d, x1,x2
3. Escribir “ecuación general”
4. Escribir “introducir el valor de a”
5. Leer a
6. SI (a!=0.0) entonces Escribir "introducir b y c” , Leer c y b , d= b2 - 4ac
7. si(d>=0.0)entonces x1= (-b + √d / (2a), x2= (-b - √d / (2a), Escribir “la raiz 1=x1 La raiz 2=x2)
8. Si no entonces escribir "La raiz es imaginaria x1 = x2
32. La raiz es imaginaria x1 = x2
33. 9. Sino entonces escribir “a debe ser difente de 0, ecuacion indeterminada"
34.
10. fin
35.
36.
37.
38.
39.
40.
41.
42. PROGRAMA 4: AREAS
1. #include
2. #include
3. #define PI3.1416
4. main ()
5. {
6. float i, a, b, c, d,f=2,g ;
7. printf (" Presione la tecla segun la figura que desea... AREA DE UN \n");
8. printf (" \n 1=CUADRADO \n 2=RECTANGULO \n 3=TRIANGULO \n4=CIRCULO ");
9. scanf ("%f", &i);
10. if (i==1)
11. {
12. printf (" \n AREA DE UN CUADRADO");
13. printf("\n Introducir el valor del lado \t\t");
14. scanf ("%f", &a);
15.c=pow(a,f);
16. printf ("\n EL AREA DEL CUADRADO ES : %f", c);
17. }
18. if (i==2)
19. {
20. printf ("\nAREA DEL RECTANGULO");
21. printf("\nIntroducir el valor de la altura \t\t");
22....
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • If Else
  • taller if else swich
  • Sentencia if/else
  • programacion if else
  • Taller Programación Basica If Else
  • Sentencia if else
  • ejercicios de if-else c#
  • Clase de If Else

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS