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; } autograderIncorrect 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started