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>
bool isValidAbbreviation(char c1,char c2,char c3,char c4){
    int chk,flag=0;
    cin>>noskipws;
     char word='a';
    for(chk=1;word!='\n';chk++){
        
        
    for(cin>>word;((word!=' ')|| (word!='\n'));cin>>word){
        
        int ascii=word;
               
            if(chk==1){
                int ascii_1=c1;
                if(ascii_1>=97){
                    if(ascii>=97 && word==c1){
                        flag=1;
                        continue;
                    }
                    if(ascii<97 && word==c1){
                        flag=1;
                        continue;
                    }
                }
                else{
                    if(ascii>=97 && word==c1){
                        flag=1;
                        continue;
                    }
                    if(ascii<97 && word==c1){
                        flag=1;
                        continue;
                    }
                }
                
            }
             if(chk==2){
                int ascii_1=c2;
                if(ascii_1>=97){
                    if(ascii>=97 && word==c2){
                        flag=2;
                        continue;
                    }
                    if(ascii<97 && word==c2){
                        flag=2;
                        continue;
                    }
                }
                else{
                    if(ascii>=97 && word==c2){
                        flag=2;
                        continue;
                    }
                    if(ascii<97 && word==c2){
                        flag=2;
                        continue;
                    }
                }
                
            }

            if(chk==3){
                int ascii_1=c3;
                if(ascii_1>=97){
                    if(ascii>=97 && word==c3){
                        flag=3;
                        continue;
                    }
                    if(ascii<97 && word==c3){
                        flag=3;
                        continue;
                    }
                }
                else{
                    if(ascii>=97 && word==c3){
                        flag=3;
                        continue;
                    }
                    if(ascii<97 && word==c3){
                        flag=3;
                        continue;
                    }
                }
                
            }

            if(chk==4){
                int ascii_1=c4;
                if(ascii_1>=97){
                    if(ascii>=97 && word==c4){
                        flag=4;
                        continue;
                    }
                    if(ascii<97 && word==c4){
                        flag=4;
                        continue;
                    }
                }
                else{
                    if(ascii>=97 && word==c4){
                        flag=4;
                        continue;
                    }
                    if(ascii<97 && word==c4){
                        flag=4;
                        continue;
                    }
                }
                
            }
            




            }          
            
        }
        if(flag==4)
        return true;
        else
        return false;
   }

    


int main(){
    char ch1,ch2,ch3,ch4;
    cin>>ch1>>ch2>>ch3>>ch4;
    if(isValidAbbreviation(ch1,ch2,ch3,ch4)==true)
    cout<<"yes";
    else
    cout<<"no";
    return 0;
}

Grading criterion: Letter case
Rating A: Correctly checks the case of a letter and changing it accordingly

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