gentlemen... I don't want you to solve it for me all what I want is to give me some hints how to solve this question...
for example what kind of function you recommend me to use and what kind of loops you recommend me to use also .....

Write a program to test kid’s knowledge of arithmetic.
Your program contains 3 functions in addition to the main function;
- Function randnum(int n) receives a positive integer n and returns a random number between 1 and n.
- Function randop() return a character representing the operation i.e. ‘+’ for addition, ‘-‘ for subtraction and ‘*’ for multiplication. The function will generate a random number between 1 and 3 ( call randnum function for this) and returns ‘+’ if it’s 1, ‘-‘ if 2, and ‘*’ if it’s 3.
- Function operation receives 2 operands n1 and n2 and the operator (+ or – or *) and returns the result (i.e. n1 operator n2).
The main function will use a do-while loop to keep the test running as long as the user types ‘Y’ or ‘y’.
The addition and subtraction will be with numbers from 1 to 20
The multiplication with numbers from 1 to 10.
Note: The function rand() will return a pseudo random number from 0 to RAND_MAX which is the maximum value in the int type. In order to limit your number from 0 to n, make the returned value % (n+1). By using rand() only, your program will generate the same sequence during each execution. To avoid this problem insert the following statement at the beginning of your main function. srand(time(NULL));
You need to insert 2 include statements <stdlib.h> and <time.h>.
Initially the program will post the first operation and wait for the answer. Then based on the typed answer, the program will print “wow you got it right” or “oops you missed it”. In this case it prints the right answer.

>for example what kind of function you recommend me to
>use and what kind of loops you recommend me to use also
Well, I'd recommend what the requirements say, since they're very specific about what functions and loops you should use. :icon_rolleyes:

Well, I'd recommend what the requirements say, since they're very specific about what functions and loops you should use. :icon_rolleyes:

He didn't ask you anything.
Look:

gentlemen...[...]

So my advice (as a gentleman) would be "I'd recommend what the requirements say, since they're very specific about what functions and loops you should use. "

(sorry, but Fridays do that to me... :) )

I solve it but still there are some errors.....help me friends

#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int randnum(int n);
char randop(int oper);
int operation(int n1,int n2,char r);
int main()
{
    int n , num , value , n2 , n1 ,resultr,ope1;
    char oper1,result,r;
    do {
        printf("Arthimatic Test\n");
        srand(time(NULL));
        ope1=randop(r);
        if(ope1=='+' || ope1 == '-')
        {
                     n1 = randnum(20);
                     n2 = randnum(20);
                     }
                     else 
                     n1 = randnum(10);
                     n2 = randnum(10);
                     result = operation(n2 , n2 , ope1);
                     printf("%d%c%d =",n1 , ope1 , n2);
                     scanf("%d", &value);
                     if (value == result)
                     printf("wow you got it right \n");
                     else 
                     printf("opps you missed it\n");
                     printf("if you want to continue press y or Y");
                     scanf("%c",&result);
                     scanf("%c",&result);
                     printf("\n");
                     }
                     while (result == 'Y' || result == 'y');
                     return 0;
                     }
                     int randnum(int n)
                     {
                         return rand()%(n+1);
                         }
                         char randop(int ope1)
                         {
                              char c ;
                              ope1 = randnum(3);
                              if(ope1==1)
                              c='+';
                              else if(ope1 == 2)
                              c='-';
                              else 
                              c='*';
                              return c;
                              }
                              int operation(int n1, int n2 , char r)
                              {
                              int k;
                              if(r=='+')
                              k=n1+n2;
                              else if(r == '-')
                              k= n1-n2;
                              else 
                              k=n1*n2;
                              return k;
                              }

eeek indent overload.
Also what is the problem exactly...?

We cannot fix it if we do not know it!

Chris

Here's the number one problem, the format!
A generic skeleton:

#include <iostream>
#include <cstdlib>

int main()
{
    string input;
    int      results[2], operation;
    bool   continue = true;

    srand(time(NULL));

    while(continue)
    {
         getline(cin, input);

        /*do stuff*/

         if(comparison is right)
             cout << "Correct.";
         else
         {
              /*Ask*/
         }
    }
    
    return(0);
}

Lets review.
One: Variable names you can read.
Two: srand() is called only once.
Three: Uses actual C++ classes.
Four: You can follow the flow.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.