Beginners - September 2013 (Page 3)

Getting wrong answers
 
I'm getting wrong answers with simple math. When I ask for something like: float answer = cos(sample1 ) * sample2 ; I get a wrong answer. It calculates 'co...
[2 replies] Last: have you tried this? float part1 = cos(sample1 ); cout << part1 << e... (by Stewbond)
Class member variable initializes with = operator??
 
Output of the code is 25! How does the object of class opp initialize its private member? #include<iostream> using namespace std; class constTest{ priv...
[2 replies] Last: Thank Cubbi. And hence the explicit keyword! (by omkarchamphekar)
Needing help with passing numbers
 
I am currently working on a little program that will take a positive number and add it to the previous number while keeping a running total. The exit is to inpu...
[1 reply] : Have you learned break; yet? Also it's because you don't add the ne... (by Stewbond)
Multiplying two matrices
 
Hi. I'm trying to figure out how to multiply two matrices. Here's my code so far. Is it correct? #include <iostream.h> #include <conio.h> int main(v...
[5 replies] Last: @Klipeti You're welcome! Happy programming!... (by condor)
by stacyd
I need to write a program in C++ that inputs in on format and outputs in another and ignore a comma
 
I have to write a program that inputs a name from a user; last, first, middle and output it first middle last. Do I have to use cout<<"Enter your name last, fi...
[9 replies] Last: I have tried moving the cin.ignore to between the cinlast and first al... (by stacyd)
need help
 
what is the output the c++ code shown above? my answer is 10_10, why is it wrong? Both a=20 and b=b+5 are local variables, ringht? int a=5; int b=...
[2 replies] Last: thx a bunch! (by linke2511)
I am stuck
 
ok I am new to C++ I am taking a computational Thinking course at College and in it we are doing C++ programming. The issue I am having is that once my program ...
[2 replies] Last: while (name != quit); should be while (name != quit) no semicolon.... (by Chriscpp)
by Ed4434
Fstream with dynamic arrays
 
Hey again, just another quickie; I'm writing a program to create and store profiles for a selected number of people. I've created a dynamic array to store th...
[3 replies] Last: Umm.. thanks.. (by Ed4434)
do-loop help
 
Hey guys, I need a little help with this game I am writing for a project. I am having an issue with the do-loop function. When the game starts, the 3rd option ...
[9 replies] Last: // By Christopher Alfonso //cop1334c JC // This is a text based gam... (by Chriscpp)
call function
 
Hi there, can you use 7.89 as a function call or variable name? processData(product, 7.89,"normal", markupPercentage,retail);
[3 replies] Last: everything looks good but you may have a problem passing "normal" via ... (by giblit)
Pointer arithmetic on multi-dimensional arrays
 
Using an example of my book int array ; to access array the author says the pointer arithmetic that is being performed is *(array + 3 * <width o...
[2 replies] Last: Yes it helped a lot, thanks! (by MasterT)
by elfeck
Getting index from array-value in O(1)
 
Hello, I've got a dyn. allocated array like this: MyClass* myarray = new MyClass ; At some point I have a pointer that points to one element in myarray ...
[4 replies] Last: http://www.cplusplus.com/reference/iterator/distance/ essentially cove... (by keskiverto)
by Nebur
Decimal to binary too slow!
 
Hi everyone, i made a program that given a decimal natural number it returns its binary, hexadecimal and octal. The program works but is way too slow. Anyone...
[5 replies] Last: http://www.cplusplus.com/reference/string/string/erase/ (by ats15)
Program received signal SIGSEGV, Segmentation fault.
 
Hi, I am trying to write a program that calculates the product of two large, dense matrices. When I use dimensions 200 x 200 for the matrices the program wo...
[4 replies] Last: I know that a accesses an element. The problem was not with access... (by vkumar8282)
Counting WORDS in a String?
 
How can i count words in a string? so far im totally doing it wrong, i really need help! it has to follow the while format! #include<stdio.h> #include<string...
[11 replies] Last: @ Andy : OK, I could see a scenario where if the instructor does not ... (by Computergeek01)
by srk24
Armstrong number
 
Hi I am very new to c++ programming.I am just trying to check whether the number is Armstrong number. Please see my code below. This program works fine for ...
[4 replies] Last: > since the Pow function inside the math.h converts the int to double ... (by JLBorges)
Pointer arithmetic
 
If I have an array int a ; Why do I have to do *(a + 1) = some_value instead of (a + 1) = some_value (Why must I include the asterisk?) I already know I can u...
[2 replies] Last: Ok it makes sense now. (by MasterT)
Using functions as parameters with arrays??
 
So I have written my code, the first part is fine utilizing a basic algorithm to find the max volume of an open box based off of user input, so please ignore th...
[no replies]
by donlxu
What's wrong with my code?
 
Hi. I'm trying to create a program to compute the Riemann zeta function which is defined as 1 + (1/(2^x)) + (1/(3^x)) + (1/(4^x)) +.... for user input o...
[2 replies] Last: It might not be because it's an assignment from my cs 101 class but t... (by donlxu)
Hollow square
 
Hi I need help in making this square hollow loop using for loop. ***** *___* *___* *___* ***** I am online from phone so can't type the whole code. the...
[2 replies] Last: Ok so, here is the code #include <iostream> using namespace std; in... (by Zaki Al Qudah)
September 2013 Pages: 12345... 64
  Archived months: [aug2013] [oct2013]

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