Thursday, November 28, 2013

Here Is The Code for the Basic C Program for a guessing game.  (Pretty basic, however its first video)!

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

int main()
{
    srand(time(NULL));
    int a,r;
    r= rand()%(6) + 1;

    (void) printf("Lets role the dice\n");
    printf("Guess what number I rolled?\n");

    while (scanf("%d",&a)){

if (a!=r){printf("Wrong Try Again");}
else {(printf("Correct\n"));}}
return 0;}

Once compiled this program can be ran.  The computer picks the number holding the number to computer memory or however computers think; allowing the user to continue guessing till get right.

KEY WORDS:  RANDOM NUMBER GENERATOR....Notice the three librarys included at top!!!

THIS IS WHY I DISLIKE AUTO CORRECT SO MUCH!!!!!


ELECTRONIC REBORN
www.electronicreborn.com