Results 1 to 2 of 2

Thread: C++ programming

  1. #1

    Default C++ programming


    Guys help naman ohhh.... pki gawa naman ako ng programm...
    Activity namin to sa skul.. di ko magawa ehh.. ang hirap...


    Write a complete C program that will display the highest common factor of two numbers.

    The highest common factor (HCF) of two positive integers a and b is the largest integer that
    divides each of a and b exactly. For example, the HCF of 45 and 30 is 15.

    Here is a form of Euclid's algorithm for finding the HCF of two integers. Let's say we want
    to find the HCF of 36 and 90.

    · Write down the numbers: 36 90

    · ... and also write down their difference: 36 90 54

    · Form a "number chain" by repeatedly writing down the difference between the last
    two numbers, stopping when you get to zero. The last non-zero number is the HCF:

    · 36 90 54 36 18 18 0

    · The HCF of 36 and 90 is 18. (tip: use absolute value)

    Example:
    Input: 30 45
    Output: 15

  2. #2
    #include <iostream>
    using namespace std;
    main(){
    int first, second, buffer;
    cout<<"enter number 1:"<<endl;
    cin>>first;
    cout<<"enter number 2:"<<endl;
    cin>>second;

    while( first - second != 0 ){
    buffer = abs(second);
    second = abs(abs(first)-abs(second));
    first = abs(buffer);
    cout<< first << endl;


    }
    cout<< "Greatest Common Factor is: " << first <<endl;
    cin.ignore(10000);
    }















    try daw nih.. hihi.. noobs pa ko..

  3.    Advertisement

Similar Threads

 
  1. Replies: 10799
    Last Post: 09-19-2020, 06:06 PM
  2. what is your favorite programming language?
    By sachem in forum Programming
    Replies: 310
    Last Post: 10-08-2015, 03:11 PM
  3. XDA2: file shortcut not removed after program uninstalled
    By c_cebrecus in forum Gizmos & Gadgets (Old)
    Replies: 5
    Last Post: 05-28-2008, 02:10 AM
  4. excel programs; needs help guys!!!
    By rufo in forum Software & Games (Old)
    Replies: 3
    Last Post: 01-14-2006, 12:18 PM
  5. Web programming like PHP, ASP, HTML AND FLASH ANIMATIONS
    By michaxze in forum Websites & Multimedia
    Replies: 10
    Last Post: 07-30-2005, 05:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top