Answer:
Check the explanation
Step-by-step explanation:
C++ code:
#include <bits/stdc++.h>
using namespace std;
string convert(string s){
int l=s.length();
string ans=" hours";
if(l==7){
if(s[5]=='a'||s[5]=='A'){
ans[0]='0';
ans[1]=s[0];
ans[2]=s[2];
ans[3]=s[3];
else{
if(s[6]=='a'||s[6]=='A'){
ans[0]=s[0];
ans[1]=s[1];
ans[2]=s[3];
ans[3]=s[4];
return ans;
}
int main(){
cout<<"Enter time: ";
string s;
getline(cin,s);
cout<<"Corresponding military time is "<<convert(s)<<endl;
return 0;
}