Question: hello people MY code is below and there is no error but i dont really know whats wrong with my codes when i run it
hello people
MY code is below and there is no error
but i dont really know whats wrong with my codes
when i run it it paint the circle (which it correct )
and then it take only one string and stop
but it should take two from user and concatinate them
please help
(IN C PROGRAMMING LANGUAGE )
#include
#include
#include
#include
void circle(int n){
int i,j;
for (i=0; i<=2*n; i++)
{
for (j=0; j<=2*n; j++)
{
double distance = sqrt((double)(i-n)*(i-n) + (j-n)*(j-n));
if (distance>n-0.5 && distance { printf("*"); } else { printf(" ");} } printf(" "); } } char *strCat(char *s1, char *s2){ int i,j=0; int len = strlen(s1); for(i=len; s2[j]!='\0';i++ ){ s1[i]=s2[j]; j++; } s1[i]='\0'; return s1; } int countS1(char *s1, char *s2) { int l1 = strlen(s1); int l2 = strlen(s2); int count = 0, i; for(i = 0; i <= (l2-l1);i++) { int j; for (j = 0; j < l1 ; j++) if (s2[i+j] != s1[j]) break; if (j == l1 ) { count++; j = 0; } } return count; } int main() { int rad; char *s1, *s2; printf("Enter radius of circle: "); scanf("%d", &rad); circle(rad); printf("Enter string one :"); scanf("%s", s1); printf("Enter string two :"); scanf("%s",s2); printf(" Number of times a substring (%s) is present in string (%s) is %d ", s1,s2, countS1(s1,s2)); printf("Concatination of two string : %s ", strCat(s1,s2)); return 0; } (in c langauage )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
