'Syntax error in definition of swap function

// swap
#include<stdio.h>
int swap(int, int);
int main(){
    int n = 7, m = 9;
    swap(n,m);
 }

swap (a,b){ // I get error here!
    int c = a;
    a = b;
    b = c;
    printf("%d and %d ", a,b);

 }

I am stuck on an error. The error message is:

[Error] expected constructor, destructor, or type conversion before '(' token
c


Solution 1:[1]

You forgot to enter return type and parameter types

#include<stdio.h>
int swap(int, int);
int main(){
int n = 7, m = 9;
swap(n,m);
}

int swap (int a,int b){ // You forgot return type  and parameter type
int c = a;
a = b;
b = c;
printf("%d and %d ", a,b);

}

Since you are a beginner, read The C Programming Languages Second Edition book by Dennis M Ritchie, free pdf may be online :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 The Inventor