...

View Full Version : A prime and Composite seperating program, controlling screen as well



Ashif
04-24-2004, 11:06 AM
/*
This program has been made by A & A Group.
Muhammad Ali: Roll # 1462 Class A-2 , B.Sc.(Hons.) in C.S.
Ashif Zubair: Roll # 1468 Class A-2 , B.Sc.(Hons.) in C.S.
ALL RIGHTS ARE RESERVED TO A & A Group.

CAUTION!
THIS PROGRAM IS PROTECTED BY LAWS AND COPYRIGHTS.
AS DESCRIBED IN TERM AND CONDITIONS SPECIFIED AT THE END.
COPYRIGHT 2003 - 2004, A & A GROUP. ALL RIGHTS ARE RESERVED.
*/

#include <iostream.h>
#include <conio.h>
#include <dos.h>

#define WASH 10
//ERASING SPEED OF NUMBERS IN MILLISECONDS. IT MUST BE AN INTEGER VALUE.
#define SPEED 10
//THE SPEED IN MILLISECONDS FOR DISPLAYING THE COMPOSITE OR PRIME NUMBERS.
#define SECOND 10
//TIME IN SECONDS, USED TO REDIRECT OR TERMINATE THE PROGRAM. MUST BE AN INTEGER VALUE.
#define PAGE 2
//TIME IN SECONDS, BEFORTE THE LIST IS ERASED FROM SCREENS.MUST BE AN INTEGER VALUE.


void composite (unsigned long int num); //Composite function decleration.
void prime (unsigned long int num); //prime function deleration.
void erase (int , int); //Erase function decleration.
void display (void); //function which shows displayed and remaining numbers.
void warning (void); //Warning function decleration
void a_a (void); //Function to display A&A Logo.
int agree (void); //Agreement function declaration.

unsigned long int start,end,z,divisor; //For Filteration Section.
int p_row,p_coloum,p_page,p_total, //For Prime Section.
c_row,c_coloum,c_page,c_total, //For Composite Section.
term,time=PAGE; //For Terms and Conditions and Controlling Time.
char again; //Character Type Data for Iteration of program.
// MAIN FUNCTION STARTS.
void main (void)
{
clrscr();
warning(); //Calling Function
int count;
for(count = SECOND;count>=0;count--)
{
gotoxy(19,34);
cout<<"YOU WILL BE REDIRECTED IN SECONDS : "<<count<<" \b";
delay(1000);
}
term = agree();
if(term==1)
{
do
{
p_row = c_row = 5;
p_total = c_total = 0;
p_page = c_page = 1;
p_coloum = 2;
c_coloum = 45;
clrscr();
cout<<"Enter Starting Value = ? ";cin>>start;
gotoxy(45,1);
cout<<"Enter Ending Value = ? ";cin>>end;
gotoxy(10,3);
cout<<"PRIME";
gotoxy(53,3);
cout<<"COMPOSITE";
gotoxy(50,48);
// Page number & total for composite.
delay(5);
cout<<"Total = "<<c_total;
gotoxy(65,48);
cout<<"Page # "<<c_page;
gotoxy(2,48);
// Page number & total for prime.
delay(5);
cout<<"Total = "<<p_total;
gotoxy(18,48);
cout<<"Page # "<<p_page;
if(start<=end&&start>=2)
{
for(z=start;z<=end;z++)
{
for(divisor = 2 ; divisor <= z ; divisor++)
{
if(z%divisor==0 && divisor != z)
{
composite(z);
break;
}
if(divisor == z)
{
prime(z);
break;
}
}
}
}
else
{
gotoxy(30,25);
cout<<"Invalid Input";
}
gotoxy(15,50);
cout<<"Enter [Y / y] to do again or [X / x] to quit = ? ";
cin>>again;
}while(again == 'y' || again == 'Y');
a_a();
warning();
for(count = SECOND;count>=0;count--)
{
gotoxy(19,34);
cout<<"PROGRAM WILL TERMINATE IN SECONDS : "<<count<<" \b";
delay(1000);
}
}
else
{
for(count = SECOND ; count >= 0 ; count--)
{
gotoxy(19,25);
cout<<"PROGRAM WILL TERMINATE IN SECONDS : "<<count<<" \b";
delay(1000);
}
}
}

/*
COMPOSITE FUNCTION DEFINATION STARTS.
*/
void composite (unsigned long int num)
{
gotoxy(c_coloum,c_row);
delay(SPEED);
cout<<num;
c_row++;
c_total++;
display();
if(c_row == 47)
{
c_row = 5;
c_coloum += 5;
if(c_coloum == 70)
{
c_row = 5;
c_coloum = 45;
c_page++;
for(time=PAGE;time;time--)
{
gotoxy(20,50);
cout<<"New Composite page will load in "<<time-1<<" seconds...";
delay(1000);
}
erase (c_row,c_coloum);
c_row = 5;
c_coloum = 45;
}
}
gotoxy(50,48);
delay(5);
cout<<"Total = "<<c_total;
gotoxy(65,48);
cout<<"Page # "<<c_page;

}

/*
PRIME FUNCTION DEFINATION STARTS
*/
void prime (unsigned long int num)
{
gotoxy(p_coloum,p_row);
delay(SPEED);
cout<<num;
p_row++;
p_total++;
display();
if(p_row == 47)
{
p_row = 5;
p_coloum += 5;
if(p_coloum == 27)
{
p_row = 5;
p_coloum = 2;
p_page++;
for(time=PAGE;time;time--)
{
gotoxy(20,50);
cout<<"New Prime page will load in "<<time-1<<" seconds...";
delay(1000);
}
erase (p_row,p_coloum);
p_row = 5;
p_coloum = 2;
}
}
gotoxy(2,48);
delay(5);
cout<<"Total = "<<p_total;
gotoxy(18,48);
cout<<"Page # "<<p_page;
}

/*
ERASE FUNCTION DEFINATION STARTS
*/
void erase (int row, int coloum)
{
int test = coloum;
while(1)
{
if(coloum != test + 25)
{
gotoxy(coloum,row);
cout<<" ";
delay(WASH);
row++;
if(row == 47)
{
row = 5;
coloum += 5;
}
}
else
break;
}
gotoxy(20,50);
for(test=20;test<=66;test++)
{
cout<<" ";
delay(5);
}
}

// Display , Remaining function Defination.
void display ()
{
gotoxy(30,21);
cout<<"Displayed";
gotoxy(30,22);
cout<<"---------";
gotoxy(30,24);
cout<<(c_total+p_total)<<"/"<<(end-start)+1;
gotoxy(30,26);
cout<<"Remaining";
gotoxy(30,27);
cout<<"---------";
gotoxy(32,29);
cout<<((end-start)+1)-(c_total+p_total);
}

// Warning Function
void warning(void)
{
gotoxy(13,16);
cout<<" WARNING!";
gotoxy(13,20);
cout<<"THIS PROGRAM IS PROTECTED BY THE LAW'S AND COPYRIGHT";
gotoxy(13,22);
cout<<" AS STATED IN THE ABOUT SECTION IN SOURCE CODE";
gotoxy(13,24);
cout<<" ---------------------------------------------";
gotoxy(13,26);
cout<<" COPYRIGHT 2003 - 2004,\"A&A\" PROGRAMERS.";
gotoxy(13,28);
cout<<" ALL RIGHTS ARE RESERVED.";
}


void a_a(void)
{
clrscr();
gotoxy(10,1);
cout<<" IT'S AN";gotoxy(13,3);
cout<<" ******* ******** ******** " ;gotoxy(13,4);
cout<<" ********** ********** ********** " ;gotoxy(13,5);
cout<<" *** *** *** *** *** *** " ;gotoxy(13,6);
cout<<" *** *** *** *** *** *** " ;gotoxy(13,7);
cout<<" ************ ***** ************ " ;gotoxy(13,8);
cout<<" ************ ******* ************ " ;gotoxy(13,9);
cout<<" *** *** **** *** *** *** " ;gotoxy(13,10);
cout<<" *** *** *** ***** *** *** " ;gotoxy(13,11);
cout<<" *** *** ******* *** *** *** *** " ;gotoxy(13,12);
cout<<" *** *** ********* *** *** *** " ;gotoxy(15,14);
cout<<" PRODUCTION! " ;
}

// TERMS AND CONDITIONS FOR USING THE PROGRAM.
int agree(void)
{
int law;
clrscr();
gotoxy(1,7);
cout<<"COPYRIGHT AND LAWS IN USING THIS PROGRAM"<<endl<<endl
<<"1. NO ONE OTHER THAN \"A&A\" GROUP IS ELIGIBLE TO MAKE ANY CHANGE IN THIS "<<endl<<endl
<<" PROGRAM UNLESS A WRITTEN PERMISSIONS IS OBRAINED FROM \"A&A\" GROUP."<<endl<<endl<<endl
<<"2. THIS PROGRAM IS FREE TO USE AND DISTRIBUTE UNTILL ANY SORT OF MODIFICATION"<<endl<<endl
<<" IS DONE INCLUDING CHANGING THE LAWS AND PROGRAMMERS CREDIT."<<endl<<endl<<endl
<<"3. \"A&A\" GROUP WILL NOT BE HELD RESPONISIBLE FOR ANY UDESIERABLE"<<endl<<endl
<<" EFFECT ON THE COMPUTER AFTER EXECUTING THIS PROGRAM,"<<endl<<endl<<endl
<<"4. \"A&A\" GROUP IS ELIGIBLE TO MAKE CHANGE IN LAWS & COPYRIGHT"<<endl<<endl
<<" WITH OR WITHOUT NOTIFICATION."<<endl<<endl<<endl
<<"5. APPROPRIATE ACTION WILL BE TAKEN AGAINST THE PERSON VOILATING"<<endl<<endl
<<" ANY OF THE CONDITIONS."<<endl<<endl<<endl
<<" COPYRIGHT 2003-2004, A & A - ALL RIGHTS ARE RESERVED."<<endl<<endl<<endl
<<" YOU MUST AGREE THE TERMS AND CONDITION IN ORDER TO USE THE PROGRAM"<<endl<<endl<<endl
<<"1: Agree ?\t 2: Disagree ?\n\nSelect Option 1 OR 2 ?\t";
cin>>law;
clrscr();
return law;
}


===============
the void a_a (void) function may look distorched here, but its A & A written with stars. hope u like the effort and program
it was my assignment.

Ashif
04-25-2004, 03:44 AM
wHATFURTHUR ENHANCEMENTS U PPL THINK CAN BE MADE IN THIS PROGRAM.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum