#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
struct Male
{
bool Father;
bool Mother;
int Sisters;
int Brothers;
int Sons;
int Daughters;
int Sons_from_sons;
int Sons_from_daughters;
int Daughters_from_sons;
int Daughters_from_daughters;
int Brothers_from_father;
int Brothers_from_mother;
int Sisters_from_father;
int Sisters_from_mother;
bool Grandfather_from_mother;
bool Grandfather_from_father;
bool Grandmother_from_mother;
bool Grandmother_from_father;
int Uncle_from_mother;
int Uncle_from_father;
int Anut_from_mother;
int Anut_from_father;
int Wife;
double mFather;
double mMother;
double mSisters;
double mBrothers;
double mSons;
double mDaughters;
double mSons_from_sons;
double mSons_from_daughters;
double mDaughters_from_sons;
double mDaughters_from_daughters;
double mBrothers_from_father;
double mBrothers_from_mother;
double mSisters_from_father;
double mSisters_from_mother;
double mGrandfather_from_mother;
double mGrandfather_from_father;
double mGrandmother_from_mother;
double mGrandmother_from_father;
double mUncle_from_mother;
double mUncle_from_father;
double mAnut_from_mother;
double mAnut_from_father;
double mWife;
};
struct Female
{
bool Father;
bool Mother;
int Sisters;
int Brothers;
int Sons;
int Daughters;
int Sons_from_sons;
int Sons_from_daughters;
int Daughters_from_sons;
int Daughters_from_daughters;
int Brothers_from_father;
int Brothers_from_mother;
int Sisters_from_father;
int Sisters_from_mother;
bool Grandfather_from_mother;
bool Grandfather_from_father;
bool Grandmother_from_mother;
bool Grandmother_from_father;
int Uncle_from_mother;
int Uncle_from_father;
int Anut_from_mother;
int Anut_from_father;
bool Husbend;
double mFather;
double mMother;
double mSisters;
double mBrothers;
double mSons;
double mDaughters;
double mSons_from_sons;
double mSons_from_daughters;
double mDaughters_from_sons;
double mDaughters_from_daughters;
double mBrothers_from_father;
double mBrothers_from_mother;
double mSisters_from_father;
double mSisters_from_mother;
double mGrandfather_from_mother;
double mGrandfather_from_father;
double mGrandmother_from_mother;
double mGrandmother_from_father;
double mUncle_from_mother;
double mUncle_from_father;
double mAnut_from_mother;
double mHusbend;
};
int main()
{
	Male M;
	Female F;
	int Tarika = 0;
	int Asl_Tarika = 0;
	int inpt = 0;
	char ch,ch2;
	printf("Dividing Mawarith...\n");
	printf("\nEnter The Value of Tarika : ");
	scanf("%d",&Tarika);
	Asl_Tarika = Tarika;
	printf("\nEnter The Value of Tajheez Mayet : ");
	scanf("%d",&inpt);
	Tarika -= inpt;
	if (Tarika < 0)
	{
		printf("\nThe Tarika is not enough!! The rest of Tajheez Mayet is %d",Tarika*-1);
		goto ind;
	}
	if (Tarika == 0)
	{
		printf("\nThe Tarika has been finished By Paying Tajheez Mayet ..");
		goto ind;
	}
	if (Tarika > 0)
	{
		printf("\nEnter The Value Deyon : ");
		scanf("%d",&inpt);
		Tarika -= inpt;
		if (Tarika < 0)
		{
			printf("\nAfter Paying The Tajheez Mayet And Doyon The Tarika was finished and still there is %d Doyon",Tarika*-1);
			goto ind;
		}
		if (Tarika == 0)
		{
			printf("\nAfter Paying Tajheez Mayet And Doyon All The Tarika has finished ..");
			goto ind;
		}
		if (Tarika > 0)
		{
			Wsya:
			printf("\nEnter The Value of Waseya : ");
			scanf("%d",&inpt);
			if (inpt > Asl_Tarika / 3)
			{
				printf("\nIt is Haram To make The Waseya Greater Than The Third of The Tarika\n");
				goto Wsya;
			}
			if (inpt <= Asl_Tarika / 3)
			{
				Tarika -= inpt;
				MoF:
				printf("\nThe Dead Preson Is (M)ale Or (F)emale : ");
				ch = getche();
				switch (ch)
				{
				case 'm':
				case 'M':
					printf("ale ..\n");
					printf("\nHow Many Sons : ");
					scanf("%i",&M.Sons);
					printf("\nHow Many Daughters : ");
					scanf("%i",&M.Daughters);
					printf("\nHow Many Grand Sons From Sons : ");
					scanf("%i",&M.Sons_from_sons);
					printf("\nHow Many Grand Sons From Daughters : ");
					scanf("%i",&M.Sons_from_daughters);
					printf("\nHow Many Grand Daughters From Sons : ");
					scanf("%i",&M.Daughters_from_sons);
					printf("\nHow Many Grand Daughters From Daughters : ");
					scanf("%i",&M.Daughters_from_daughters);
					fthr:
					printf("\nIs The Father Alive (Y)es OR (N)o ? ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							M.Father = true;
							break;
						case 'N':
						case 'n':
							M.Father = false;
							break;
						default:
							putchar(10);
							goto fthr;
							break;
						}
					mthr:
					printf("\n\nIs The Mother Alive (Y)es OR (N)o ? ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							M.Mother = true;
							break;
						case 'N':
						case 'n':
							M.Mother = false;
							break;
						default:
							putchar(10);
							goto mthr;
							break;
						}
					gfm:
					printf("\n\nIs The Grand Father From The Mother Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							M.Grandfather_from_mother = true;
							break;
						case 'N':
						case 'n':
							M.Grandfather_from_mother = false;
							break;
						default:
							putchar(10);
							goto gfm;
							break;
						}
					gff:
					printf("\n\nIs The Grand Father From The Father Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							M.Grandfather_from_father = true;
							break;
						case 'N':
						case 'n':
							M.Grandfather_from_father = false;
							break;
						default:
							putchar(10);
							goto gff;
							break;
						}
					gmm:
					printf("\n\nIs The Grand Mother From The Mother Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							M.Grandmother_from_mother = true;
							break;
						case 'N':
						case 'n':
							M.Grandmother_from_mother = false;
							break;
						default:
							putchar(10);
							goto gmm;
							break;
						}
					gmf:
					printf("\n\nIs The Grand Mother From The Father Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							M.Grandmother_from_father = true;
							break;
						case 'N':
						case 'n':
							M.Grandmother_from_father = false;
							break;
						default:
							putchar(10);
							goto gmf;
							break;
						}
					printf("\n\nHow Many Wives : ");
					scanf("%i",&M.Wife);
					printf("\nHow Many Brothers : ");
					scanf("%i",&M.Brothers);
					printf("\nHow Many Sisters : ");
					scanf("%i",&M.Sisters);
					printf("\nHow Many Brothers From Father Only : ");
					scanf("%i",&M.Brothers_from_father);
					printf("\nHow Many Brothers From Mother Only : ");
					scanf("%i",&M.Brothers_from_mother);
					printf("\nHow Many Sisters From Father Only : ");
					scanf("%i",&M.Sisters_from_father);
					printf("\nHow Many Sisters From Mother Only : ");
					scanf("%i",&M.Sisters_from_mother);
					printf("\nHow Many Uncles From Mother : ");
					scanf("%i",&M.Uncle_from_mother);
					printf("\nHow Many Uncles From Father : ");
					scanf("%i",&M.Uncle_from_father);
					printf("\nHow Many Anuts From Mother : ");
					scanf("%i",&M.Anut_from_mother);
					printf("\nHow Many Anuts From Father : ");
					scanf("%i",&M.Anut_from_father);
					break;
				case 'F':
				case 'f':
					printf("emale ..\n");
					printf("\nHow Many Sons : ");
					scanf("%i",&F.Sons);
					printf("\nHow Many Daughters : ");
					scanf("%i",&F.Daughters);
					printf("\nHow Many Grand Sons From Sons : ");
					scanf("%i",&F.Sons_from_sons);
					printf("\nHow Many Grand Sons From Daughters : ");
					scanf("%i",&F.Sons_from_daughters);
					printf("\nHow Many Grand Daughters From Sons : ");
					scanf("%i",&F.Daughters_from_sons);
					printf("\nHow Many Grand Daughters From Daughters : ");
					scanf("%i",&F.Daughters_from_daughters);
					fthr2:
					printf("\nIs The Father Alive (Y)es OR (N)o ? ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							F.Father = true;
							break;
						case 'N':
						case 'n':
							F.Father = false;
							break;
						default:
							putchar(10);
							goto fthr2;
							break;
						}
					mthr2:
					printf("\n\nIs The Mother Alive (Y)es OR (N)o ? ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							F.Mother = true;
							break;
						case 'N':
						case 'n':
							F.Mother = false;
							break;
						default:
							putchar(10);
							goto mthr2;
							break;
						}
					gfm2:
					printf("\n\nIs The Grand Father From The Mother Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							F.Grandfather_from_mother = true;
							break;
						case 'N':
						case 'n':
							F.Grandfather_from_mother = false;
							break;
						default:
							putchar(10);
							goto gfm2;
							break;
						}
					gff2:
					printf("\n\nIs The Grand Father From The Father Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							F.Grandfather_from_father = true;
							break;
						case 'N':
						case 'n':
							F.Grandfather_from_father = false;
							break;
						default:
							putchar(10);
							goto gff2;
							break;
						}
					gmm2:
					printf("\n\nIs The Grand Mother From The Mother Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							F.Grandmother_from_mother = true;
							break;
						case 'N':
						case 'n':
							F.Grandmother_from_mother = false;
							break;
						default:
							putchar(10);
							goto gmm2;
							break;
						}
					gmf2:
					printf("\n\nIs The Grand Mother From The Father Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							F.Grandmother_from_father = true;
							break;
						case 'N':
						case 'n':
							F.Grandmother_from_father = false;
							break;
						default:
							putchar(10);
							goto gmf2;
							break;
						}

					hsb:
					printf("\n\nIs The Husbend Alive ? (Y)es OR (N)o ");
					ch2 = getche();
						switch (ch2)
						{
						case 'y':
						case 'Y':
							F.Husbend = true;
							break;
						case 'N':
						case 'n':
							F.Husbend = false;
							break;
						default:
							putchar(10);
							goto hsb;
							break;
						}
					printf("\n\nHow Many Brothers : ");
					scanf("%i",&F.Brothers);
					printf("\nHow Many Sisters : ");
					scanf("%i",&F.Sisters);
					printf("\nHow Many Brothers From Father Only : ");
					scanf("%i",&F.Brothers_from_father);
					printf("\nHow Many Brothers From Mother Only : ");
					scanf("%i",&F.Brothers_from_mother);
					printf("\nHow Many Sisters From Father Only : ");
					scanf("%i",&F.Sisters_from_father);
					printf("\nHow Many Sisters From Mother Only : ");
					scanf("%i",&F.Sisters_from_mother);
					printf("\nHow Many Uncles From Mother : ");
					scanf("%i",&F.Uncle_from_mother);
					printf("\nHow Many Uncles From Father : ");
					scanf("%i",&F.Uncle_from_father);
					printf("\nHow Many Anuts From Mother : ");
					scanf("%i",&F.Anut_from_mother);
					printf("\nHow Many Anuts From Father : ");
					scanf("%i",&F.Anut_from_father);
					break;
					default:
						putchar(10);
						goto MoF;
				}
			}
		}
	}
	if (ch == 'f' || ch == 'F')
	{
		printf("\n\nThe Dead Person is A Female");
		if (F.Husbend == true) printf(" , Her Husbend is Alive");
		if (F.Sons > 1) printf(" , She Has %i Sons",F.Sons);
		if (F.Sons == 1) printf(" , She Has One Son");
		if (F.Daughters > 1) printf(" , %i Daughters",F.Daughters);
		if (F.Daughters == 1) printf(" , One Daughter");
		if (F.Sons_from_daughters + F.Sons_from_sons + 
			F.Daughters_from_daughters + F.Daughters_from_sons > 1)
			{
			printf(" , She Has %i Grand Children",F.Sons_from_daughters + F.Sons_from_sons + 
			F.Daughters_from_daughters + F.Daughters_from_sons);
			if (F.Sons_from_sons > 1) printf(" , %i Grand Sons Are From Her Sons",F.Sons_from_sons);
			if (F.Sons_from_sons == 1) printf(" , One Grand Son Is From Her Son");
			if (F.Sons_from_daughters > 1) printf(" , %i Sons are From Her Daughters",F.Sons_from_daughters);
			if (F.Sons_from_daughters == 1) printf(" , One Son Is From Her Daughter");
			if (F.Daughters_from_sons > 1) printf(" , %i Daughters Are From Her Sons",F.Daughters_from_sons);
			if (F.Daughters_from_sons == 1) printf(" , One Daughter Is From Her Son");
			if (F.Daughters_from_daughters > 1) printf(" , %i Daughters Are From Her Daughters",F.Daughters_from_daughters);
			if (F.Daughters_from_daughters == 1) printf(" , One Daughter Is From Her Daughter");
			}
		if (F.Sons_from_daughters + F.Sons_from_sons + 
			F.Daughters_from_daughters + F.Daughters_from_sons == 1)
			{
			if (F.Sons_from_sons == 1) printf(" , She Has One Grand Son From Her Son");
			if (F.Sons_from_daughters == 1) printf(" , She Has One Son From Her Daughter");
			if (F.Daughters_from_sons == 1) printf(" , She Has One Daughter From Her Son");
			if (F.Daughters_from_daughters == 1) printf(" , She Has One Daughter From Her Daughter");
			}
		if (F.Brothers + F.Brothers_from_father + F.Brothers_from_mother)
			{
			printf(" , She Has %i Brothers",F.Brothers + F.Brothers_from_father + F.Brothers_from_mother);
			if (F.Brothers_from_father > 1) printf(" , %i Brothers Are From Her Father Only",F.Brothers_from_father);
			if (F.Brothers_from_father == 1) printf(" , One Brothers Is From Her Father Only");
			if (F.Brothers_from_mother > 1) printf(" , %i Brothers Are From Her Mother Only",F.Brothers_from_mother);
			if (F.Brothers_from_mother == 1) printf(" , One Brothers Is From Her Mother Only");
			}
		if (F.Sisters + F.Sisters_from_father + F.Sisters_from_mother)
			{
			printf(" , She Has %i Sisters",F.Sisters + F.Sisters_from_father + F.Sisters_from_mother);
			if (F.Sisters_from_father > 1) printf(" , %i Sisters Are From Her Father Only",F.Sisters_from_father);
			if (F.Sisters_from_father == 1) printf(" , One Brothers Is From Her Father Only");
			if (F.Sisters_from_mother > 1) printf(" , %i Sisters Are From Her Mother Only",F.Sisters_from_mother);
			if (F.Sisters_from_mother == 1) printf(" , One Sisters Is From Her Mother Only");
			}
		if (F.Mother == false) printf(" , Her Mother Is Dead");
		if (F.Mother == true) printf(" , Her Mother Is Alive");
		if (F.Father == false) printf(" , Her Father Is Dead");
		if (F.Father == true) printf(" , Her Father Is Alive");
		if (F.Grandfather_from_father == true) printf(" , Her Grand Father From Her Father\'s Side is Alive");
		if (F.Grandmother_from_father == true) printf(" , Her Grand Mother From Her Father\'s Side is Alive");
		if (F.Grandfather_from_mother == true) printf(" , Her Grand Father From Her Mother\'s Side is Alive");
		if (F.Grandmother_from_mother == true) printf(" , Her Grand Mother From Her Mother\'s Side is Alive");
		if (F.Uncle_from_father > 1) printf(" , She Has %i Uncles From Her Father\'s Side",F.Uncle_from_father);
		if (F.Uncle_from_father == 1) printf(" , She Has One Uncle From Her Father\'s Side");
		if (F.Uncle_from_mother > 1) printf(" , She Has %i Uncles From Her Mother\'s Side",F.Uncle_from_mother);
		if (F.Uncle_from_mother == 1) printf(" , She Has One Uncle From Her Mother\'s Side");
		if (F.Anut_from_father > 1) printf(" , She Has %i Anuts From Her Father\'s Side",F.Anut_from_father);
		if (F.Anut_from_father == 1) printf(" , She Has One Anut From Her Father\'s Side");
		if (F.Anut_from_mother > 1) printf(" , She Has %i Anuts From Her Mother\'s Side",F.Anut_from_mother);
		if (F.Anut_from_mother == 1) printf(" , She Has One Anut From Her Mother\'s Side");
	}
	if (ch == 'm' || ch == 'M')
	{
		printf("\n\nThe Dead Person is A Male");
		if (M.Wife == 1) printf(" , He Has A Wife");
		if (M.Wife > 1) printf(" , He Has %i Wives",M.Wife);
		if (M.Sons > 1) printf(" , He Has %i Sons",M.Sons);
		if (M.Sons == 1) printf(" , He Has One Son");
		if (M.Daughters > 1) printf(" , %i Daughters",M.Daughters);
		if (M.Daughters == 1) printf(" , One Daughter");
		if (M.Sons_from_daughters + M.Sons_from_sons + 
			M.Daughters_from_daughters + M.Daughters_from_sons > 1)
			{
			printf(" , He Has %i Grand Children",M.Sons_from_daughters + M.Sons_from_sons + 
			M.Daughters_from_daughters + M.Daughters_from_sons);
			if (M.Sons_from_sons > 1) printf(" , %i Grand Sons Are From His Sons",M.Sons_from_sons);
			if (M.Sons_from_sons == 1) printf(" , One Grand Son Is From His Son");
			if (M.Sons_from_daughters > 1) printf(" , %i Sons are From His Daughters",M.Sons_from_daughters);
			if (M.Sons_from_daughters == 1) printf(" , One Son Is From His Daughter");
			if (M.Daughters_from_sons > 1) printf(" , %i Daughters Are From His Sons",M.Daughters_from_sons);
			if (M.Daughters_from_sons == 1) printf(" , One Daughter Is From His Son");
			if (M.Daughters_from_daughters > 1) printf(" , %i Daughters Are From His Daughters",M.Daughters_from_daughters);
			if (M.Daughters_from_daughters == 1) printf(" , One Daughter Is From His Daughter");
			}
		if (M.Sons_from_daughters + M.Sons_from_sons + 
			M.Daughters_from_daughters + M.Daughters_from_sons == 1)
			{
			if (M.Sons_from_sons == 1) printf(" , He Has One Grand Son From His Son");
			if (M.Sons_from_daughters == 1) printf(" , He Has One Son From His Daughter");
			if (M.Daughters_from_sons == 1) printf(" , He Has One Daughter From His Son");
			if (M.Daughters_from_daughters == 1) printf(" , He Has One Daughter From His Daughter");
			}
		if (M.Brothers + M.Brothers_from_father + M.Brothers_from_mother)
			{
			printf(" , He Has %i Brothers",M.Brothers + M.Brothers_from_father + M.Brothers_from_mother);
			if (M.Brothers_from_father > 1) printf(" , %i Brothers Are From His Father Only",M.Brothers_from_father);
			if (M.Brothers_from_father == 1) printf(" , One Brothers Is From His Father Only");
			if (M.Brothers_from_mother > 1) printf(" , %i Brothers Are From His Mother Only",M.Brothers_from_mother);
			if (M.Brothers_from_mother == 1) printf(" , One Brothers Is From His Mother Only");
			}
		if (M.Sisters + M.Sisters_from_father + M.Sisters_from_mother)
			{
			printf(" , He Has %i Sisters",M.Sisters + M.Sisters_from_father + M.Sisters_from_mother);
			if (M.Sisters_from_father > 1) printf(" , %i Sisters Are From His Father Only",M.Sisters_from_father);
			if (M.Sisters_from_father == 1) printf(" , One Brothers Is From His Father Only");
			if (M.Sisters_from_mother > 1) printf(" , %i Sisters Are From His Mother Only",M.Sisters_from_mother);
			if (M.Sisters_from_mother == 1) printf(" , One Sisters Is From His Mother Only");
			}
		if (M.Mother == false) printf(" , His Mother Is Dead");
		if (M.Mother == true) printf(" , His Mother Is Alive");
		if (M.Father == false) printf(" , His Father Is Dead");
		if (M.Father == true) printf(" , His Father Is Alive");
		if (M.Grandfather_from_father == true) printf(" , His Grand Father From His Father\'s Side is Alive");
		if (M.Grandmother_from_father == true) printf(" , His Grand Mother From His Father\'s Side is Alive");
		if (M.Grandfather_from_mother == true) printf(" , His Grand Father From His Mother\'s Side is Alive");
		if (M.Grandmother_from_mother == true) printf(" , His Grand Mother From His Mother\'s Side is Alive");
		if (M.Uncle_from_father > 1) printf(" , He Has %i Uncles From His Father\'s Side",M.Uncle_from_father);
		if (M.Uncle_from_father == 1) printf(" , He Has One Uncle From His Father\'s Side");
		if (M.Uncle_from_mother > 1) printf(" , He Has %i Uncles From His Mother\'s Side",M.Uncle_from_mother);
		if (M.Uncle_from_mother == 1) printf(" , He Has One Uncle From His Mother\'s Side");
		if (M.Anut_from_father > 1) printf(" , He Has %i Anuts From His Father\'s Side",M.Anut_from_father);
		if (M.Anut_from_father == 1) printf(" , He Has One Anut From His Father\'s Side");
		if (M.Anut_from_mother > 1) printf(" , He Has %i Anuts From His Mother\'s Side",M.Anut_from_mother);
		if (M.Anut_from_mother == 1) printf(" , He Has One Anut From His Mother\'s Side");
	}
	ind:
	putchar(10);
	return 0;
}