google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.

Saturday, March 15, 2014

Program to find GCD of two numbers

#include<iostream.h>
int main()
{
int first_number,second_number,gcd,i;
cout<<"Enter First Number : ";
cin>>first_number;

cout<<"Enter Second Number: ";
cin>>second_number;

for(i=1;i<=first_number&&i<=second_number;i++)
{

     if(first_number%i==0 && second_number%i == 0 )
{
                     gcd=i;

    }

}

cout<<"Greatest Common Division (GCD):"<<gcd<<endl;
return 0;
}

******Output******
Enter First Number: 9
Enter Second Number: 24
Greatest Common Division (GCD):3 

What is GCD of two numbers?
 It means a greatest number which divides both numbers
For example: Two numbers are 9 and 24
Numbers which divides both are 1 and 3 in which greatest number is 3
So 3 is the GCD of 9 and 24

Click here for more programs on C++

Monday, March 3, 2014

Program in C++ to count heart beats of a person by its age from born

# include <iostream.h>
int main()
{
int age,heartbeats;
cout<<"Enter Age: ";
cin>>age;
cout<<"Enter Number of Heartbeats per min: ";
cin>>heartbeats;

heartbeats = heartbeats * 60; //heartbeats per hour

heartbeats = heartbeats * 24; //heartbeats per day

heartbeats = heartbeats * 365; //heartbeats per year

cout<<"Your Heart has beat "<<heartbeats * age<<" times since you were born."<<endl;

return 0;
}

-----------------------OUTPUT---------------------
 Enter Age: 26
 Enter Number of Heartbeats per min: 70
 Your Heart has beat  956592000  times since you were born.

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...