473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

implicit declaration of function

implicit declaration of function
please tell me what im doing wrong.

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4.  
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.   char choice;
  9.   int number1, number2;
  10.  
  11.   printf("=========================================================\n");
  12.   printf("* A (a):Enter two integer numbers                       *\n");
  13.   printf("* B (b):Find the maximum of the two numbers             *\n");
  14.   printf("* C (c):Find the minimum of the two numbers             *\n");
  15.   printf("* D (d):Determine if both numbers are equal             *\n");
  16.   printf("* Q (q):Quit program                                    *\n");
  17.   printf("=========================================================\n");
  18.   printf("\n");
  19.  
  20.   printf("*Enter Your Chice:  ");
  21.   scanf("%c",&choice); 
  22.  
  23.   switch(choice)
  24. {
  25. case 'a':
  26. case 'A':
  27.           PrintMenu(char choice);
  28. break;
  29.  
  30. case 'b':
  31. case 'B':
  32.          EnterNumber(char choice);
  33. break; 
  34.  
  35. case 'c':
  36. case 'C':
  37.          FindMaximum(int number1,int number2); 
  38. break;
  39.  
  40. case 'd':
  41. case 'D':
  42.           FindMinimum(int number1,int number2);
  43. break;
  44.  
  45. case 'q':
  46. case 'Q':
  47.          IsEqual(int number1,int number2);
  48. break;
  49. }
  50.  
  51.  
  52.   void PrintMenu(char choice);
  53.           {            
  54.           printf("\nPlease Enter an Integer:");
  55.           scanf("%d",&number1);
  56.           printf("\n");
  57.           printf("\nPlease Enter an Integer:");
  58.           scanf("%d",&number2);
  59.           printf("\n You entered %d and %d\n",number1,number2);
  60.           }
  61.  
  62.   int EnterNumber(char choice);
  63.       {
  64.        if (number2<number1)
  65.        printf("The Bigger number is %d\n",number1);
  66.        else if (number1<number2)    
  67.        printf("The Bigger number is %d\n",number2);
  68.        }
  69.  
  70.   int FindMaximum(int number1, int number2);
  71.       {
  72.       if (number1<number2)
  73.       printf("The Smaller number is %d\n",number1);
  74.       else if (number2<number1)
  75.       printf("The Smaller number is %d\n",number2);
  76.       }
  77.  
  78.  
  79.   int FindMinimum(int number1, int number2);
  80.       {
  81.      if(number1 == number2)
  82.      printf("The numbers are equal\n");
  83.      else if(1)
  84.      printf("The numbers are NOT Equal\n");
  85.      }
  86.  
  87.  
  88.   int IsEqual(int number1, int number2);
  89.   {
  90.   if(number1 == 'q'&& number2 == 'q')
  91.   printf("\n Quitting program!");
  92.   }
  93.  
  94.  
  95. return 0;
  96. }
Apr 15 '12 #1
4 6630
weaknessforcats
9,208 Expert Mod 8TB
B the time the compiler gets here:
Expand|Select|Wrap|Line Numbers
  1. switch(choice)
  2.  {
  3.  case 'a':
  4.  case 'A':
  5.  PrintMenu(char choice);
  6.  break;
  7.  
it hasn't been told there there is a function named PrintMenu with a char argument. So it puts out an error.

You need to tell the compiler a funtions exists before you call it.
Use a function prototype for this:


Also every one of your functions has a semi-colon before the opening brace:

Expand|Select|Wrap|Line Numbers
  1. void PrintMenu(char choice);  <---------!
  2.  { 
  3. printf("\nPlease Enter an Integer:");
  4.  scanf("%d",&number1);
  5.  printf("\n");
  6.  printf("\nPlease Enter an Integer:");
  7.  scanf("%d",&number2);
  8.  printf("\n You entered %d and %d\n",number1,number2);
  9.  }
  10.  
You will need to remove those.
Apr 15 '12 #2
I tried removing them , but i m not getting the part where you tell me to "You need to tell the compiler a funtions exists before you call it.
Use a function prototype for this:"

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>


int main(int argc, char *argv[])
{
char choice;
int number1, number2;

printf("========================================== ===============\n");
printf("* A (a):Enter two integer numbers *\n");
printf("* B (b):Find the maximum of the two numbers *\n");
printf("* C (c):Find the minimum of the two numbers *\n");
printf("* D (d):Determine if both numbers are equal *\n");
printf("* Q (q):Quit program *\n");
printf("========================================== ===============\n");
printf("\n");

printf("*Enter Your Chice: ");
scanf("%c",&choice);



void PrintMenu(char choice)
{
printf("\nPlease Enter an Integer:");
scanf("%d",&number1);
printf("\n");
printf("\nPlease Enter an Integer:");
scanf("%d",&number2);
printf("\n You entered %d and %d\n",number1,number2);
}

int EnterNumber(char choice)
{
if (number2<number1)
printf("The Bigger number is %d\n",number1);
else if (number1<number2)
printf("The Bigger number is %d\n",number2);
}

int FindMaximum(int number1, int number2)
{
if (number1<number2)
printf("The Smaller number is %d\n",number1);
else if (number2<number1)
printf("The Smaller number is %d\n",number2);
}


int FindMinimum(int number1, int number2)
{
if(number1 == number2)
printf("The numbers are equal\n");
else if(1)
printf("The numbers are NOT Equal\n");
}


int IsEqual(int number1, int number2)
{
if(number1 == 'q'&& number2 == 'q')
printf("\n Quitting program!");
}

switch(choice)
{
case 'a':
case 'A':
PrintMenu(char choice)
break;

case 'b':
case 'B':
EnterNumber(char choice)
break;

case 'c':
case 'C':
FindMaximum(int number1,int number2)
break;

case 'd':
case 'D':
FindMinimum(int number1,int number2)
break;

case 'q':
case 'Q':
IsEqual(int number1,int number2)
break;
}
Apr 15 '12 #3
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4. /*void variable doesnt return anything, thats why we need to use the parameters*/
  5.  
  6. void printMenu(int a, int b) {
  7. printf("you entered %d 
  8. and %d",a,b);
  9. }
  10.  
  11. int main()
  12. {
  13. char choice;
  14. int n1,n2;
  15. printf("enter choice:\n");
  16. scanf("%c",&choice);
  17.  
  18. switch(choice) {
  19. case 'A':
  20. case 'a':
  21. printf("enter n1:\n");
  22. scanf("%d",&n1);
  23. printf("enter n2:\n");
  24. scanf("%d",&n2);
  25. printMenu(n1,n2);
  26. break;
  27.  
  28. default:
  29. printf("not in menu");
  30. goto main();
  31. break;
  32. }
  33.  
  34. getch();
  35. }
  36.  
Apr 16 '12 #4
weaknessforcats
9,208 Expert Mod 8TB
Compile you code and fix the firtst error only. Then recompile. Often subsequent errors are removed by fixing the first one.

If you fix only the first error and recompile each time you will eventually get a good build.

Once you get there you can lean how to step through the code using your debugger.
Apr 16 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jason | last post by:
Hi, Im running windows xp pro and compiling using dev c++ 4. I have the following situation: #include <iostream> #include <string> using namespace std; int main() {
2
by: nick | last post by:
the following is my programming code and compile message why the warning message arise, have i done somethings wrong? #include<stdio.h> typedef struct card{ int abc; }card;
7
by: Paminu | last post by:
On a gentoo linux system i don't get any warnings when I comlpile this code: #include <stdio.h> typedef struct test { void *content; struct test_ *bob; } test_;
6
by: Johs32 | last post by:
I get this warning: warning: incompatible implicit declaration of built-in function 'printf' because I use printf in a function that I include in a .h file that is included by other files...Do...
5
by: Christian Christmann | last post by:
Hi, in one file I've a function that is used by another file containing the main function: file1.c: .... void test( int a ) { ... } ....
6
by: yeah | last post by:
hi I got this error "implicit declaration of function" what it means???
14
by: UNCManiac37 | last post by:
Hi, I'm very new to coding, so this is a newbie question. I'm trying to print out a banner using functions instead of main: int main () { banner1 (); } void banner1 (void) { cout...
5
by: DanielJohnson | last post by:
I call a function which is named as func_name in file /source/folderA/ fileA.c. The actual function definition is in /source/folderB/fileB.c. And I get this error. warning: implicit...
3
by: samdomville | last post by:
hello...upon compilation, i get a warning: "warning: implicit declaration of funciton funciton_name" what, techicallly, is an implicit declaration? how/where would i look to track down the error?...
1
by: samdomville | last post by:
Hello - I have a .c file that gives me a warning "implicit declaration of function function_name". However, I have #included the header file that #defines that funciton, so how is it possible to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.