Hello i'm trying to understand this issue: I need to write a function which should return two different random integers but i didn't manage to get two outputs from function so i decided to simple call 2 times the same function by doing this
#include <stdio.h>
#include <time.h>
int query ();
int query (){
int c,d;
srand(time(NULL));
c = 1 + (rand() % 9);
//d = 1 + (rand() % 9);
//printf("How much is %d times %d?\n", c, d);
}
int main (){
int firstNumber, secondNumber;
firstNumber= query();
secondNumber = query();
printf("How much is %d times %d ?\n", firstNumber, secondNumber);
//query();
}
but sadly the number i get running the program is the same (firstNumber == secondNumber). BUT when i uncomment the lines in the function and line //query() in main then i get two different random numbers. I'm trying to understand why so if someone could help i'll appreciate it. thanks.