I am having a bit of trouble, in class I am using Turbo C++ in which I can copile my code so it can become a executable file. Problem is the professor gave us a source to use but the program isnt Turbo C++ it is Microsoft Devlopment Enviroment. Iam creating a program in which I have to input an integer "ie: 25" and that number has to come out in decimal, hexidecimal and ascii character forms. In addition the program must be able to use a floating-point number and output it in floating point and scientific format.

This is what i have so far:

#include<iostream.h>
#include<iomanip.h>
main()
	{
	int x;
	char x;

	do {
	
		cout << "Number as decimal: " << dec << x;
			cin >> x; 

		cout << "Number as hexadecimal: " << hex << x;
			cin >> x;

		cout << "Number as character: x" 
			cin >> x;

<< moderator edit: added code tags: [code][/code] >>

I know this mesage is long bare with me..

Also I have to act as if i work for the phone company and output several call durations "such as 45,43,12,17,78"

and I have to categorize them as "shorstest call, longest call, count the total number of calls made and the avergage of a call on the list"

for this one i have this:

#include<iostream.h>
#include<iomanip.h>
main()
	{
	int  a, b, c,d,e,f;
	
	do {

	cout << "Enter first call: ";
	cin >> a;
	cout << "Enter second call: ";
	cin >> b

..you get the idea

cout << "Enter longest calls made: ";
	cin >> a;
	cout << "Enter shortest calls made: ";
	cin >> b

similar as before

I want to know if Iam on the right track or am I off the main focus of the program itself. If I am off then can anyone please help me out.

What your professor had in mind apparently was to give you an exercise in Data output and a simple exercise in logical operators ( i.e > , < , == , etc. )

The output of a character in hexadecimal and decimal is okay. But you dont have to input the shortest call by hand. You can tell the program to do find it for you.

for example;

int minimum = -1 ;

cin >> a ;

if ( minimum > a )
minimum = a ;

cin >> b ;

if ( minimum > b )
minimum = b

cin >> c ;
if ( minimum > c )
minimum = c ;
...

so on.

After entering the last input and doing the above comparison with minimum, you will get the minimum of the entered sequence.

Similary for the maximum

if ( maximum < a )
maximum = a ;

....

The average as you may know is the sum of a, b ,c , d .. divided by the count of numbers in the sequence.
if you dont know the count of numbers you will be inputing, use a do-while loop as below

#include <iostream>
using namespace std;

int main ()
{

	int sum = 0 ;
	int count = 0 ;
	int a ;
	cin >> a ;
	int minimum = a ; 
	while ( a != -1 )	 // This means that the loop will run until you input -1
	{
		if ( minimum > a )
			minimum = a ;
		sum = sum + a ;
		count = count + 1 ;
		cin >> a ;	
	} 

	cout << "Average : " << (float( sum ) / count ) << endl; // check for count == 0 before this
	cout << "Minimum : " << minimum << endl;
	return 0;
}

and for maximum also you can do the same. I wont give the line of code so you can try it out.That is how i understood your problem and I hope you understand my solution. Just ask in case you dont or if it gives errors.

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.