Created
February 11, 2018 21:04
-
-
Save sojohnnysaid/5fd7e9e1a97f0d7b81036a2334f8ed37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cs50.h> | |
#include <string.h> | |
int main(void) | |
{ | |
// take the user's name and capitalize all letters | |
string name = get_string("enter your name: "); | |
printf("All Uppercase: "); | |
// output each character of the user's name | |
for (int i = 0; i < strlen(name); i++) | |
{ | |
int is_lower_case = (name[i] >= 'a') && (name[i] <= 'z'); | |
if (is_lower_case) | |
{ | |
int magic_number = 'a' - 'A'; // always 32 no matter what letter we use | |
printf("%c", name[i] - magic_number); | |
} | |
else | |
{ | |
printf("%c", name[i]); | |
} | |
} | |
printf("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment