applying subprogramcalls in the main program

can someone help me with this.. i'm quite new in C++.. my problem here is that my instructor wanted me to demonstrate or apply calling for subprograms in the main program, and i really dont know how to do it.. i have done the code here and i already compiled it successfully without errors

#include <iostream>
#include <string>

using namespace std;

int main()
{
const int SIZE = 1000;
char name1[SIZE], name2[SIZE];
int a, b;


cout << "Enter a name: ";
cin.getline(name1, SIZE);
a=strlen(name1);


cout << "Enter another name: ";
cin.getline(name2, SIZE);
b=strlen(name2);
cout<<" " << endl;

if(a>b)
{
system("cls");
cout<<"My name is " << name1 << endl;
cout<<"Length: " << a << endl;
cout<<" " << endl;
cout<<"My name is " << name2 << endl;
cout<<"Length: " << b << endl;
}

else if(a<b)
{
system("cls");
cout<<"My name is " << name2 << endl;
cout<<"Length: " << b << endl;
cout<<" " << endl;
cout<<"My name is " << name1 << endl;
cout<<"Length: " << a << endl;
}

else
{
system("cls");
cout<<"The names: " << name1 <<" and " << name2 <<" have the same character length of " << a << endl;
}
cout<<" " << endl;

return 0;
}
Topic archived. No new replies allowed.