My issue
sol.c:55:5: error: redefinition of ‘main’
55 | int main() {
| ^~~~
sol.c:29:5: note: previous definition of ‘main’ with type ‘int()’
29 | int main(){
| ^~~~ . this is the problem I’m getting in this code and in last module also.
My code
#include<stdio.h>
void swap(int* xp, int* yp){
int temp= *xp;
*xp=*yp;
*yp=temp;
}
void selectionSort(int arr[], int n) {
int i,j,min_idx;
for( i=0; i<n-1; i++){
min_idx=i;
for(j=i+1; j<n; j++){
if(arr[j]<arr[min_idx]){
min_idx=j;
}
}
swap(&arr[min_idx], &arr[i]);
}
}
void printArray(int arr[], int size){
for(int i=0; i<size; i++){
printf("%d", arr[i]);
}
printf("\n");
}
int main(){
int n;
scanf("%d", &n);
int arr[n];
for(int i=0; i<n; i++){
scanf("%d", &arr[i]);
}
selectionSort(arr,n);
printArray(arr,n);
}
Learning course: Data structures & Algorithms lab
Problem Link: https://www.codechef.com/learn/course/muj-dsa-c/MUJDSAC23/problems/SESO41