Write a program to concentrate two string without library function
strcat .
#include<stdio.h>
#include<conio.h>
Main()
{
Int len
a=0,lenb=0, i;
Char a[50] ,
b[50];
Printf(“enter
first string”);
Gets(a);
Printf(“enter second
string”);
Gets(b);
/* finding
string length of first string */
For (i=0; a[i]!=’\0’ ; i++)
Lena=lena+1;
/* finding
string length of second string */
For (i=0; b[i]!=’\0’ ; i++)
Lenb=lenb+1;
/* string
concatenate */
For (i=0; i<lenb; i++)
a[lena+i] = b[i];
printf(“in the
concatenate string is %s”,a);
}
Write a
program to check weather a string is palindrome or not without using library
function.
#include<stdio.h>
#include<conio.h>
Main
()
{
Char st[40];
Int len=0, i=0, flag=1;
Printf(“enter a string”);
Gets(st);
For(i=0; st[i]! = ‘\0; i++)
Len=len + 1;
For (i=0; i<=len/2; i++)
{
If(st[i]! = st [len-1-i])
{
Flag =0
Break:
}
}
If (flag==1)
Printf(“the
given string is palindrome”);
Else,
Printf(“the
given string is not palindrome”);
}
Write a
program to read 10 string & display.
#include<stdio.h>
#include<conio.h>
Main ()
{
Char a [10] [20];
Int i;
For (i=0; i<10; i++)
{
Printf(“in enter %d string”, i+1);
Gets(a[i]);
}
/* display 10 string */
For (i=0; i<10; i++);
Printf(“in %s”, a[i]);
Gets();
No comments:
Post a Comment