Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
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:

More info:

Published by: Muhammad Rana Farhan on Dec 22, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





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";

Activity (19)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
gefinna liked this
gefinna liked this
linkjiten liked this
syriluit liked this
Pum Symon liked this
Anurag Goel liked this
sankumi liked this
swathir007 liked this

You're Reading a Free Preview

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