Given two strings. The task is to find the larger string without using built-in functions.
Input: GeeksforGeeks Geeks Output: GeeksforGeeks Input: GeeksForFeeks is an good Computer Coding Website It offers several topics Output: GeeksForFeeks is an good Computer Coding Website
- Take two strings in separate variables.
- Initialize the two count variables to zero.
- Use a for loop to traverse through the characters in the string and increment the count variables each time a character is encountered.
- Compare the count variables of both the strings.
- Print the larger string.
Below is the complete program based on the above approach:
Larger string is: GeeksForFeeks is an good Computer Coding Website
Program Explanation :
- User must enter two strings and store it in separate variables.
- The count variables are initialized to zero.
- The for loop is used to traverse through the characters in the strings.
- The count variables are incremented each time a character is encountered.
- The count variables are then compared and the larger string is printed.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course