flames match finding program. can anyone reduce it's no of lines?

//flames programming using pointers
#include<iostream.h>
#include<conio.h>
#include<string.h>
void exchange(char *,char *,int,int,int,int,int *);
int main()
{
char you[20],partner[20],c[20],d[20],*p,*q;
int a,b,e,i,j,*z;
clrscr();
cout<<"PROGRAM to find your FLAMES match"<<endl<<"Done by N.SURRENDHARAN of MECHATRONICS ENGINEERING in Kongu engineering college";
cout<<endl<<"Enter your name without space:";
cin>>you;
cout<<endl<<"Enter your partner name without space:";
cin>>partner;
strcpy(c,you);
strcpy(d,partner);
a=strlen(you);
b=strlen(partner);
for(i=0;i<strlen(c);i++)
{
for(j=0;j<strlen(d);j++)
{
if(c[i]==d[j])
{
p=&c[i];
q=&d[j];
z=&i;
exchange(p,q,i,j,a,b,z);
break;
}
}
}
a=strlen(c);
b=strlen(d);
e=a+b;
cout<<endl<<"mismatching elements"<<endl<<e<<endl<<c<<endl<<d<<endl;
if(e==2||e==4||e==7||e==9||e==15||e==20)
{cout<<"you both are enemies";}
else if(e==3||e==5||e==14||e==16)
{cout<<"you both are friends";}
else if(e==10||e==13||e==19)
{cout<<"you both are lovers";}
else if(e==8||e==12||e==17)
{cout<<"you both are in affection";}
else if(e==6||e==11||e==18)
{cout<<"you both are married";}
else
{cout<<"you both are sister and brother";}
getch();
return 0;
}
void exchange(char *p,char*q,int i,int j,int a,int b,int *z)
{
for(;i<a&&*p!='\0';i++)
{
*p++=*(p+1);
}
for(;j<b&&*q!='\0';j++)
{
*q++=*(q+1);
}
(*z)--;
}
Why would you want to? The code is such an unreadable mess that nobody can understand what it does. Adding lines, including blank lines and especially comments, and coming up with meaningful variable names would make this code much more maintainable. Smart employers aren't looking for the most compact code--they are looking for the most maintainable code.
Topic archived. No new replies allowed.