Like Tree9Likes

developing an easy CAI programm in C

This is a discussion on developing an easy CAI programm in C within the C Programming forums, part of the General Programming Boards category; > I can't quite understand that, could u pls explain more?! Perhaps you should read your book on functions, and ...

  1. #31
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    > I can't quite understand that, could u pls explain more?!
    Perhaps you should read your book on functions, and contemplate what
    x = rand();
    means in terms of a function (ie rand) returning a result (of type int)
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  2. #32
    Registered User Ashl7's Avatar
    Join Date
    Oct 2012
    Posts
    57
    Quote Originally Posted by Salem View Post
    > I can't quite understand that, could u pls explain more?!
    Perhaps you should read your book on functions, and contemplate what
    x = rand();
    means in terms of a function (ie rand) returning a result (of type int)

    ok I guess this is what you mean:
    Code:
    int func(int x,int y)
    {
        int c;
        printf("How much is the product of %d and %d? \n",x,y);
        scanf("%d",&c);
        return c;
    yea this should work...tnx

    and my int main body is going to be like this:
    Code:
    int main()
    {
        int a,b,h,d;
        srand(time(NULL));
        a= rand() % 10;
        b= (rand() % 10);
        printf("Hello, this is computer assited instruction for multiplication...\n");
        h=func(a,b);
        d=a*b;
        if(h==d)
        correct();
        else
        wrong();
        return 0;
        }

  3. #33
    Registered User Ashl7's Avatar
    Join Date
    Oct 2012
    Posts
    57
    now could someone give me a hint about how my program remembers the times of occurrence of a certain number?!
    like 3,4,5,5,6,7,7,7
    a program that tell me 5 is been occurred 2 times,and 7,three times
    Last edited by Ashl7; 10-13-2012 at 11:50 AM. Reason: found out how

  4. #34
    Registered User
    Join Date
    Jun 2011
    Posts
    2,234
    If you're only using ten integers (0 - 9), you can create an array with ten elements (0 - 9).

    When a random number is chosen, increment that element of the array by one.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Developing GUI app with C
    By elf1984 in forum C Programming
    Replies: 2
    Last Post: 10-23-2008, 09:58 AM
  2. Seg fault in easy, easy code
    By lisa1901 in forum C++ Programming
    Replies: 11
    Last Post: 12-10-2007, 04:28 AM
  3. Further developing C for the web
    By bjdea1 in forum C Programming
    Replies: 24
    Last Post: 12-25-2002, 12:49 PM
  4. Easy question, (should be) easy answer... ;-)
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-12-2002, 09:36 PM
  5. Replies: 6
    Last Post: 11-28-2001, 04:53 AM

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