Rolling a Six-Sided Die




Welcome to C programming tutorial, we will be writing a program illustration that Rolls a Six-Sided.

A fair die means that each of the faces has the same probability of landing facing up; A standard six-sided die, for example, can be considered "fair" if each of the faces has a probability of 1/6.

The Program will be required to loop 20 times and on each loop the rand() function for number generation will be called to be picking numbers randomly between 1 to 6.



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

int main(void)

{

    int i;

    for(i=1; i<=20; i++){

        printf("%5d", 1+(rand()%6));
        if(i%5==0){
            printf("\n"); 

        }


    }

    return 0;


}

Comments

Popular posts from this blog

Body Mass Index Calculator In C

Adding two Integers in Java Application

Calculating Product, sum, difference, and quotient of Five Integers