Forum: C++ 7 Hours Ago |
| Replies: 10 Views: 95 You should check where the program crashes, and read the error message(s).
Check your arguments closely - what's being used here, and what is being used without having a value assigned?
... |
Forum: C++ 8 Hours Ago |
| Replies: 3 Views: 59 First, the code would be clearer if your variable names better expressed what they were.
What's "total"? The input of distance driven should be "miles", not "mpg". mpg = miles / gallons better... |
Forum: C++ 8 Hours Ago |
| Replies: 2 Views: 82 What's the largest value that can be stored in a long int?
How does that limit compare to the value you're trying to stuff into a long int? |
Forum: C++ 2 Days Ago |
| Replies: 2 Views: 97 results[0]= x * sin (x);
x is an array - it cannot be used as the operand of a multiplication nor as the argument to sin( ).
Did you mean to say results[i]= x[i] * sin (x[i]);? |
Forum: C++ 2 Days Ago |
| Replies: 2 Views: 84 Actually, it does make a difference. The declaration outside of main( ) is globally visible and modifiable. This is generally to be avoided, especially in beginning programs, as it may cause the... |
Forum: C++ 2 Days Ago |
| Replies: 1 Views: 70 switch blocks are not good for doing range based decision making. You have to be able to do exact matches to integral types, which is often, as you surmise, way too much work.
Use if...else if...... |
Forum: C++ 2 Days Ago |
| Replies: 10 Views: 220 Your new function, which still has the { } problem jonsca pointed out, will return immediately after the first number is read in, depending on whether it meets the 10-500 test or not.
You should... |
Forum: C++ 11 Days Ago |
| Replies: 4 Views: 186 Do you have a pencil and a piece of paper handy?
This is C++. |
Forum: C++ 13 Days Ago |
| Replies: 4 Views: 185 You need to write a couple of hand scoring functions. You don't look for all possible combinations, but look at a player's hand and determine what, if any, of the poker hands it constitutes.
... |
Forum: C++ 14 Days Ago |
| Replies: 3 Views: 292 To read just 5 characters at a time to your array, you could use getline( ).
Make your array size 6 to allow for the null terminator at the end of a string, then
char arr[6];
//open your... |
Forum: C++ 14 Days Ago |
| Replies: 4 Views: 186 I would do a search of the daniweb c++ forum and find this problem discussed many, many times.
( I wish profs would be a bit more creative and come up with some new assignments.) |
Forum: C++ 16 Days Ago |
| Replies: 5 Views: 207 Hmm, bet you made the file in notepad and named it "test.txt", and Vista added the other .txt. Or VS might have done the same thing.
That's why I like to set my systems to display the file... |
Forum: C++ 16 Days Ago |
| Replies: 5 Views: 207 What compiler/IDE are you using? That would help us to tell you where the input file should be located. Are you running this from the IDE or directly in a command window? |
Forum: C++ 16 Days Ago |
| Replies: 1 Views: 139 Long time ago I used this article (http://msdn.microsoft.com/en-us/magazine/dvdarchive/cc301454.aspx)as a reference to do such.
Unfortunately, it seems the supporting code is not available at... |
Forum: C++ 17 Days Ago |
| Replies: 1 Views: 204 Here's your code, translated in to C++.
#include <fstream>
#include <iostream>
using namespace std;
void READFile(char* filename)
{
int num; |
Forum: C++ 17 Days Ago |
| Replies: 3 Views: 279 |
Forum: C++ 17 Days Ago |
| Replies: 4 Views: 175 Read the problem thoroughly. List what you know, what's to be input, what you're to do with it.
Then start listing the steps to accomplish the task. Voila, you're done. |
Forum: C++ 17 Days Ago |
| Replies: 4 Views: 271 RTE, I think you're reading too much into this. The airline reservation/seating problem is a common assignment in beginning programming course, as evidenced by the many times it's come up here. |
Forum: C++ 17 Days Ago |
| Replies: 4 Views: 271 Read the full assignment. It should all be there. |
Forum: C++ 17 Days Ago |
| Replies: 2 Views: 165 You could pass the username and password arrays (or the single array of user objects when you make a class) to the checkDetails( ) function. That way you don't have the arrays in global space... |
Forum: C++ 17 Days Ago |
| Replies: 4 Views: 175 Yes, you could use a loop to print only up to 22 characters. Be sure to first test the length of the actual string content, and limit your loop to 22 or the string length, whichever is less. |
Forum: C++ 18 Days Ago |
| Replies: 3 Views: 162 So, your function must:
1. Display the menu. What are the options in this program?
2. Ask the user to make a selection from the options available. Usually you will take this in as either a... |
Forum: C++ 18 Days Ago |
| Replies: 4 Views: 175 I think a better approach would be just use getline to grab all of a line into a large string, then print out the first 22 characters that appear (or less if the line's not that long.)
You can... |
Forum: C++ 19 Days Ago |
| Replies: 1 Views: 151 Please use this big white space to ask a question. If you read the sticky threads at top, you'll find useful information on how to ask questions here.
It looks like you're writing in C, this is... |
Forum: C++ 19 Days Ago |
| Replies: 3 Views: 288 Please read the sticky threads about how to ask questions.
Mainly, please put your code inside code tags so it will be more readable, like
your code goes here
Big problem with your second... |
Forum: C++ 20 Days Ago |
| Replies: 5 Views: 378 For your array, if the problem is given as a set size, just declare a local array, as you show int plate[10][10]; for example.
If no specific info is given for initial state of interior nodes,... |
Forum: C++ 21 Days Ago |
| Replies: 5 Views: 199 YES, that was a typo
Should read
for( c = 0; c < 5; c++ )
(walks away with embarrassed look) |
Forum: C++ 21 Days Ago |
| Replies: 5 Views: 378 What I believe the problem is asking you to do is set up the 2D array.
Read in the temperatures along the edges (is the temperature the same all along an edge or does it vary along the edge,... |
Forum: C++ 21 Days Ago |
| Replies: 5 Views: 199 Is your array declared as 5 columns or as 6? It makes a difference in the indexing you use.
Are you using the row index as the student ID? I don't see input for IDs.
Remember that the maximum... |
Forum: C++ 21 Days Ago |
| Replies: 2 Views: 200 Well, I think an elegant solution would be a loop that iterates from -4 to +4, inclusive. Within that loop is another that uses the absolute value of the loop counter to print out the numbers and... |
Forum: C++ 22 Days Ago |
| Replies: 3 Views: 218 Why are you doing two input actions in the loop?
The first, in the while condition, reads the word and stops at the newline. The getline will read and discard the newline, storing an empty string to... |
Forum: C++ 22 Days Ago |
| Replies: 3 Views: 273 Sure you could modify during runtime. And make allowance to store the parity bit(s) as well.
Say you want to store a byte, plus a parity bit. Allocate an array of 9 char's (unsigned, if you want,... |
Forum: C++ 22 Days Ago |
| Replies: 3 Views: 273 Depends on how easy you want to access the bits, and how you get the data.
You could store the data as an unsigned char, and access each bit using masks. That easily handles single bytes.
You... |
Forum: C++ 22 Days Ago |
| Replies: 6 Views: 459 I'll write that code for $25,000
How low can the bidding go?
Maybe this should move to Geeks' Lounge? |
Forum: C++ 22 Days Ago |
| Replies: 2 Views: 257 Please read the sticky threads about using this forum, it'll make your time here more productive.
Mainly, be sure to put your code inside code tags, like
your code goes here
This will make... |
Forum: VB.NET 23 Days Ago |
| Replies: 2 Views: 184 The error is due to the way floating point values are stored. Single precision, which it looks like you used, is only good to about 7 digits. Double precision will get you 15 digits. It's best to... |
Forum: C++ 23 Days Ago |
| Replies: 4 Views: 4,054 A. You are responding to a three year old post
B. You are hijacking that thread with a new problem
C. You are asking for a solution to a problem you have not attempted to solve on your own
D. This... |
Forum: C++ 23 Days Ago |
| Replies: 13 Views: 369 makeChange.quarters = static_cast<int>(remainingMoney * 4);
remainingMoney = money - ( quarters * .25); |
Forum: C++ 23 Days Ago |
| Replies: 3 Views: 165 I think it has to do with the declarations of the items
Product milk = Product( "Milk", 7 , "Lot's of calcium");
Left side of the assignment operator creates the object. Right side of the... |
Forum: C++ 23 Days Ago |
| Replies: 13 Views: 369 You're welcome.
Now go back and read my first reply again, relating to the calculation of remaininMoney.
You have $1.78. Your code correctly stores 1 dollar, and subtracts 1.00 from the total,... |