9.4.20

string concatenation wihtout using strcat()


STRING CONCATENATION WITHOUT USING STRCAT()
#include <stdio.h>
int main()
{
    char st1[30],st2[30];
    int l1,l2,i;
    puts("enter string 1:");
    gets(st1);
    puts("enter string 2:");
    gets(st2);
    for(l1=0;st1[l1]!=0;l1++)
        for(l2=0;st1[l2]!=0;l2++)
    if(l1!=l2)
    {

        printf("not same");
        exit(0);

    }
    for(i=0;i<l1;i++)
        if(st1[i]!=st2[i])
        break;
    if(i==l1)
        printf("same");
    else
        printf("not same");
return 0;
}
OUTPUT
               Enter a string 1: siri
Enter a string 2: sana
Not same


No comments:

Post a Comment

JAVA program pattern 2

import java.util.Scanner; public class pattern3 { public static void main(String args[]) { int i,j; Scanner sc=new Scanner(System.in); Syste...