Concate string

Program:

#include<stdio.h>
int main()
{
char s1[50],s2[30];
int len1,len2,i,j;
printf("Enter first string: ");
scanf("%s",s1);
printf("Enter second string: ");
scanf("%s",s2);
len1=0,len2=0;
while(s1[len1]!='\0')
{
len1++;
}
while(s2[len2]!='\0')
{
len2++;
}
for(j=0,i=len1;j<=len2;i++,j++)
{
s1[i]=s2[j];
}
printf("After Concatenation : %s",s1);
return 0;
}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...