473,385 Members | 1,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Composite and Prime Numbers

this was my and my frineds little project in earlier classes,
the program seperates the composite and prime numbers in two sections
of the screen
=====================

/*
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;
}
/*========================*/

Jul 23 '05 #1
0 2371

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Dag | last post by:
Is there a python module that includes functions for working with prime numbers? I mainly need A function that returns the Nth prime number and that returns how many prime numbers are less than N,...
9
by: Greg Brunet | last post by:
In doing some testing of different but simple algorithms for getting a list of prime numbers, I ended up getting some results that seem a bit contradictory. Given the following test program...
11
by: don | last post by:
Ok, this is a homework assignment, but can you help me out anyway...... I need a routine for figuring out if a number inputted by the user is a prime number or not...... all I'm asking for is Not...
0
by: ETM11871 | last post by:
i need to develop a code that finds a prime right number between 2 and 100000. and print one line of text that indicates if the int. is right prime. i am in beginning programing so complex is...
25
by: johnmsimon | last post by:
i need to develop a code that finds a prime right number between 2 and 100000. and print one line of text that indicates if the int. is right prime. i am in beginning programing so complex is...
60
by: rhle.freak | last post by:
Here is my code to generate prime numbers.It works absolutely fine when the range is *not very large*. However on initializing i with a large integer it produces erroneous results (some numbers...
7
by: newstips6706 | last post by:
1, 2, 3, 5, 7... PRIME Numbers ________________________________ Definitions What is a PRIME Number ?
7
by: Caffiend | last post by:
Well, I've been picking at learning python, got tired of reading, and figured I'd try to replicate my prime number generator I wrote (with much TSDN forum help) in C++. I've hit a stumbling block......
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.