Created
February 17, 2019 19:27
-
-
Save leovarmak/5c67b0c54be6ec2bf19a2443538fade9 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 <string.h> | |
int main(){ | |
char string[100]; | |
char alphabets[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; | |
int i, j, first_string_size = 0, second_string_size = 0; | |
printf("\nEnter first string: "); | |
fgets(string, sizeof string, stdin); | |
for (i = 0; i < strlen(string); i++){ | |
for (j = 0; j < sizeof alphabets; j++) { | |
if (string[i] == alphabets[j]) { | |
first_string_size = j + 1 + first_string_size; | |
} | |
} | |
} | |
printf("Enter second string: "); | |
fgets(string, sizeof string, stdin); | |
for (i = 0; i < strlen(string); i++){ | |
for (j = 0; j < sizeof alphabets; j++) { | |
if (string[i] == alphabets[j]) { | |
second_string_size = j + 1 + second_string_size; | |
} | |
} | |
} | |
if(first_string_size > second_string_size){ | |
printf("\nFirst string is bigger\n"); | |
} else if (first_string_size == second_string_size) { | |
printf("\nBoth are of same size\n"); | |
} else { | |
printf("\nSecond string is bigger\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment