#include <iostream>
#include <conio.h>
#include <time.h>
usingnamespace std;
constint size = 50;
void sort(int, int, int);
int main()
{
int amount, year;
int month, day;
char slash = '/';
int months[size], days[size];
cout << "Enter the amount of digits you wish to enter.";
cin >> amount;
cout << "now enter the year you wish to use.";
cin >> year;
for(int i=0; i<amount;i++)
{
month = rand() % 12+1;
months[i]=month;
if (month == 4 || month == 6 || month == 9 || month == 11)
{
day = rand() % 30+1;
}//end of if(first if ) bracket
elseif (month == 2){
if (year%4==0 && year%100>0 || year%400 == 0)
{
day=rand()% 29+1;
}// end of if bracket of else if
else
day = rand()% 28+1;
}// end of else if bracket for feb
else
day=rand()%31+1;
days[i]=day;
cout << month << slash << day << endl;
}// end of for bracket
sort(months[size], days[size], size);
}// end of main bracket
void sort(int months[size],int days[size], int amount)
{
int temp;
for (int i=0;i<=amount;i++)
{
temp=months[i];
if (months[i]<months[i+1])
{
months[i]=months[i];
}//end of if
else
months[i]=months[i+1];
}// end of for loop
}
There are few things which looks incorrect , some things I noticed are:
1) conio.h is not part of c++ standard
2) calling sort function syntax does not look right