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

Dire help needed in writing a multiplication program!

Hi I'm very new to C programming and I'm writing a program which will generate two random numbers, multiply them together and we have to guess the answer if it is correct or not, the problem involves the use of arrays and loops...

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int run_Test(int x[], int y[], int answers[]);
  6. int main(void)
  7. {
  8.     int one;
  9.  
  10.   printf("This software tests you with 10 questions.\n 1) Multiplcation.\n 2) Division.\n 3) Exit.\n Please make a selection (1-3):");
  11. scanf("%d", &one);
  12.  
  13. if (one==1)
  14. {
  15.     printf("Please give the answers to the following additions:\n");
  16. }
  17. else
  18. if (one==2)
  19. {
  20.     printf("Please give the answers to the following additions:\n");
  21. }
  22.  
  23.     return 0;
  24. }
  25.  
  26. int run_Test(int x[], int y[], int answers[])
  27. {
  28.     int x[10], int y[10], int answers[10]
  29. }
  30.  
  31.  
For now I'm only trying to figure out how to generate 10 different multiple choice questions using the srand command. The problem is I'm not very good with arrays and loops and would be grateful if someone could explain in detail as what needs to be done.
Feb 18 '11 #1
1 1702
I have written a preliminary code to generate 10 multiple choice questions..can someone please tell me where I'm going wrong:

Expand|Select|Wrap|Line Numbers
  1.  
  2. // Generates 10 multiple choice questions, the user enter 10 multiple choice questions, the program checks it and gives out the result
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. int a;
  7. int b;
  8. a=rand();
  9. b=rand()
  10. int run_Test(int a, int b);
  11.  
  12. int main(void)
  13. {
  14.  int x[10];
  15.  int y[10];
  16.  int answer[10];
  17.  
  18.  printf("Enter the answer to the following questions:.\n");
  19.  scanf("%d %d", &x, &y);
  20.  if (x*y==answer)
  21.  {
  22.      printf("correct answer");
  23.  }
  24.  
  25.  
  26.  
  27.  return 0;
  28. }
  29.  
  30. int run_Test(rand(),rand())
  31. {
  32.     answer = a * b;
  33.     return answer;
  34. }
  35.  
Feb 18 '11 #2

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

Similar topics

3
by: bjeffers | last post by:
I need help writing a program that asks the user to enter the number of grades that he/she wants to enter, reads this many number of integer grades (assume each grade is in the range 0..100), and the...
22
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at...
1
by: lenest | last post by:
I need help writing a program.... You are to write a python program to accomplish the following: a.. Play a dice game of Craps using a random number generator to simulate the roll of the...
1
by: jyothiusha | last post by:
hi i want to write a program in bash for uploading a file in directory from one directory to another directory or a web page in fedora linux. can anyone help me in writing the program please...
7
by: rohitsripathi | last post by:
i need help writing this program... i am in college and i do not have time do this right now as i need to study for another test....but this is due tonight...i will pay $5 if you accept to do it and...
1
by: siva041986 | last post by:
Hi there, This is Siva. I need some help in writing a program for Unix. I need to write a program using Semaphores and avoid deadlocks and starvation. If you think you can help me please let me...
6
by: mcse jung | last post by:
Here is asample program that writes a program and then executes it. Do you knowof a much simpler way of writing a program that writes a program? """...
3
by: Levi Campbell | last post by:
Hi, I'm trying to write a program for a friend of mine who uses windows but I use GNU/Linux. I know you can use mingw and link to the python dll, but is there a way to create a win32 service under...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.