mardi 17 mars 2015

"rand()" not working, i keep getting the same number after every execute

So i am creating a ATM program for my programming class, long story short, i have to create about four random numbers. My issue is my program will not create different numbers, the numbers i get when i execute my program are the same over and over. I had srand(time(NULL)); in my main function and since my variables were global i tried to move it out of main next to my global variables, this left me with a un-compliable error. HELPPP!!!!



#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<string.h>


int account_number = rand() % 5, pin = rand() % 3, chk_acc_bal = rand() % 4, sav_acc_bal = rand() % 5;




Aucun commentaire:

Enregistrer un commentaire