Write a Program in C that reads two strings. The program should work in Linux an
ID: 2247124 • Letter: W
Question
Write a Program in C that reads two strings. The program should work in Linux and wrote in C not C++. It should give a count for the data below.
Position Count with case and no case. Also, a Contain Count with case and no case.
Output:
Books
Goblins
Position: case: 1 nocase: 1
Contains: case: 3 nocase: 4
--------------------------------------------
goodness
BoGo
Position: case: 1 nocase: 1
Contains: case: 4 nocase: 5
-------------------------------------------
abc abc abc
Abc aBc abC
Position: case: 8 nocase: 11
Contains: case: 22 nocase: 31
---------------------------------------------
BOGO Sale
Oreo Blizzard
Position: case: 2 nocase: 3
Contains: case: 8 nocase: 10
---------------------------------------------
If[]12
So;=11
Position: case: 1 nocase: 1
Contains: case: 2 nocase: 2
Explanation / Answer
#include<stdio.h>
#include<string.h>
void main()
{
char string1[20],string2[20];
int i,j,pos;
memset(string1,0,20);
memset(string2,0,20);
printf("enter the first string : ");
scanf("%s",string1);
printf("enter thesecond string:");
scanf("%s",string2);
printf("first string = %s ",string1);
printf("second string =%s ",string2);
for(i=0;string1[i] !='';i++)
{
;
}
pos=i;
for(j=0;string2[j] !=''; i++)
{
string[i]=string2[j++];
}
string1[i]=string2[j++];
}
string1[i]='';
printf("concatenated string =%s ",string1);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.