Thread: executing certain function

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    25

    executing certain function

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    
    void multiplication (void);
    
    int main()
    {
    	multiplication();
    }
    void multiplicaton (void)
    {
    		int x, y, answer, guess;
    srand(time(NULL));
    x = rand()%9 + 1;
    y = rand()%9 + 1;
    
    answer = x*y;
    printf( "what is %d multplied by %d\n" , x , y);
    	scanf("%d", &guess);
    
    
    	while( guess != answer)
    	{
    		printf("No. Please try again");
    	}
    		printf(" Very Good\n");
    	
    	
    }
    Basically the function is supposed to be executed almost as it was the main function and be the only thing really doing anything during the program. I can't seem to call it in the main function. here is the question I have to answer:

    2- Computers are playing an increasing role in education. Define a function called multiplication that takes no arguments and returns nothing to help an elementary school student learn multiplication. Use rand to produce two positive one-digit integers. It should then type a question such as:

    How much is 6 times 7?

    The student then types the answer. Your function checks the student’s answer. If it is correct, print “Very good!” and then ask another multiplication question. If the answer is wrong, print “No. Please try again.” and then let the student try the same question again repeatedly until the student finally gets it right. Use this function in a program to check the correctness of the function.

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    Check your spelling of "multiplication".

    In the future, please explain in detail what's going wrong. "I can't seem to call it" does not give any information about the problem you're encountering.

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    25
    All I really want to do is have the function be initiated but the program doesn't execute it I just a blank screen until I hit enter or whatever twice for my getchars();. I want it to execute the function multiplication()

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    As already mentioned, you're screwed if you can't spell.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Sep 2010
    Posts
    25
    hmmmmm...... thank you *hangs head in shame*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM