Parameter, initilaizing variables, and link

ive been working on 3 codes for class but I'm having a problem with all of them.


for the first one it says that there is a problem with a link. Link1168
// Debug 4-1
// function counts down from higher number to lower number entered
// e.g., if numbers entered are 4 and 8
// output is: 8 7 6 5 4
#include<iostream>
using namespace std;

void main()
{
void countDown(double highest, double lowest);
double high, low, temp;
cout << "Enter a number ";
cin >> high;
cout << "Enter another number ";
cin >> low;
if (high < low)
temp = high;
high = low;
low = temp;
countDown(high, temp);
system("pause");
}
void countDown(double highest, double lowest)
{
int x;
for (x = highest; x <= lowest; --x)
cout << x << " " << endl;
}


for the second one I have two errors the same. It says that I have two uninitialized local variables. Price in line 13 and taxRate in line 14.

// Debug 4-2
// User enters price
// program computes tax rate
// 5% at $10 and under, otherwise 7%
#include<iostream>
using namespace std;
void main()
{
double askPrice();
double calcTax(double price);
double price;
double taxRate;
askPrice();
calcTax(price);
cout << "On $" << price << ", the taxRate is " << taxRate << endl;
system("pause");
}
double askPrice()
{
double price;
cout << "Enter price $";
cin >> price;
return price;
}
double calcTax(double price)
{
double rate;
if (price <= 10)
rate = .05;
else rate = .07;
return rate;
}



for the third one it says I am missing a default parameter at the end but I am not sure what this means.

// Debug 4-3
// Function displays course information
// instructor defaults to Staff
// enrollment defualts to 30
#include<iostream>
using namespace std;
void main()
{
void displayCourseInfo(char instructor[] = "Staff", int enrollment = 30, char course[]);
displayCourseInfo( "ENG101");
displayCourseInfo("Bossert", 4, "PSY151");
displayCourseInfo("Dykeman", 24, "CIS200");

system("pause");
}

void displayCourseInfo(char instructor[], int enrollment, char course[])
{
cout << course << " taught by " << instructor << " enrollment " << enrollment << endl;
}
First, please use code tags when posting code. See http://www.cplusplus.com/articles/jEywvCM9/
(This is not the first time to request that. Perhaps you somehow miss what we write?)


4-1
What is the exact error message? We are not supposed to hunt some "link 1168" for details that only you can provide.

Another compiler says:
4:11: error: '::main' must return 'int'

That problem you have in all three. Fix it.


4-2
1
2
3
4
5
6
7
8
9
double price;
// what is the value of 'price' now?
double taxRate;
// what is the value of 'taxRate' now?
askPrice();
calcTax(price);
// what is the value of 'price' now?
// what is the value of 'taxRate' now?
cout << "On $" << price << ", the taxRate is " << taxRate << endl;



4-3
void displayCourseInfo( char instructor[] = "Staff", int enrollment = 30, char course[] );
missing a default parameter at the end

5:6: error: default argument missing for parameter 3 of 'void displayCourseInfo(char*, int, char*)'

See http://en.cppreference.com/w/cpp/language/default_arguments
Topic archived. No new replies allowed.