/* Random Credit Card Numbers (10 points) Write a complete C program that generates 10 random 16-digit credit card numbers for a Discover card. The first 6 digits of each credit card number are reserved for the issuer number. For Discover cards these digits must be "6011-xx". The remaining ten digits are the account number. Print the credit card numbers using the standard format: 6011-xxxx-xxxx-xxxx. The card numbers must be different every time your program is executed. SAMPLE RUN: 6011-3834-4218-9357 6011-5536-3701-3912 6011-1663-8203-7559 6011-4510-8871-8681 6011-8568-2780-4730 6011-1436-1756-1762 6011-4189-3250-7716 6011-0609-1802-2561 6011-9681-8075-1019 6011-3003-5535-4391 */ #include #include #include int main(void) { int i, d; int n[12]; // an array to store the 12 random digits srand ( time(NULL) ); // initialize the random number generator for(i=0; i<10; i++) // ten numbers { for(d=0; d<12; d++) // generate twelve digits for each card number n[d] = rand()%10; printf("6011-"); // print 1st 4 digits (always fixed) printf("%d%d%d%d-", n[0], n[1], n[2], n[3]); // print 2nd 4 digits printf("%d%d%d%d-", n[4], n[5], n[6], n[7]); // print 3rd 4 digits printf("%d%d%d%d", n[8], n[9],n[10],n[11]); // print 4th 4 digits printf("\n"); } system("pause"); }