Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my code and under it will be autograder can someone please show me what is wrong with the code. #include #include int main()

This is my code and under it will be autograder can someone please show me what is wrong with the code.

#include

#include

int main()

{

printf("Enter the length of the string:");

int n,i=0;

scanf("%d",&n);//reading input

//you can modify this line

//int *a = (int *)malloc(sizeof(int)*n+2);

char *a = (char *)malloc(sizeof(char)*n);//declaration

//dynamic allcoation

printf("Enter the string:");

while(i

{

scanf("%c",(a+i));

i++;

}

char c;

printf("Enter search character:");

scanf("%c",&c);

i=0;

int count=0;

//finding character cound

while(i

{

if(*(a+i)==c)count++;

i++;

}

printf("Characters found: %d ",count);

return 0;

}

autograder

Incorrect Output Input: 37 absence makes the heart grow fonder a Output>>>>>>>>>: 'Enter the length of the string:Enter the string:Enter search character:Characters found: 3 ' Expected Output: 'Enter the length of the string: Enter the string: Enter search character: Characters found: 3 ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Incorrect Output Input: 35 rabota ne volk - v les ne ubezhit e Output>>>>>>>>>: 'Enter the length of the string:Enter the string:Enter search character:Characters found: 4 ' Expected Output: 'Enter the length of the string: Enter the string: Enter search character: Characters found: 4 ' 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago