Here your supposed to create a program that takes in information and formats it into three columns.
I can't seem to use the float variable unitprice with decimal places here for, if I try to use %.1f and type in an input, the program seems to skip over the second scanf function, not allowing me to put input into the third scanf function as the program runs before I can.
I can use %f on its own and it works but this creates too many zeroes(and you're supposed to set the currency limit to $99999.99).
Code: #include <stdio.h> int main(void) { int itemno, month, year, day; float unitprice;
[Code]....
So the output should look like three columns. It's just the float that is the issue here....
My Question is when i compile this code in Linux platform Using g++ compiler My sample.o's Size is 1Kb.. But when the same code is compiled in Windows platform using VC++ Compiler , My sample.o's size is 42Kb..to reduce the size in windows... Is there any proble with '#include <string>' in Windows platform.
I've been in a strange problem. Im in need to have a dynamic character size, but that increases the outputsize of my program by almost 50kb. (while the program was 11kb previously).
#include <iostream> int ival1 int ival2=1 int summe /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main() {
I keep getting an error here and cant quite figure out why,
Code: else if (mainMenu == 3){ cout << "Please make a selection" << endl << " 1) Withdraw from account" << endl << " 3) Back to main menu" << endl; cin >> withdrawMenu;
I wrote a program, that generates 20 random integers, and stores them in an array. Then I decided, to build more functions to it, i.e why not have it to display the lowest integer of an array. I created my function,
Code: int minValue( int field[ ] )
and got my code in side, which (technically) works. In my main() function I'm calling
Code: printf( "The smallest value of an array is: %d ", minValue( field[] ) );
and I'm getting an error trying to compile it.
Code: randomArray.c:62:74: error: expected expression before ']' token printf( "The smallest value of an array is: %d ", minValue( field[] ) );
After compiling it is giving error as : foo.cpp: In function ‘int Foo_max(Foo*)’: foo.cpp:26:37: error: expected primary-expression before ‘int’ foo.cpp:26:46: error: expected primary-expression before ‘int’
This first Dowhile loop is saying "expected unqualified-id" at the do and while parts. What does that mean
do { do { do { std::cout << "Give me a test result or grade from 0 to 100 for class"<< 1 << std::endl; std::cin >> mathaverage[mathtestcount]; loopresult=1;
I have a template class (A) that derives from a either a base class that has a member (_A1.m) or not (_A0), based upon it's template parameter. class (A) has a member function (fn) returns the value of (m) as it understands what (m) is.
However, this gives different results compared with a non-template class in a similar scenario. I'm expecting that if derived from _A1, that m should be taken from the base class scope and if derived from _A0, it should be taken from the global one.
Here is the code for your amusement:
int m = 5; class _A0 { public: _A0(int) {
[Code] ....
This compiled using g++ 4.5.3 and 4.6.3 with the same results: Global value of m is: 5 B0 class has no internal m member. Object resolves m internally with value 5 B1 class has internal m member. Object resolves m internally with value 3 A<_A0> class has no internal m member. Object resolves m internally with value 5 A<_A1> class has internal m member. Object resolves m internally with value 5
#pragma once #include <iostream> class CBox // Derived class { public: // Constructor explicit CBox(double lv = 1.0, double wv = 1.0, double hv = 1.0) : m_Length(lv), m_Width(wv), m_Height(hv){}
[Code] .....
Before the program ends, at return 0;
I would expect the CBox destructor to be called 3 times but it is being called 6 times? Why? Also in this code:
#pragma once #include <iostream> class CBox // Derived class { public: // Constructor explicit CBox(double lv = 1.0, double wv = 1.0, double hv = 1.0) : m_Length(lv), m_Width(wv), m_Height(hv){}
[Code] .....
Why is the destructor called 3 times? When have you really destroyed a CBox? Doesnt emplace only create it and store it, then thats it?
[URL] .....
For pushback:
void push_back(value_type&& _Val) {// insert by moving into element at end if (_Inside(_STD addressof(_Val))) {// push back an element size_type _Idx = _STD addressof(_Val) - this->_Myfirst;
I'm trying to perform a simple input operation, and check to make sure that whatever the user input is a valid input (is within data type bounds, is correct data type...). But when I get to ignoring the input, I keep getting an error.
unsigned short num; while (true) { std::cin >> num; if (std::cin.fail()) { num = 1;
#include <stdio.h> #include <math.h> main() { int n; int k; int j; //gets user input for length of string printf("Enter the value of n:"); scanf("%d", &n);
[code]......
When I compile my code I get an error saying that I need declaration specifiers in my is_prime subroutine in the for loop.
Code: void change(pixel_t *pixel, int w, int h, pixel_t *buffer) {
int average, sum; int i; pixel_t *pointer;
Everything else works fine. I keep getting an error when I call the convert function. It says "expected expression before pixel_t" and "too few arguments to function "change". I know that everything else in the main is working.
I am trying to parallelize some of my code with OpenMP. When I switch to using multiple threads I start getting random numbers that are out of the expected range.
Here is a small example:
Code: #include <stdio.h> #include </usr/local/include/gsl/gsl_rng.h> #include </usr/local/include/gsl/gsl_randist.h> int main() { int mySeed=0; const gsl_rng_type *T; T = gsl_rng_ranlxs2; gsl_rng *r_1 ;
[Code] .....
gsl_rng_uniform should only output number in the range [0,1) but with multiple threads it outputs larger number as well.
I tried my best but I can't figure out the problem. At the last part of "createArray", I output the final array created. I mean it to repeat once but then it repeat more times than I expect. createArray is an iterative function. If it repeats 3 times, than at last the array created which fulfil the criterion would be printed out 3+1 times.
I am trying to create an array with 3 numbers 5 times, resulting in a 2D array. The 3 numbers in a array are picked from 0 - 5. I enter createArray(5,3,5). Then these 5 arrays are compared with each other to see if there are repetitions. If there are, the whole process begins again, 5 arrays with 3 numbers each will be picked again and compared with each other. If there are no repetitions at last, there 5 arrays would be printed out.
void deleteArray(int** array){ delete[] array; } int** createArray(int simu_times, int randomrun,int numberofrun){ vector<Int_t>fChosenRun; int** Array = new int*[simu_times];