Alright guys, brand new to the forum and I'm currently taking my first c++ course. I am not asking for anyone to do my homework for me, but I have been working on the same assignment for the past three days and have been unable to figure it out. Here is the link for the assignment:

https://docs.google.com/document/d/1MK0eS3xVBcLuJHfy_Akr5GRLVxmyoOqeIDVdPIDX73A/edit

as well as the code I have so far, any help would be appreciated:

/* -------------------------------------------------------
* Program:      CircleFun
* Author:       James Harris
* Date:         2012.11.06
* Dev Env:      Visual Studio 2010
* Description:  This program outpuds outputs the area, radius and cirumference of a cirlce.
* ------------------------------------------------------ */

#include <iostream> // to use cin cout
#include <iomanip> //to set precision, etc.
#include <cmath> // to use predefined math functions

using namespace std;

//list function prototypes so main is first

int convertTime24to12(int hour);
void getTime24();
void printTime12(int& minute, char& ch);
int userWantsToContinue();

//main function to repeat input and output of processing function if desired by user
int main() 
{
    int hour;
    char ch;
    int minute;

        getTime24();
        convertTime24to12(ihour);
        printTime12(minute, ch);

        cin.get();
        cin.get();
}

void getTime24()
{   
    int hour, minute;
    char ch;

    cout << "Please enter time in 24-hour format. For example 22:03: " << endl;
    cin >> hour >> ch >> minute;

    convertTime24to12(hour);
}

int convertTime24to12(int hour) 
{
    char ch;

    if (hour > 12){
        hour -= 12;
        ch == 'p';
    }

    else
        ch == 'a';

    return hour;
}


void printTime12(int& minute, char& ch) 
{
    cout << "The time entered in 12-hour format is " << convertTime24to12;

    if (ch == 'a')
        cout << "a.m.";

    else
        cout << "p.m.";
}

So what's the error you're getting?

First is it is saying hour is being used uninnitialized from line 30, secondly, after user input, it prints a jumbled number for the 12 hour format which is 00F6109B in the console window.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.