6,741 Posted Topics

Member Avatar for souphmars

With single digits all you need to do is subtract the character '0' from the value. For mutidigit numbers you need to perform a conversion, and the easiest way to do so is with strtol (in <stdlib.h> for C or <cstdlib> for C++), sscanf (recommended only for C), stringstream (for …

Member Avatar for Narue
0
129
Member Avatar for tyalangan

>scanf("%d,&n"); >n = 0; This assignment is suspicious. >prime = 1; >while(prime < n) 1 is not less than 0; your loop will never execute.

Member Avatar for Narue
0
125
Member Avatar for dcving

>Please give me any suggestions on the program. >Product1, // declare indentifiers >Product2, TotalSeconds; Bad form. Ending a physical line with a comma so that you can use a single line comment and continue the logical line on the next physical line is poor style. >Seconds = Usertime.substr(SecondC + 1, …

Member Avatar for Narue
0
138
Member Avatar for Deiwos

>"no operator defined which takes a right-hand operand of type 'const char' Post your code. >when you type name you hit space and that cin will acknowledge the space being there? cin's >> operator ignores whitespace unless you tell it to do otherwise. The best option for single line input …

Member Avatar for Narue
0
94
Member Avatar for galmca

I'm never going to answer another question of yours again. Clearly you have no respect for the people that volunteer their time to help you. First you bump your thread before a satisfactory amount of time has passed (a few days I could understand, but not less than 30 minutes), …

Member Avatar for Narue
0
96
Member Avatar for the b

Add a simple test before you print to the file: [code] if ( in == ' ' ) continue; [/code]

Member Avatar for Narue
0
112
Member Avatar for motswana

So do you have a specific question or were you expecting us to write a textbook on the subject for you? :rolleyes:

Member Avatar for Narue
0
171
Member Avatar for blargage

>#include <iostream.h> If you can use the string class then you can stop using these old headers. >#include <cstring.h> Either you're using an old, nonstandard header, or this should give you a compiler error. >void main() No matter how old your compiler is, main always returns int. This has always …

Member Avatar for blargage
0
130
Member Avatar for Calum

You can open up a command line prompt and run the program that way, but the more common solution is to ask for input at the end of the program so that a blocking read pauses execution: [code] #include <iostream> using namespace std; int main() { // Your program here …

Member Avatar for Calum
0
129
Member Avatar for marwanessa

>(1) The brief history of evolution of 'c' language. There's no such thing as a brief history of C. However, Dennis Ritchie's web site has a nice description of it, so you can try to summarize that. >(2)The advantages of this language among other available languages Advantages and disadvantages differ …

Member Avatar for Narue
0
75
Member Avatar for Angie Tullis

>If you can help email me If you're not interested enough to come back and check for replies then I'm not interested enough to help you with your problem.

Member Avatar for Narue
0
85
Member Avatar for Jason Marceau

>int result = (int) (rand.nextInt()); Should be: [code] int result = (int) (rand.nextInt(num)); [/code] By the way, Sun has a complete API listing for Java that makes a wonderful reference when first learning: [url]http://java.sun.com/j2se/1.4.2/docs/api/[/url]

Member Avatar for Narue
0
131
Member Avatar for Klarson

>how do u allow the user to input as many values as they want? You can use a sentinel value that, when read, will terminate the input loop. This sentinel must be a value that is not within the valid range, or all input must be taken as string data …

Member Avatar for Narue
0
44
Member Avatar for shdwdrgn517

>I'm trying to compare a string to an ArrayList Object. This is your problem. Unless you can figure out a way to convert the ArrayList to a String so that they are comparable, you'll need to manually compare each item individually in a loop.

Member Avatar for shdwdrgn517
1
143
Member Avatar for N3wbi3C0d3r

>but not all of my question's have been answerd It's rather difficult to answer "I wana be a l33t g4m3 c0d3r like John Carmack, tell me how to do it!" questions. Get a compiler, get a book, and start from hello world; just like the rest of us did. >:rolleyes: …

Member Avatar for N3wbi3C0d3r
0
145
Member Avatar for number1tiancai

>Or if anyone has the code which is similiar to my HW will be highly appericated. No, you do your own homework. If you post your code then we can help you with it, but we won't give you the program.

Member Avatar for number1tiancai
1
148
Member Avatar for freesoft_2000

[code] if ( pageIndex % 2 == 0 ) { // Even } else { // Odd } [/code]

Member Avatar for Narue
1
152
Member Avatar for Etarr
Member Avatar for gpleonar

Read a number, set both the min and max to that number. For each new number you read, if it's larger than the max, assign it to max and if it's smaller than the min, assign it to min.

Member Avatar for Narue
0
66
Member Avatar for elianahendler

>the class has just started using C++ so only simple commands will be acceptable This implies that you want us to do it for you. How presumptuous! Why don't you start by asking a pointed question that DOESN'T start by pasting your assignment.

Member Avatar for alc6379
0
104
Member Avatar for Jason Marceau

Have you done any research? You realize that the Java API has a Math class with a random() member function that returns a double between 0.0 and 1.0. Once you have that it's a simple matter of multiplying by N to get a random range from 0 to N.

Member Avatar for Narue
0
100
Member Avatar for bemrag

>the error is: P,G,and C are unreferenced local variables That's not an error, that's a warning. And if you remove the declarations for P, G, and C, the warnings will go away.

Member Avatar for Narue
0
97
Member Avatar for hfick

[QUOTE=manoj9_5]----------------------------------------------------------- output will be X X because ptr1 point to the var2 and var2 contain value 'x';[/QUOTE] Not necessarily. At that point dereferencing an uninitialized pointer has caused undefined behavior. After that, nothing is guaranteed to work, even if it would otherwise.

Member Avatar for Narue
0
164
Member Avatar for Simplicity
Member Avatar for Narue
0
90
Member Avatar for Midnight Skulke

>If you can just help me debug it I'll help, but I'm not going to do it for you. Debugging is what the majority of programming is, so if I did it for you then you would learn nothing. As it is, you didn't specify what the error was in …

Member Avatar for Narue
0
232
Member Avatar for NAjAM AHMeD

What are you trying to do with those two functions? It's clearly not a simple factorial or modulo calculation, so unless you describe what the problem is, we can't help. Though I can tell you right now that your power function isn't going to work like you expect. >i=a^b; ^ …

Member Avatar for Narue
0
120
Member Avatar for epsos

I hope you plan on using one of the braindead windowing interfaces, because with typing like that you won't get very far on the command line. :lol:

Member Avatar for TKSS
0
103
Member Avatar for m-soft

>ln(x) doesn't work in BC 3.1 Neither does 1/3. Maybe, just [b]maybe[/b] vegaseat was using mathematical notation rather than valid C++ code. :rolleyes: Get a reference and figure out what the equivalent functions are. It's really not that difficult.

Member Avatar for vegaseat
0
141
Member Avatar for bemrag

Start by including stdio.h and making sure your braces match, then we'll talk.

Member Avatar for Narue
0
252
Member Avatar for indignity

The harsh reality is that you'll learn more on your own or on the job than you will from college. Since that's the case, pick the school that will look best on a resume and do all of the following in your spare time: 1) Read, read, read. 2) Practice …

Member Avatar for umcookeg
0
303
Member Avatar for hill0ster

>use memcmp Brilliant! No, not really. If not being able to use strcmp is a requirement of the function then clearly it's homework and using memcmp would result in a failing grade. However, I won't make a suggestion other than looping over the contents of both arrays and making comparisons …

Member Avatar for Narue
0
138
Member Avatar for Beau

>is microsoft visual C++ the same as any other C++ programing tool? Yes, if by "the same" you mean it compiles something called C++ that may or may not be the standard definition of the C++ language. Otherwise, no. Compliers and development environments are all different, but if they claim …

Member Avatar for Narue
0
171
Member Avatar for kwongchungying

Nobody is going to download 5 files just to help you. My suggestion is that you remove everything you can without removing the error itself (but if you do, note what you took out). Then you'll be in a better position to debug. Who knows? The code may be short …

Member Avatar for Ejaz
0
283
Member Avatar for hopeolicious

>It took me about 2 days but I got it lets see if you can do it. >Challenge ends on October 27 the program will then be posted for you viewing Geez, you'd think that people would be more creative than this. Do you want to know how many times …

Member Avatar for alc6379
1
121
Member Avatar for Young Teck 06

>system("pause"); >put getch(); You know what I find funny? The fact that every time this question is asked, the first two replies suggest the first two absolute [b]worst[/b] options. :rolleyes: system is slow, nonportable, and a serious security hole and getch is the patron saint of nonportable. >What can I …

Member Avatar for Young Teck 06
0
117
Member Avatar for bryan7890

>i couldnt finish it cuz i have 2 exams cal2 and physics 2 tomo.. Tough beans. Learn to start your work sooner or prioritize the homework that's most important and accept the failing grade that you deserve for the homework you're unable to finish. Do you think that when you …

Member Avatar for bryan7890
0
131
Member Avatar for gwenny

>Can anyone out there help me write the "Main" part. [code] #include <iostream> #include <queue> using namespace std; int main() { queue<char> q; char ch; bool match = true; cout<<"Enter a message: "; while ( cin.get ( ch ) && ch != '\n' ) q.push ( ch ); cout<<"Enter another …

Member Avatar for Narue
0
146
Member Avatar for Young Teck 06

>1. What exactly is the purpose of white spaces? Whitespace serves two purposes. First, it separates certain tokens that cannot be immediately adjacent. For example, this is valid C++: [code] int i; [/code] But this is not: [code] inti; [/code] At least, it isn't valid unless you've declared a name …

Member Avatar for Young Teck 06
0
111
Member Avatar for pratima
Member Avatar for KittyGirl

>Can someone tell me what is wrong with it? Just about everything. You're also overcomplicating things and it's pretty obvious that you aren't referring to any book on C++ or trying to compile this or you wouldn't have such dreadful syntax errors. Use this as a template: [code] #include <cctype> …

Member Avatar for Narue
0
135
Member Avatar for pratima

>#include<iostream.h> No, not C++. >#include<iomanip.h> Also not C++. >#include<conio.h> Not only is this not C++, it's also only available on a limited number of implementations. >void main() This never has been, and hopefully never will be, correct C++. main returns int. In fact, the old argument of being a lazy …

Member Avatar for Narue
0
123
Member Avatar for prachi

What did you try and where did you search? I get plenty of hits on google for this sort of thing, and several books go over it during their explanation of stacks.

Member Avatar for Narue
0
107
Member Avatar for kwongchungying

Header files are just textual replacement. When you say [code] #include "Person.h" [/code] That line is replaced with the contents of Person.h. In other words, everywhere you include Person.h, you get this: [code] #include <string> class Person { public: Person(char * name = 0,int age = 0); Person(Person const & …

Member Avatar for Narue
0
931
Member Avatar for hill0ster
Member Avatar for iumair
0
126
Member Avatar for skamen

>I'm really drawing a blank as far as how to setup the function that reads the fractions inputed by the user. It's as simple as reading two integers and saving them in numerator and denominator variables.

Member Avatar for Narue
0
2K
Member Avatar for Sukhbir

>int *a = malloc(10 * sizeof *a); [QUOTE=Chainsaw]Most compilers will complain because malloc() returns void* and, in C++, you need to cast void* to the type you are mallocing. Generally, you should use 'new' and 'delete' rather than malloc, for at least these three good reasons: 1) You don't need …

Member Avatar for Narue
0
141
Member Avatar for tendekai

><iomanip.h> is a (deprected) C++ header Nope, iostream.h was removed completely. Deprecated presumes that the header is still valid C++, but not recommented as it might be removed in future revisions. As it is, iostream.h is nonstandard and should be treated as such.

Member Avatar for Narue
0
198
Member Avatar for somer2412

>Can someone please help me with a statement to calculate the median when the array is even. Take the median of the two middle items: a[size / 2] and a[size / 2 + 1].

Member Avatar for Dave Sinkula
0
392
Member Avatar for BeyerCorpuz

>Which language would be the best intial language to learn to get the most education as a programmer. Python is a good start, so is Java. >BCX is the way to learn it! Funny, in all my years of programming with C++, this is the first time I've heard about …

Member Avatar for pAiNtBaLlEr06
-1
467
Member Avatar for the b

do..while loops end with a semicolon: [code] } while(!infile.eof())[color=red];[/color] [/code] But, tell me what happens when the input file is empty? Your do..while loop will still process a character, but it will be uninitialized and the result is undefined behavior. A while loop is better, but don't use stream.eof() as …

Member Avatar for the b
0
328

The End.