Learn ABC in C language?

2

How do I in this code, when it enters a letter read by the keyboard with the scanf of type (char) it repeats until the Z?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char c;

    /*for (c= 'A'; c<='Z'; c++){
        printf("Letra =  %c\n", c);
    } */
    system("pause");
    return 0;
}
    
asked by anonymous 13.05.2015 / 15:24

1 answer

2

Perform scanf of the letter, and suppress counter initialization in for .

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char c;
    char limit;
    scanf("%c", &c);

    if(c >= 65 && c <= 90){
         limit = 'Z';
    }else{
         limit = 'z';
    }

    for (; c<=limit; c++){
        printf("Letra =  %c\n", c);
    }
    system("pause");
    return 0;
}
    
13.05.2015 / 15:29