about-text

SoftOSet is the most remarkable programming site. SoftOSet provides the fresh conceptual and professional programs, articles, books, and other interesting and technical writings. SoftOSet is the most reliable programming site to learn the programs and the basics of the popular programming languages. SoftOSet is the hub of the informative and research based articles.

Program to Top K2 Mountain using the C and C++ Language

 

 

The programming is all about fun and passion. It’s passion that enforces you to perform different things. We have decided to make a program in both C++ and C language which will give the user his estimated days in which he could top the K@ mountain. User has to get his days, just need to enter his per day travel in meters.

 

Logic

So what’s logic behind, very simple. Everybody knows that K2 is 8611 meter high. So height is already known to us. We have to find the days, if we find the per day traveling of a person we will add again and again his per day traveling and repeatedly increment the days. We will store the repeated addition of per day traveling in top and when top reaches the height we have the days in which we can top the K2. That’s it.

Now below is the code and output in C language first and then in C++.

 

Program to Top K2 Mountain using the C Language

 

Code

//date 30 january 2019

//program to Estimate the number of days to top the k2 when per day traveling distance is given by user

 

#include<stdio.h>

int main()

{

           

            int height=8611,perday_distance,days,top=0;

            printf("Enter the Distance You Travel Perday in Meters\n To Estimate the Your Time To Top the \nK2 Mountain\n");

            scanf("%d",&perday_distance);

            for(days=0;top<height;days++)

     top+=perday_distance;

            printf("You will Top the k2 in  About %d Days ",days);

            return 0;

}

 

 

Output

And here is the output of the above code

 

 

 

 

 

Program to Top K2 Mountain using the C++ Language

 

Code

//date 30 january 2019

//program to Estimate the number of days to top the k2 when per day traveling distance is given by users

#include<iostream>

using namespace std;

int main()

{

           

            int height=8611,perday_distance,days,top=0;

            cout<<"Enter the Distance You Travel Per day in Meters\n To Estimate the Your Time To Top the \nK2 Mountain"<<endl;

            cin>>perday_distance;

            for(days=0;top<height;days++)

     top+=perday_distance;

            cout<<"You will Top the k2 in  About "<<days<<" Days "<<endl;

            return 0;

}

 

Output

On executing this code we have got the following output.

 

 

 

 

 

 

In the end I hope that you will easily understand this code. If you have any trouble regarding this code feel free to contact us and comment us to help you.

 

Thanks for using this site.

 

 

 

 


Post a Comment

Feel Free to Comment Us

Previous Post Next Post

Recents