I'm just trying to make a program that selects a range of numbers, then uses that to print out a statement with switch. After doing some editing, I figured this might work but so far it hasn't
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int i;
srand( time(NULL) );
for (i = 0; i < 1; i++) {
switch(( rand()%3 ) + 1 )) {
case 1:
printf("1 was selected.\n");
break;
case 2:
printf("2 was selected.\n");
break;
case 3:
printf("3 was selected.");
break;
}
}
}
Aucun commentaire:
Enregistrer un commentaire