This example helps determine given two strings S1 and S2, whether one string is an anagram of the other. An anagram of a string is a string obtained by permuting the letters of a string.
This example helps determine given two strings S1 and S2, whether one string is an anagram of the other. An anagram of a string is a string obtained by permuting the letters of a string.
String comparison is done using strcmp(). The function takes two strings as parameters. The function returns 0 if the strings are same.
Null-terminated Strings in C++ are implemented using character arrays. The last element of the array-string is terminated by a null character '\0'.
This example shows how to iterate through an array and search for a particular entry. We set a flag if we find the particular value.
The program simply declares a 1-D array of 5 integers and initializes it. Then, it uses for-loop to traverse each element and adds it into result. Result finally returns the sum of all elements.
An array is simply a collection of similar data items. You can see in this example, an array of int type is declared. It consists of 5 elements stored sequentially in the memory.
This example sorts the array in ascending order using the inbuilt sort function and then outputs the last element of array as it will be the maximum of all.