This action might not be possible to undo. Are you sure you want to continue?

BooksAudiobooksComicsSheet Music### Categories

### Categories

### Categories

### Publishers

Scribd Selects Books

Hand-picked favorites from

our editors

our editors

Scribd Selects Audiobooks

Hand-picked favorites from

our editors

our editors

Scribd Selects Comics

Hand-picked favorites from

our editors

our editors

Scribd Selects Sheet Music

Hand-picked favorites from

our editors

our editors

Top Books

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Audiobooks

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Comics

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Sheet Music

What's trending, bestsellers,

award-winners & more

award-winners & more

P. 1

Write a Program That Will Find the Highest Common Factor ,Prime Number and Maximum Devisor.|Views: 515|Likes: 17

Published by Muhammad Rana Farhan

See more

See less

https://www.scribd.com/doc/24406191/Write-a-Program-That-Will-Find-the-Highest-Common-Factor-Prime-Number-and-Maximum-Devisor

10/19/2012

text

original

**and maximum devisor.
**

i.e. press 1 for HFC

press 2 for Prime Number

press 3 for greatest common devisor

============================================

#include<iostream.h>

#include<conio.h>

void main()

{

int a=0;

while(a!=3)

{

cout<<"[1] for maths\n";

cout<<"[2] for diagrams\n";

cout<<"[3] for Exit\n";

cin>>a;

if(a==1)

{

while(a!=4)

{

cout<<"[1] for Greates common Devisor\n";

cout<<"[2] for check prime number\n";

cout<<"[3] for maximum devisor \n";

cout<<"[4] for go to main menu\n";

cin>>a;

if(a==1)

{

cout<<"\t\t GREATEST COMMON

DEVISOR\n";

int a,b,c,d,gcd=0;

cout<<"Enter three integers";

cin>>a>>b>>c;

if(a>=b && a>=c)

d=a;

else if(b>=a && b>=c)

d=b;

else if(c>=a && c>=b)

d=c;

for(int i=1; i<=d; i++)

if((a%i)==0 && (b%i)==0 &&

(c%i)==0)

gcd=i;

cout<<"GCD is "<<gcd<<"\n\n\n";

cout<<"press any key to return menu\n";

getche();

}

if(a==2)

{

cout<<"\t\t PRIME NUMBER\n";

int a,flag=0;

cout<<"Enter any number";

cin>>a;

for(int i=2; i<a; i++)

{

if((a%i)==0)

{

flag=1;

break;

}

}

if(flag==0)

cout<<"Number is prime\n\n\n\n";

else

cout<<"Number is not

Prime\n\n\n";

cout<<"press any key to return menu\n";

getche();

}

if(a==3)

{

cout<<"\t\t MAXIMUM DEVISOR\n";

int a,b,rem;

cout<<"Enter two values";

cin>>a>>b;

if(a>b)

{

rem=a%b;

a-=rem;

a/=b;

cout<<"\n"<<a;

}

cout<<"press any key to return menu\n";

getche();

}

}

}

if(a==2)

{

while(a!=3)

{

cout<<"[1] for box\n";

cout<<"[2] for diamond\n";

cout<<"[3] for go to main menu\n";

cin>>a;

if(a==1)

{

cout<<"\t\t BOX\n";

int width,height;

cout<<"Enter width and height";

cin>>width>>height;

for(int i=0; i<width; i++)

cout<<"*";

cout<<endl;

for(i=0; i<height-2;i++)

{

cout<<"*";

for(int j=0; j<width-2;j++)

cout<<" ";

cout<<"*";

cout<<endl;

}

for(i=0; i<width; i++)

cout<<"*";

cout<<"\n\n\n\n";

cout<<"press any key to return menu\n";

getche();

}

if(a==2)

{

cout<<"\t\t DIAMOND\n";

int a;

cin>>a;

a/=2;

for(int i=0;i<a;i++)

cout<<" ";

cout<<"*\n";

for(int line=1; line<a; line++)

{

for(int space=a; space>line; space--

)

{

cout<<" ";

}

cout<<"*";

for(int counter=0;

counter<(line+line-1); counter++)

{

cout<<" ";

}

cout<<"*";

cout<<endl;

}

for(int line1=a; line1>0; line1--)

{

for(int space1=a; space1>line1;

space1--)

{

cout<<" ";

}

cout<<"*";

for(int counter1=0;

counter1<(line1+line1-1);

counter1++)

{

cout<<" ";

}

cout<<"*";

cout<<endl;

}

for(i=0;i<a;i++)

cout<<" ";

cout<<"*\n";

cout<<"press any key to return menu\n";

getche();

}

if(a==3)

{

a=0;

break;

}

}

}

}

}

http://www.ravianeducation.blogspot.com

FARHAN: 03008855006

Function Add Sub Mul Div

Function Print Table

Function Print Factorial

Function Hello World

Teachers Evaluation

Neural Networks

Multi Layer Perceptrons

9th Rav

Date Sheet 10th

Time Table

Tentative Course Outline for C Section

Ravian Education Campus - Teacher Evaluation Form

Inter part 2 - C-Section Test - Objective Part

Ravian Education Campus - Teacher Evaluation Form

Normalization Assignment

Assignment 3(SQL)

Assignment 2(SQL)

SQL First Quize

String Tokenize - JAVA

Parking Example - JAVA

Java 2 - Assignment

Java 1 Assignment

Data Save - Java

Client Server - Java

Graphical Calculator - JAVA

- Read and print without ads
- Download to keep your version
- Edit, email or read offline

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

CANCEL

OK

You've been reading!

NO, THANKS

OK

scribd

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->