Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Write a Program That Will Find the Highest Common Factor ,Prime Number and Maximum Devisor.

# Write a Program That Will Find the Highest Common Factor ,Prime Number and Maximum Devisor.

Ratings: (0)|Views: 515 |Likes:

### Availability:

See more
See less

10/19/2012

pdf

text

original

Write a program that will find the highest common factor ,prime numberand maximum devisor.i.e. press 1 for HFCpress 2 for Prime Numberpress 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 COMMONDEVISOR\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";elsecout<<"Number is notPrime\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";