C++ tutorial, C++ programs, C++ Exercises, C++ Example Programs

Friday, April 6, 2012

Program Age Years To Days Convert

Today, we will discuss the logic of a simple C++ Program to input age in Years and Convert into Days. This is a simple C++ logic program. Simply we will multiply the years entered by user by 365 to convert years into  days.

a) Program Requirements: Input your age in years, convert it into days and show the result.

Let's write down an algorithm first

b) Algorithm: Convert-Years-To-Days

  1. Start 
  2. Input Your age in years 
  3. Calculate days = years X 365 
  4. Output "Your age in days=" , days 
  5. Stop




    c). Flow Chart: Convert Years Into Days





    d.) Picture of C++ Program Years to days conversion from Turbo C++ 3.0 IDE


    C++ Program Convert your Age from Years to days conversion


    e). Program coding.


    #include <iostream.h>
    #include <conio.h>
    void main()
    {
        // Declare two integer variables(for whole numbers)
        int years, days;
       // clear output screan and display message to user for input
        clrscr();
        cout<<"\n Enter Your Age in Years=";
        // get input from user
        cin>>years;
        //calculate days
        days = years * 365;
        //display output message to user showing age in days
        cout<<"\n Your age in days="<<days;
        // make output screen stay as long as a character key is pressed
        getch();
    }

    f).Program sample run output: 

    C++ Program Convert your Age from Years to days conversion 


    Enter Your Age in Years=17
    Your age in days=6205
    Share:

    0 comments:

    Post a Comment

    We Love To Hear From You!

    EasyCPPprogramming.blogspotcom

    Labels