---
# System prepended metadata

title: Untitled

---

first problem

```cpp=
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
	
	int size=9;// 7->9 eight dice
	int freq[size]={};
	srand(time(0));
	
	for(int roll=1;roll<=100;roll++) //wrong
	{
	freq[1+rand()%8]++; //wrong 1+rand()%7 the range is between 1~7 not 1~8
	}
	cout<<"Dice face"<<setw(13)<<"Frequency"<<endl;
	
	
	for(int face=1;face<size;face++)
	{
		cout<<setw(9)<<face<<setw(13)<<freq[face]<<endl;
		
	}
    
    return 0;
    }
    
```

second problem

```cpp=
#include <iostream>
#include <iomanip>
using namespace std;


int main() {
	
	int size=9;
	int freq[size][size]={};
	srand(time(0));
	
	for(int roll=1;roll<=100;roll++) 
	{
		
	freq[1+rand()%8][1+rand()%8]++;
		
	}
	
	
	cout<<"Dice face1 Dice face2"<<setw(13)<<"Frequency"<<endl;
	
	for(int face1=1;face1<size;face1++)
		for(int face2=1;face2<size;face2++)
		{
			cout<<setw(9)<<face1<<setw(9)<<face2<<setw(13)<<freq[face1][face2]<<endl;
		}
	
	
	
	return 0;
}


```


```C=
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int N=10;
int k=8;

int main(void) {
	
	
	srand(time(NULL));
	int A[N];
	
	for(int i=0;i<N;i++)
	{
		A[i]=rand()%100;
		printf("%d ",A[i]);
		
	}
	
	int max=-99999999;
	int min=999999999;
	
	for(int i=0;i<N;i++)
	{
		if(max<A[i]){max=A[i];}
		if(min>A[i]){min=A[i];}
	}
		printf("\n%d %d",max,min);
	
	
	int num=0;
	int temp=min;
	
	while(temp<=max&&num<k)
	{
		for(int i=0;i<N;i++)
		{
			if(temp==A[i])num++;
		}
		temp++;
		
		
	}
		printf("\n%d",temp-1);	

}

```