0

this morning I made a simple class program, with if and else, but when compiling, a certain part of the program is not displayed on the screen. I have separated them and they work correctly. The exercise is based on creating a program that orders three numbers from highest to lowest and on the other hand, with two letters that you write to say if they are minus or capitalus.

This is the code:

#include <stdio.h>

int main(){
    
    int num1, num2, num3;
    char letra1, letra2;    
    
    printf("Dame tres numeros: ");
    scanf("%d %d %d", &num1, &num2, &num3);
    
    
    
    if(num1<=num2 && num2<=num3){
        printf("Mayor: %d, Mediano: %d, Menor: %d.\n", num3, num2, num1);
    }else{
        if(num1<=num3 && num3<=num2){
            printf("Mayor: %d, Mediano: %d, Menor %d.\n", num2, num3, num1);
        }else{
            if(num2<=num1 && num1<=num3){
                printf("Mayor: %d, Mediano: %d, Menor: %d.\n",  num3, num1, num2);
            }else{
                if(num2<=num3 && num3<=num1){
                    printf("Mayor: %d, Mediano: %d, Menor: %d.\n", num1, num3, num2);
                }else{
                    if(num3<=num2 && num2<=num1){
                        printf("Mayor: %d, Mediano: %d, Menor: %d.\n", num1, num2, num3);
                    }else{
                        if(num3<=num1 && num1<=num2){
                            printf("Mayor: %d, Mediano: %d, Menor: %d.\n", num2, num1, num3);
                        }
                    }
                }
            }
        }
    }
    printf("Dame dos letras: ");
    scanf("%c %c",&letra1,&letra2);
    
    if(letra1>= 'a' && letra1 <= 'z' && letra2>='a'&&letra2<='z'){
        printf("Las letras %c y %c son minusculas.\n", letra1, letra2);
    }else{
        if(letra1>='a'&&letra1<='z'&&letra2>='A'&&letra2<='Z'){
            printf("La letra %c es minuscula y la letra %c es mayuscula.\n", letra1, letra2);
        }else{
            if(letra1>='A'&&letra1<='Z'&&letra2>='a'&&letra2<='z'){
                printf("La letra %c es mayuscula y la letra %c es minuscula.\n", letra1, letra2);
            }else{
                if(letra1>='A'&&letra1<='Z'&&letra2>='A'&&letra2<='Z'){
                    printf("Las letras %c y %c son mayusculas.\n", letra1, letra2);
                }
            }
        }
    }
    
    return 0;
}
NineBerry
  • 26,306
  • 3
  • 62
  • 93
  • 1
    Is this C or C++? Please only tag the right language – shree.pat18 Jun 11 '21 at 13:52
  • "a certain part of the program is not displayed on the screen" is not a very clear problem description. We can't see your screen. It would be more helpful to describe what input you gave and what the output was. –  Jun 11 '21 at 13:55
  • Probably `letra1` is reading the carriage return from the previous call to `scanf`. Try writing `scanf(" %c %c",&letra1,&letra2);`, with and extra space before `%c`. – rodrigo Jun 11 '21 at 13:59
  • If your assignment is to order numbers, than you didn't really do the assignment. Instead of ordering the numbers you just print different texts by checking conditions, which is not really ordering... – Brecht Sanders Jun 11 '21 at 14:02
  • When you have 3 or more items that need to be sorted, it is probably simpler to store them in an array, and use bubble sort to sort them than using a lot of `if`/`else`. – HAL9000 Jun 11 '21 at 14:35

0 Answers0