Untitled
unknown
plain_text
3 years ago
940 B
5
Indexable
#include <stdio.h> #include <stdlib.h> #include<conio.h> // Generation of random numbers using built in function of C int main(){ int ch,i; time_t t; do{ printf("press: \n"); printf("1. to generate random number using random() function \n"); printf("2. to generate random number using rand() function \n"); printf("3. to generate random number using srand() function \n"); printf("Any other number to terminate\n"); switch(ch) { case 1: for (i=1;i<10;i++){ randomize(); printf("Random number in the 0-99 range: %d\n",random(100)); } break; case 2: for (i=0;i<10;i++){ printf("%d \n",rand()%10); } case 3: srand((unsigned) time(&t)); for (i=1;i<10;i++){ printf("%d\n",rand()%100); } break; default: printf("Invalid Choice"); exit(0); } }while(1); // getch(); return 0; }
Editor is loading...