need help computer-assisted instruction programm(rand for short)

This is a discussion on need help computer-assisted instruction programm(rand for short) within the C Programming forums, part of the General Programming Boards category; Question.Use rand to produce two positive one-digit integers.It should then type a question such as: How much is 6 times ...

  1. #1
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356

    Unhappy need help computer-assisted instruction programm(rand for short)

    Question.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 awnser .Your program checks the students awnser.If it is correct, printf "Very good!" and then ask another multiplication question.If the awnser is wrong printf"No.Please try again" and then let the student try the same question repeatedly until he gets it right.Note.Also use user defined functions.

    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <time.h>
    
    int riwo ( int ,int, int ); //function prototype
    
    int main()
    {
     int num1, num2, awn;
         srand(time(NULL));
         num1 = 1+ rand () % 10;
         num2 = 1+ rand() % 10;
    
    
    
    
    
         printf ("What is %d times %d: ", num1 , num2);
         scanf ("%d", &awn );
         if ( riwo(num1, num2,awn) == 1 )
         printf ("Very good\n");
    
         else if ( riwo(num1, num2, awn) == 0)
         printf ("You are wrong\n");
    
          system("PAUSE");
          return 0;
    }
    
    int riwo (int a, int b, int tot )
    {
    
        if ( tot == a*b )
        return (1);
        else
        return (0);
    }
    I cant do the part where it says if it is wrong print the same thing again..help me out...

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    Code:
    while (riwo(num1, num2,awn) == 0) {
       printf("No. Please try again\n");
       printf ("What is %d times %d: ", num1 , num2);
       scanf ("%d", &awn );
    }
    printf("Very good\n");

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simulator
    By MasterAchilles in forum C Programming
    Replies: 10
    Last Post: 11-30-2008, 10:31 PM
  2. Replies: 34
    Last Post: 02-26-2006, 01:16 PM
  3. Major Computer Problem
    By Olidivera in forum Tech Board
    Replies: 10
    Last Post: 07-15-2005, 12:15 PM
  4. Tabbed Windows with MDI?
    By willc0de4food in forum Windows Programming
    Replies: 25
    Last Post: 05-19-2005, 11:58 PM
  5. Computer will not boot.
    By RealityFusion in forum Tech Board
    Replies: 25
    Last Post: 09-10-2004, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21