#include <iostream>
#include <cstdlib> // mengandung fungsi random
using namespace std;

int main(){
	char lanjut;
	while(true){
		cout << "Lempar dadu? (y/n)";
		cin >> lanjut;

		if(lanjut == 'y'){
			cout << 1 + (rand() % 6) << endl;	
		}else if(lanjut == 'n'){
			break;	
		}else{
			cout << "Warning: ketik y atau n dong!!\n";
		}
	}
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: