Regarding Parameter in C (GCD of 2 Numbers)
-
Here is my Program In the line int GCD(num1,num2) I get the warning " warning: parameter names (without types) in function declaration [enabled by default]| " But if I use int GCD(int a,int b) the warning is not there. NOTE - In both cases the program runs perfectly. I am a newbie, so I would appreciate if someone helps me regarding this.... :) /* I am using mingw with code blocks */
#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
} -
Here is my Program In the line int GCD(num1,num2) I get the warning " warning: parameter names (without types) in function declaration [enabled by default]| " But if I use int GCD(int a,int b) the warning is not there. NOTE - In both cases the program runs perfectly. I am a newbie, so I would appreciate if someone helps me regarding this.... :) /* I am using mingw with code blocks */
#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
} -
So i need to specify that they are integers, right ? :)
-
So i need to specify that they are integers, right ? :)
-
Here is my Program In the line int GCD(num1,num2) I get the warning " warning: parameter names (without types) in function declaration [enabled by default]| " But if I use int GCD(int a,int b) the warning is not there. NOTE - In both cases the program runs perfectly. I am a newbie, so I would appreciate if someone helps me regarding this.... :) /* I am using mingw with code blocks */
#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}#include<math.h>
#include<stdio.h>
#include<conio.h>int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);printf("\\n\\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2)); getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}Driganka Mandal wrote:
int GCD(num1,num2);
int is the default type... but that function declaration isn't exactly kosher (think it would be invalid for any C compiler, C++ compilers tend to be more forgiving but that doesn't mean it's part of the standard).