Beginners - February 2012 (Page 61)

Does C++ round floats to the nearest int when casted into an int?
 
I performed the following casting in C++. int n = (int) sqrt(3); The square root of 3 is about 1.732. When I checked the value of n in gdb, the value I got...
[5 replies] Last: The Palm Tree Magician is correct in that it truncates. However tru... (by closed account z05DSL3A)
help with accessing private member functions
 
I am some what new to c++, I am making a linked list and am a bit confused at how it works. I have looked at several examples online and they all use strutcs wh...
[3 replies] Last: Thanks for the quick response I think I am on my way now. (by xintaris)
How to sum up a vector/array
 
Hi all. Looking for help on how to sum up the components of a vector/array. The basic outline is that I input a vector/array a of length N,and want the sum o...
[9 replies] Last: Brilliant, that works if I get it to print out b Thanks for your h... (by HershelLayton)
Trouble with Simple Program - For School
 
For a lab assignment, we are to create an application that generates questions and answers them randomly to determine the kind of animal. So we have... Is it...
[1 reply] : Firstly, you have a closing brace at the end of line 43, with no match... (by The Palm Tree Magician)
star's outpud
 
how to output diamond shape, using a symbol of asterisk. using a nested for loop.
[1 reply] : We don't do people's homework for them, but if you take a stab at it a... (by The Palm Tree Magician)
Help - Loop time?
 
Just started with C++. Currently taking a Fundamentals class. How long should it take a 2.66Ghz Pentium 4 with 1G of ram to count in a loop to 100,000,000? I...
[4 replies] Last: Also looks like you can just get rid of either f1 or d1. They both do ... (by ResidentBiscuit)
Getline from a txt file to a 3d array??
 
I have to read in 50 questions from a file , each that looks like this -- What is the capital of Texas? Kansas Kentucky Alaska Austin -- I have to o...
[1 reply] : OK, first things first: Line 9: To declare an array, you need a ty... (by The Palm Tree Magician)
error LNK2019: unresolved external symbol "void
 
Hello All, I am getting two compile errors and needing help. Please see the description of the program below. And below that is the code for the said progr...
[1 reply] : Wow, wall of text! Use code braces around code (the <> symbol in the ... (by The Palm Tree Magician)
Why does the set iterator not have get() as a function?
 
I have a int set iterator: set<int>::iterator itr; Apparently, itr.get() is not a function for set iterators. How, then, should I retrieve the valu...
[2 replies] Last: Thank you! That makes sense. (by johnhoffman)
How can one get the maximum of a set?
 
I tried using this code to get the maximum of a set. set<int> myset; myset.insert(1); myset.insert(3); myset.insert(2); cout << max(myset); Earlier, I did ...
[2 replies] Last: Thank you! Also, I figured out that the max() in the algorithm library... (by johnhoffman)
by oyoung
A question about pointer
 
int nums ; int *en = nums+100; I am reading a book. The book says that 'int *en == nums+100;' defines en as a pointer to the last element of the arr...
[3 replies] Last: My copy of the book says int* en = nums + 100; Defines en as a point... (by Cubbi)
Passing a string literal to a constructor??
 
I have a class called Product. It has three data members I need to have several different constructors. On of them will take three arguments for the data member...
[4 replies] Last: shacktar the const char* worked perfectly. Thanks. Man points and th... (by jokerfwb)
by YBCO
Confused myself
 
Hey, I'm trying to get my program so that, at any question, pressing the 'r' key will return to, main (). However i am also trying to carry out other if-else f...
[4 replies] Last: Thank you so much WhiteWind been a great help. Yeah im going to start... (by YBCO)
Cout an array element's index number
 
I need to display the subscript/index number of an element in an array, how do I do it? thanks
[10 replies] Last: Nearly ;) It should be if (i == SIZE) i = SIZE+1; isn't necessary... (by Athar)
File I/O problem (1,2)
 
I have previously written a program that produces 20 arithmetic problems to solve. Now I need to change the program so that the problems values (a and b) are...
[21 replies] Last: Thanks for the solution L B. unfortunately after using: ofstream ou... (by Orangejuice)
not able to print out statement
 
#include <iostream> using namespace std; int main() { const string LETTER_D = "*******\n* *\n* *\n* *\n* *\n*******\n";...
[5 replies] Last: It's a tab ;) (by LB)
Understanding Return better!?
 
#include <iostream> using namespace std; int ff(int x){ if(x==1){ return 1; }else{ return x*ff(x-1); } } int main(...
[2 replies] Last: also where is the return value held does the program allocate space f... (by Athar)
problem with vectors
 
error with :reservationMain.UsersVector.push_back(userMain.username) here's the error codes: Error 1 error C2664: 'void std::vector<_Ty>::push_back(_Ty &&...
[1 reply] : in line 97 userMain.username is of type std::string and your vector wa... (by sparticus37)
by swp
reversed order linked list
 
hey im working on this problem: #include <iostream> using namespace std; struct node{ int data; node* next; }; int main() { node *fir...
[2 replies] Last: Yes. Keep a node* last; When the 1st node is created (when first==0) a... (by closed account D80DSL3A)
by Barkin
c++ create a program please somebody helpp..
 
Part 0 Output a prompt using the cerr object that instructs the user to type in a temperature in °F (i.e. Fahrenheit). Define a variable named tempF o...
[19 replies] Last: cin.clear(); cin.sync(); cin.ignore(unsigned(-1), '\n'); (by LB)
February 2012 Pages: 1... 596061626364
  Archived months: [jan2012] [mar2012]

This is an archived page. To post a new message, go to the current page.