commit 4b63152ebad97919a8a1590a3789f6cec494891c
parent 4cd65ea0d5e5c82075c27f4175665b773ff06636
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date: Thu, 19 Nov 2020 23:16:08 -0300
Added ej5.c
Diffstat:
2 files changed, 27 insertions(+), 61 deletions(-)
diff --git a/95.11/guia01/ej5.c b/95.11/guia01/ej5.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <math.h>
+
+int main( void ) {
+
+ float raiz = 25;
+ float inv = 4;
+
+ printf("sqrt(%.2f) = ", raiz);
+
+ if(raiz > 0)
+ raiz = sqrt(raiz);
+ else
+ return 1;
+
+ printf("%.2f\n", raiz);
+ printf("inv(%.2f) = ", inv);
+
+ if (inv != 0)
+ inv = 1/inv;
+ else
+ return 1;
+
+ printf("%.2f\n", inv);
+
+ return 0;
+}
diff --git a/95.11/guia03/ex13.c b/95.11/guia03/ex13.c
@@ -1,61 +0,0 @@
-// Reads a string from stdin and converts it to uppercase or lowercase
-// depending on an option readed from stdin
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#define MSG_STR_PROMPT "Introduzca una cadena:"
-#define MSG_FMT_PROMPT "Convertir a: (0 - MAYUSCULAS / 1 - MINUSCULAS)"
-#define MSG_FMT_ERR "Err: Formato incorrecto"
-
-#define MAX_STR_LEN 100
-
-typedef enum {
- FMT_MAYUSCULAS, FMT_MINUSCULAS
-} format_t;
-
-
-int main ( void ) {
-
-
- char buffer[MAX_STR_LEN];
- char str[MAX_STR_LEN];
- format_t format;
-
-
- printf(MSG_STR_PROMPT"\n>> ");
- fgets(buffer, MAX_STR_LEN, stdin);
- strcpy(str, buffer);
-
- printf(MSG_FMT_PROMPT"\n>> ");
- format = (getchar () - '0');
- if((format < 0) || (format > 1)) {
- fprintf(stderr, MSG_FMT_ERR"\n");
- return 1;
- }
-
- printf("La cadena ingresada: %sOpcion elegida: %d\n", str, format);
-
- int i, aux;
- switch(format)
- {
- case FMT_MAYUSCULAS:
- for(i = 0; (aux = str[i]) != '\n'; i++) {
- if(islower(aux))
- str[i] = toupper(aux);
- }
- break;
- case FMT_MINUSCULAS:
- for(i = 0; (aux = str[i]) != '\n'; i++) {
- if(isupper(aux))
- str[i] = tolower(aux);
- }
- break;
- }
-
- printf("%s", str);
- return 0;
-}