Hello, this part of my program:
int shotDistance(in t a)
{
int min = a * .8, max = a * 1.2; //Defines the minimum and maximum range of the club.
srand ((unsigned int) time(NULL));
a = min + (rand() % (max - min)) ; //calculates the random shot distance.
return a; //returns the distance to main().
}
gives warning:C4244 'initializing' : conversion from 'double'...
User Profile
Collapse
-
getting rid of warning: C4244
-
Program check - help
Hi anyone,
Could someone check this program for me, I've given it a go, it runs well but gives me 6 of this warning:
warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
Please check this and let me know if I've left out anything or any additions, anything:
#include <iomanip>
#include <iostream>
#include <string>
... -
Thanks guys but i still cant get the expected results cos I do not know how to code the calculations for the total sales and average sales.......cou ld someone give me an idea on how to do that???...Leave a comment:
-
No am not trying to implement a for loop I just want to use a while loop but I want the months to automatically just come as Month1...Month2 ...etc.
The program is giving me this warning:
warning C4552: '<=' : operator has no effect; expected operator with side-effect...Leave a comment:
-
C++ - formula in a while loop
How do i write the formula for calculating the total sales and average for this program:
[code=cpp]
while (sales !=-1)
{
i <= 12; i++;
cout << fixed << setprecision(2) << "Please enter your sales for month " << i << ": ";
cin >> sales;
} //end while
i <= 12; i--;
cout << "For " <<...Last edited by sicarie; Apr 21 '08, 01:06 PM. Reason: Code tags are [code=cpp] and after your code [/code]. Please use them. They want to be used. They like to be used. -
using a while loop
Hi can anyone tell me how to do this problem:
Write a program using a while loop that asks the user to enter their sales for each month until they enter -1 (sentinel value). After this, it should tell the user how many months, the total sales and the average sales.
If the user enters a negative value as the first input, it should not cause an error.
The program should be able to produce the output below:
... -
-
Logical error - same output no matter what the input
Hi,
Can someone tell me what's wrong with my code cos when I test the program, it always gives me the fee as 20 for everything..... .
[code=cpp]
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
//declare variables
char memberStatus = ' ';
int age = 0;
int fee = 0;
... -
-
Thank you, now it doesnt have errors but it's not giving the value :(...Leave a comment:
-
This is the error am getting:
error C2451: conditional expression of type 'std::basic_str ing<_Elem,_Trai ts,_Ax>' is illegal
with
[
_Elem=char,
_Traits=std::ch ar_traits<char> ,
_Ax=std::alloca tor<char>...Leave a comment:
-
selection structure problem
Hi
I have to create a program that displays a shipping charge. The shipping charge is based on the state name entered by the user, as shown:
StateShipping charge ($)Alabama25Alaska50If the user enters any other state name, the shipping charge should be 0 (zero).
So far I've come up with this but am having errors. Can someone help check my code out?
#include <iostream>
#include... -
program converting Celsius to Fahrenheit
Hi
I was doing this program on Visual Studio 2005 where the program converts C to F and vise versa but after debugging it, it doesnt give the expected result. Could someone tell me what is wrong with my code???
#include <iostream>
#include <iomanip>
using namespace::std;
using std::fixed;
int main()
{
int conversionType = 0;
double temp... -
Help, am getting this error C2784 message
Hi am working on this program that will display the sum, difference, product and quotient of two numbers using the selection structures. This is what I did:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int num1 = 0;
int num2 = 0;
int answer = 0;
char operation;
int main()
{
cout << "Enter... -
error C2065
Hi,
I'm doing C++ with visual studios 2005 and recently did this program
#include <iostream>
int num1;
int num2;
int answer;
char operation;
int main()
{
cout << "Enter first number: ";
cin >> num1;
cout >> "Enter 1 (add) or 2 (subtract) or 3 (multiply) or 4 (divide): ";
cin >> operation;...
No activity results to display
Show More
Leave a comment: