473,387 Members | 1,897 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,387 software developers and data experts.

error too few arguments to function: 'generateQuestions'

Hi sorry for asking to many questions but I have compiled the code for division and multiplication, which all ask 10 random questions on both section and the user has to enter them. I'm receiving this error on line 39 and 68 ' too few arguments to function 'generateQuestions' . I would be tremendously grateful if anyone can help me on this.

Thank you.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. int a;
  7. int b;
  8. int choice;
  9.  
  10. #define SIZE 10
  11.  
  12. //FUNCTION PROTOTYPE
  13.  
  14. void generateQuestions(int a[], int b[], int c[], int d[]);
  15. void multiplication(int a[], int b[], int c[]);
  16. int printResult_multiplication(int a[], int b[], int ca[],int ua[]);
  17. void division(int a[], int b[], int d[]);
  18. int printResult_division(int a[], int b[], int ca[],int ua[]);
  19.  
  20. //PROGRAM BODY
  21.  
  22. int main(void)
  23. {
  24.  
  25.    printf("This program tests you with ten questions.\n 1) Multiplication\n 2) Division\n 3) Exit\n Please make a selection (1-3)\n");
  26.    scanf("%d", &choice);
  27.    if(choice==1)
  28.    {
  29.        int i;
  30.     int ans;
  31.     int x[SIZE];
  32.     int y[SIZE];
  33.     int answer[SIZE];
  34.     int useranswer[SIZE];
  35.     int score=0;
  36.  
  37.     srand(time(NULL));
  38.  
  39.     generateQuestions(x, y, answer);
  40.     multiplication(x, y, useranswer);
  41.     score= printResult_multiplication(x, y, answer,useranswer);
  42.  
  43.     if (score > 7)
  44.     {
  45.         printf("Congratulations! You scored %d/%d\n",score,SIZE);
  46.  
  47.     }
  48.     else if (score <= 7)
  49.  
  50.     {
  51.         printf("Please ask your teacher for help! You scored %d/%d\n",score,SIZE);
  52.  
  53.     }
  54.    }
  55. else
  56. if (choice==2)
  57. {
  58.     int i;
  59.     int ans;
  60.     int x[SIZE];
  61.     int y[SIZE];
  62.     int answer[SIZE];
  63.     int useranswer[SIZE];
  64.     int score=0;
  65.  
  66.     srand(time(NULL));
  67.  
  68.     generateQuestions(x, y, answer);
  69.     division(x, y, useranswer);
  70.     score= printResult_division(x, y, answer,useranswer);
  71.  
  72.     if (score > 7)
  73.     {
  74.         printf("Congratulations! You scored %d/%d\n",score,SIZE);
  75.  
  76.     }
  77.     else if (score <= 7)
  78.  
  79.     {
  80.         printf("Please ask your teacher for help! You scored %d/%d\n",score,SIZE);
  81.  
  82.     }
  83. }
  84.  
  85.     return 0;
  86. }
  87.  
  88. //FUNCTION DEFINED
  89.  
  90.  
  91. //GENERATE QUESTION FUNCTION
  92. void generateQuestions(int a[], int b[], int c[], int d[])
  93. {
  94.     int i;
  95.     for(i=0; i<SIZE; i++)
  96.     {
  97.         a[i]=rand()%11;
  98.         b[i]=rand()%11;
  99.         c[i]=a[i]*b[i];
  100.         d[i]=a[i]%b[i];
  101.  
  102.     }
  103.  
  104. }
  105.  
  106. //MULTIPLICATION FUNCTION
  107. void multiplication(int a[], int b[], int c[])
  108. {
  109.     int i;
  110.     int ans;
  111.     printf("Please give the answers to the following additions:.\n");
  112.  
  113.     for(i=0; i<SIZE; i++)
  114.     {
  115.  
  116.         printf("%d x %d = ",a[i],b[i]);
  117.         scanf("%d",&ans);
  118.         c[i]=ans;
  119.     }
  120. }
  121.  
  122.  
  123. //DIVISION FUNCTION
  124. void division(int a[], int b[], int d[])
  125. {
  126.     int i;
  127.     int ans;
  128.     printf("Please give the answers to the following additions:.\n");
  129.  
  130.     for(i=0; i<SIZE; i++)
  131.     {
  132.  
  133.         printf("%d / %d = ",a[i],b[i]);
  134.         scanf("%d",&ans);
  135.         d[i]=ans;
  136.     }
  137. }
  138.  
  139.  
  140. //PRINT DIVISION SUMMARY FUNCTION
  141. int printResult_division(int a[], int b[], int ca[],int ua[])
  142. {
  143.     int i;
  144.     int score=0;
  145.     for(i=0; i<SIZE; i++)
  146.     {
  147.         printf(" %d / %d = %d  -", a[i],b[i],ua[i]);
  148.         if(ua[i]==ca[i])
  149.         {
  150.             score=score+1;
  151.             printf("Correct answer\n");
  152.         }
  153.         else
  154.         {
  155.             printf(" Incorrect answer - the answer is %d \n",ca[i]);
  156.         }
  157.     }
  158.  
  159.     return score;
  160. }
  161.  
  162.  
  163. //PRINT MULTIPLICATION FUNCTION
  164. int printResult_multiplication(int a[], int b[], int ca[],int ua[])
  165. {
  166.     int i;
  167.     int score=0;
  168.     for(i=0; i<SIZE; i++)
  169.     {
  170.         printf(" %d * %d = %d  -", a[i],b[i],ua[i]);
  171.         if(ua[i]==ca[i])
  172.         {
  173.             score=score+1;
  174.             printf("Correct answer\n");
  175.         }
  176.         else
  177.         {
  178.             printf(" Incorrect answer - the answer is %d \n",ca[i]);
  179.         }
  180.     }
  181.  
  182.     return score;
  183. }
  184.  
  185.  
  186.  
Feb 19 '11 #1
2 3159
Rabbit
12,516 Expert Mod 8TB
You're only passing in 3 parameters into the function while your function is expecting 4.
Feb 19 '11 #2
What he said
Feb 19 '11 #3

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

Similar topics

2
by: Lian Liming | last post by:
Hi, all I want to write my own error handler function in php by using "set_error_handler()" function. I have made a test for this function but found it did not work. My test code is as following:...
3
by: murphy | last post by:
Hi, I've been seeing two symptoms with my asp.net site that have started recently after a long period of smooth running. As others on our team make changes to referenced dll's I find that I...
9
by: Alexander Cohen | last post by:
(sorry for the double post if there is one - i sent the mail to the lisyt from the wrong address) Hi, Im passing this in the commmand line to start up the PostgreSQL server: ../pg_ctl start...
5
by: Jozef | last post by:
I have an MDE file that is blowing up with "Error 3075 Function Not Available", which is normally a reference issue, but, I have no missing references. It seems that offending function is a...
1
by: joe10001 | last post by:
Hi all, I just installed CRELoaded (oscommerce fork) on my server and all work fine except that I have a little message at the bottom of the main page : Fatal error: main() : Security alert:...
7
by: Hexer | last post by:
Hi and good day to all...I am new to the C language and whenever I tried to run the program I made, it won't because it says it has an "expression syntax error in function main"..what I don't get is...
3
by: sadique | last post by:
Hello, Sadique here I've been installing a free source hotel booking system and I encountered an error while trying to go to the second step in the installation process. Fatal error:...
5
by: Sonasang | last post by:
Hi , I am creating a web page with ASP and Javascript.We have shared the foldres containg the code and all our team members are accessing the code. There is no problem for me when i run the...
1
by: pnbaocuong | last post by:
Dear All When I try to use convert function of MS sql server like this: String sql = " (employee_id = '" + employee_id + "') and ((convert(VARCHAR,w_date,103) = '" + w_date + "'))"; ...
1
by: kinhoe | last post by:
i have a program in webserver. i run smooth before. but dunno why it sudden prompt out the error below? Warning: require_once() : open_basedir restriction in effect....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.