You are on page 1of 2

Assignment No.

6
Question 1:

We will input up to 15 random characters as an input. Your task is to do the following:

1. Display the number of upper case letters

2. Display the number of lower case letters

3. Display that how many characters were between 0-9 (both inclusive)

4. Display how many characters other than letters and numbers are present

5. Display the length of the input by the user.

6. Display the ASCII value of the maximum character (along with that character)

7. Check whether the input is a “palindrome” or not.

Input:

Iramn@2bAbas?0

Output:

Upper Case: 2

Lower Case: 8

0-9: 2

Other: 2

Length: 14
Question 2:

Compare two character arrays (strings). For this purpose, see the explanation given below: Start
comparing the first character of each string. If they are equal to each other, it continues with the
following pairs until the characters differ or until a terminating null character is reached. This operation
does not take into account the length of the strings.

Display an integral value indicating the relationship between the strings:

-2 String1 terminated first


-1 the first character that does not match has a lower value in string1 than in string2 based
on ACII value
0 the contents of both strings are equal
1 the first character that does not match has a greater value in string1 than in string2 based
on ACII value
2 String2 terminated first

Input:

String1: section

String2: sectionA

Output:

-2

Input:

String1: finalsarecoming

String2: finalsarenotcoming

Output:

-1

You might also like