Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
531 B
1
Indexable
Never
#include <stdio.h>
#include <string.h>

int main() {
    char input[100], output[100];
    int i, j = 0;
    
    printf("Enter a string: ");
    fgets(input, sizeof(input), stdin);
    input[strcspn(input, "\n")] = '\0'; // remove newline character
    
    for(i = 0; input[i] != '\0'; i++) {
        if(input[i] >= 'A' && input[i] <= 'Z') { // check if uppercase letter
            output[j++] = input[i];
        }
    }
    output[j] = '\0';
    
    printf("Result: %s\n", output);
    
    return 0;
}