I am trying to make the code below display the result with decimals. I tried using setprecision, but I am not too sure where to put it. I placed it in cout section where the answer is but it still doesn't come out correctly.
#include <iostream>
using namespace std;
//*Delcare function prototype*
int ConvertToCentimeters (double, double );
//declare exception class*
class NegativeNumber
c++.....in my program i have 3 string-s (string houses,string ink,string buildings)and i must add function substr()... In the program i need to add a function that receives a parameter of type string. The task function is that the resulting string is inserted characters '=' to split a string of characters into subsets 5 letters long. If you come to the end and no more letters after the equal sign is not added. The function should not display anything but the resulting string is returned as a result. Example:
A function recive: "housesinkbuildings" .The function returns: "house=sinkb=uildi=ngs" in The main program Add call of this function so that it is specified as a parameter string consists houses,ik, buildings.
I have a task to hold a number like 4.0000000000000000199e+30 and, in a variable like long double (the largest of the data type) doesn't hold the whole number, holds only 4.099e+30, like that.
I'm working on a Fraction Class assignment where I'm supposed to provide conversion operators to allow Fraction objects to be used in expressions containing float data values. The way I have it now, I'm getting an error that says operator float(const Fraction &) must contain 'void', which makes no sense to me. Lines 155 - 173.
// Fractions CLASS // Source: Fraction2012.cpp // Author: Warren H. Knox, Jr. // Date: 11/8/2012 #include <iostream> #include <cstdlib> using namespace std; class Fraction {
I created class called students which suppose to store students names of in array but when I call the display function it display only the first name. but I want it to display names depending on the array size.
#include <iostream> #include <sstream> using namespace std; const int SIZE=5;
I know this is more simple than I am making it out to be. I have a solar panel hooked up to an 8-Bit ADC and linked into my Microprocessor. I am trying to take the Binary readout from the ADC and convert it to a decimal number to be displayed on the boards LCD display. I am wiring the ADC to PORTA on my Motorola Freescale Board. This is for a final project for my electronic systems class due on Monday...
Info:Program that stores information about reports .the above function searches the report according to its title. list is the name of the structure that stores the records.
Why i'm using strstr:
for eg. there is a report titled 'report on tigers'
I want the report information to be output if someone searches for 'tiger'
Output:displays all the entries i have made till now
I'm trying to understand the pass by value-result. The code I have came up with so far only does by value and by reference, which I understand. The value-result is what has me stumped, and honestly I am unsure how to write the function for it. Here's my code so far...
#include <iostream> using namespace std; // Function prototypes. void swapByValue(int, int, int); void swapByRef(int&, int&, int&);
I keep getting an undesired value in this code. I've tried several methods, but none are giving me the correct answer. The out put is always zero, when in this case it should be 10!!
Here's the object structure:
template<class T, class _b> struct quantity { private: T value; public: explicit quantity(T val): value(val) {}; T getValue() { return value; };
Why does it seem that the assignment operator is the harder operator to overload? Maybe it's just my luck, but I seem to always run into issues whenever I work with it. I hardly ever experience errors when overloading any of the other operators.
how to use the result of an if statement in my program. I'm writing a program for a knockout tournament, so i want to extract the winner of each match to carry forward in the code for use in the next round. I've tried assigning another variable (#define r1w1) and saying that the variable = cName[0] or cName[1] in the if statements like this: (i did this because i thought i could then use r1w1 later in the code)
if(scorea1 > scoreb1) { printf(" "); printf("WINNER OF ROUND 1 MATCH 1 IS %s ", cName[0]); cName[0] = r1w1
I am creating a program that allows the user to enter the number of days worked and calculates the amount of money gained by doubling the amount from the previous day, starting with .01 cents. The program works fine except for in day 3, the program adds .01 along with doubling the amount from day 2. Also I must use a List Box.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;
I am trying to compare 2 strings of characters The users input containing 5 chars is compared to a table If the input is already be existent in the table the index of those chars in the table is printed Quest: how to copy the result of a printf() into an array ? The last printf() gives a sequence of numbers and I am trying to save that sequence to another array for further operation ! I have not been able to do that so far even with tmp[]=i ;
Code: #include <stdio.h> #include <string.h> #define N 30 #define n 100 int main (void) [code]....
I am having a problem using fprintf. I have a function which flips a coin. Heads prints a text to the screen. Tails prints a different text to the screen. My problem is getting the result to print to a text file.
Code:
#include <stdio.h> #include <stdlib.h> #include<time.h> void seedrnd(void); int coinflip(int small, int large); }
I'm making a simple calculator and have done it all right where you can input everything, all the functions are there, but when i run the program it will come to displaying the result and it will always equal zero, I just need it to say 8+8 = 16 rather than 8+8 = 0, i don't know whether its just displaying the results as 0, or not displaying it at all, the code will follow below:
So I want to go from having 0 or 1 to having words like false or true. I did it with an if statement earlier today, but I had to get rid of the whole bool thing. I made the variable just a float. But he requires we use bool. Here is my code:
Car y; cout << "Initial value for the Car: " << endl; cout << "Age= " << y.getAge() << " years old. The Price= $" << y.getPrice() << endl; y.setAge(8); y.setPrice(12000); y.setRaceCarStatus(true); cout << "Modified value for the Car: " << endl;
[Code]...
I commented (//) the if statement that I had earlier. If I set RacecarStatus to True, is cout's 1. The starred (*) line right above the comments is the line that I was required to add. I want to cout the actual word true. The one I had this morning won't work anymore.
I do not have code - I am just wondering if I have a method which gets input from the keyboard and returns it, how would I store that information in a new method after calling it and put the result of it into an array.
The results of my code is supposed to be very simple: return the 2 integers and then their sum. However, it's doing returning the first value, then an address in memory(rather than the 2nd value), and then the 2nd value(rather than the sum). Here is the code: