C, C++, etc Programing examples. Post as many you can. Test the programs and discuss about the output of the programes.
Forum rules
Please Discuss & post only about the programes and its Output
by aniketkumar » Fri Oct 21, 2011 3:33 pm
source : http://www.cppforschool.com/assignments.htmlcompiler : Turbo C++ under Dos
program : C++ program to calculate hcf of two given number
- Code: Select all
#include<iostream.h>
#include<conio.h>
int main()
{
int dividend,divisor,rem,hcf;
cout<<"Enter two numbers ";
cin>>dividend>>divisor;
while(rem!=0)
{
rem=dividend%divisor;
if(rem==0)
hcf=divisor;
else
{
dividend=divisor;
divisor=rem;
}
}
cout<<"HCF is :"<<hcf;
return 0;
}
-
aniketkumar
- Registered User
-
- Posts: 6
- Joined: Fri Oct 14, 2011 12:30 pm
- Location: Ghaziabad
- membership: Affiliate Member of The Institution of Engineers (India)- AFM
-
Return to Computer Notes : Some Sample Programs
Who is online
Users browsing this forum: No registered users and 0 guests