Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!