/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>

#define Q(qtxt,qres) \
    do \
    { \
        ok = 0; \
        printf("%s ",qtxt); \
        fgets(s,sizeof(s),stdin); \
        a = strtol(s, &ep, 10); \
        if(ep > s) \
        { \
            if(a == qres) \
            { \
                printf("Rigtigt!\n"); \
                ok = 1; \
            } \
            else \
            { \
                printf("Forkert!\n"); \
            } \
        } \
        else \
        { \
            printf("Ikke et tal\n",s); \
        } \
    } while (!ok);

int main()
{
    int a;
    int ok;
    char s[33],*ep;
    Q("Hvad er 2 + 2 ?",4);
    Q("Hvad er 2 * 3 ?",6);
    return 0;       
}
