Your IP : 216.73.216.40


Current Path : /var/www/html/venkat/old/old/
Upload File :
Current File : /var/www/html/venkat/old/old/lit2015044_2.c

#include<stdio.h>

int length(char*);
void concate(char*,char*);
int compare(char*,char*);
int main()
{
 char str1[1000],str2[1000];
 int l1,i,l2;
 printf("enter first string\n");
 gets(str1);
 printf("enter another string\n");
 gets(str2);

 l1 = length(str1);
 l2 = length(str2);

// printf("%d %d",l1,l2);
 if(l1 != l2)
 {
  concate(str1,str2);
   printf("%s",str1);
 }
 else
{
 i= compare(str1,str2);
 if(i==0)
 {
   concate(str1,str2);
   printf("%s",str1);

 }
 else
 {
   printf("%s",str2);
 }
}
 return 0;
}

int length(char*p)
{
 int count=0,i=0;
 while(p[i] !='\0')
 {
   count++;
   i++;
 }
 return count;
}
void concate(char*p,char*q)
{
 while(*p !='\0')
 {
   *p++;
 }
 while(*q != '\0')
 {
   *p = *q;
   *p++;
   *q++;
 }
 *p = '\0';

}
int compare(char*m,char*n)
{
  int i=0,k=5;
  while(m[i]!= '\0')
  {
    if(m[i]!= n[i])
     {
      return 0;
     }
    else
     {
      i++;
     }
  }
 // printf("successfully");
 return k;
  
}