Problem: At college X, students and professors often use abbreviations for long titles of academic papers and projects. In this problem, you are asked to verify whether a given abbreviation matches the first letters of the words in a string, ignoring case. The abbreviation is valid only if it follows the exact order of the first letters of each word.

Examples:

For the words:
United Nations
united nations
United nations
united Nations

Valid abbreviations are:
UN, un, Un, uN

For the words:
Machine Learning college X

Valid abbreviations are:
MLIB (or any combination of upper and lowercase letters in the same order, such as mLiB).

Your Task

Main Program:

Write a C++ program that accepts four characters from the user and stores them in four character variables. Pass these characters to a function named isValidAbbreviation, which returns true if the abbreviation is valid, otherwise returns false. In the main function, print "yes" or "no" (lowercase letters) based on the returned value.

isValidAbbreviation Function:

1. Accept the words character by character as input.
2. Check whether the first letter of each word matches the corresponding abbreviation character (case insensitive).
3. Return false if there is any mismatch.
4. Return true if the entire abbreviation is correct.

To read character sequences with spaces:
First write:
cin >> noskipws;

Then a loop like the following may be used:
for (cin >> c; c != '\n'; cin >> c)

Output Format:

Print:
yes
or
no

accordingly.

Note:

- Do not print any extra messages such as:
  cout << "Enter a number";
  cout << "The computed answer is";
- Use cout only to print the final output.
- Do not print unnecessary spaces.
- Do not hard-code the solution.
- If any test case passes by simply printing with cout and without logic, marks will not be awarded.

Student submission:
#include<simplecpp>;
char isValidAbbreviation(char a1,char a2,char a3,char a4){
if(a1<='Z'&&a1>='A'){
    a1 = a1 -('A'-'a');
}
if(a2<='Z'&&a2>='A'){
    a2 = a2 -('A'-'a');
}
if(a3<='Z'&&a3>='A'){
    a3 = a3 -('A'-'a');
}
if(a4<='Z'&&a4>='A'){
    a4 = a4 -('A'-'a');
}
int r1=0;
char w1;
    cin>>w1;
    if(w1==a1||w1== a1 + 'A'-'a'){
      r1=1;
    }

for (int i=0;i>=0;i++){
    char w;
    cin>>w;
    if (w =='\n'){
        break;
    }
}
int r2=0;
char w2;
    cin>>w2;
    if(w2==a2||w2== a2 + 'A'-'a'){
      r2=1;
    }
for (int i=0;i>=0;i++){
    char w;
    cin>>w;
    if (w =='\n'){
        break;
    }
}


int r3=0;
char w3;
    cin>>w3;
    if(w3==a3||w3== a3 + 'A'-'a'){
      r3=1;
    }
for (int i=0;i>=0;i++){
    char w;
    cin>>w;
    if (w =='\n'){
        break;
                                                                                                                                                                                          31,1          Top

  }
}


int r4=0;
char w4;
    cin>>w4;
    if(w4==a4||w4== a4 + 'A'-'a'){
      r4=1;
    }
for (int i=0;i>=0;i++){
    char w;
    cin>>w;
    if (w =='\n'){
        break;
    }
}

int ans=0;
if(r1==1&&r2==1&&r3==1&&r4==1){
ans =1;
}
else {
    ans=0;
}

return ans ;
}





main_program{
    char a1;
    char a2;
    char a3;
    char a4;
    cin>>a1>>a2>>a3>>a4;



int value = isValidAbbreviation(a1,a2,a3,a4);

if(value == 1){
    cout<<"yes";
}
if(value==0){
    cout<<"no";
}

}
                                                                                                                                                                                          101,1         Bot

Grading criterion: function: returning value
Rating A: Correctly returns True or False. Should return false if more than four words in the sentence.

Rating B: some issue
Rating C: major issue
Rating D: 0
Assigned grade: B