Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Wheres my Code error? It says free() isnt correct and im getting segmentation fa

ID: 3657126 • Letter: W

Question

Wheres my Code error? It says free() isnt correct and im getting segmentation fault... Its in C NOT C++

#include<stdio.h>

void sort(int sorted[],int size);

int main()

{

int *arr;

int N,num,count;

printf("Enter how many integer you want to enter: ");

scanf("%d",&N);

int new[N];

int i;

for(i=0;i<N;i++)

{

printf("Enter integer %d: ", i+1);

scanf("%d",&arr[i]);

free(i);

}


sort(arr,N);

printf(" Number frequency");


for(i=0;i<N;)

{

count=1;

num=arr[i];

printf(" %d ",arr[i]);

while(arr[++i]==num){

count++;

}

printf("%d",count);

}

getchar();

return 0;

}

void sort(int sorted[],int size){

int i,j,temp;

for(i=0;i<size-2;i++)

{

for(j=0;j<size-1;j++)

{

if(sorted[j]<sorted[j+1]){

temp=sorted[j];

sorted[j]=sorted[j+1];

sorted[j+1]=temp;

}

}

}

return;

}

Explanation / Answer

PLease give the definition of the free() in the program.You dint do that

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote