38) C PROGRAM TO CONCATENATE OF TWO STRING
LOGIC:- Take any two strings,either directly or by user.Now for concatenate there are many ways which is shown in example.
EXAMPLE 1 :- BY USING STRCAT() BUILT-IN FUNCTION
EXAMPLE 2 :- WITHOUT USING BUILT-IN FUNCTION
EXPLANATION:- This program also created by using a function in which we apply the same logic.Here We use a for loop it can be done by using while loop also.In first for loop all character of string is assign in new string s3.So similarly we can assign the all characters of string s2 in string s3,But here is a problem if we try similar way then only string s2 is present in string s3 so to solve this problem the for loop is start with the size of s1 and run it atleast the size of s2 is not come.
EXAMPLE 3 :- BY USING POINTER
New Things:- this time we can take the string from user
LOGIC:- Take any two strings,either directly or by user.Now for concatenate there are many ways which is shown in example.
EXAMPLE 1 :- BY USING STRCAT() BUILT-IN FUNCTION
EXAMPLE 2 :- WITHOUT USING BUILT-IN FUNCTION
EXPLANATION:- This program also created by using a function in which we apply the same logic.Here We use a for loop it can be done by using while loop also.In first for loop all character of string is assign in new string s3.So similarly we can assign the all characters of string s2 in string s3,But here is a problem if we try similar way then only string s2 is present in string s3 so to solve this problem the for loop is start with the size of s1 and run it atleast the size of s2 is not come.
EXAMPLE 3 :- BY USING POINTER
New Things:- this time we can take the string from user
Comments
Post a Comment