C++ :: Compiler Not Recognizing Numbers

Sep 8, 2013

I'm working on this homework assignment where the program takes in the user's height in inches, weight in pounds, and age, then calculates their hat size, jacket size and waist size. The formulas for these are as follows:

Hat: (weight/height) x 2.9

Jacket: (height x weight)/288 then adjusted by adding 1/8 an inch for every 10 years over the age of 30 (The adjustment only takes place after a full 10 years, so there is no adjustment for 30-39, but there is for 40)

Waist: (weight/5.7) then adjusted by adding 1/10 of an inch for each 2 years over the age of 28 (the adjustment only takes place after a full 2 years, so no adjustment for 29, but there is for 30, etc)

I'm supposed to utilize functions for each of the three formulas.

There's a couple things I can't figure out.

1. Why won't the compiler recognize 2.9 and 5.7 as numbers?

2. How do I adjust the calculation for the jacket and waist based on age?

Here's what I've got so far:

#include <cstdlib>
#include <iostream>
using namespace std;
double hatSize(int weight, int height);
double jacketSize(int weight, int height, int age);
double waistSize(int weight, int height, int age);

[code]....

View 1 Replies


ADVERTISEMENT

C++ :: File I/O Not Recognizing Contents Correctly

Nov 17, 2014

I have a program that's not doing what I want it to do. This is the assignment:

The nth term of the sequence of triangle numbers is given by, tn = 1/2 n (n+1); so the first ten triangle numbers are:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55,...

By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word value for SKY is 19 + 11 + 25 = 55 = t10. If the word value is a triangle number then we shall call the word a triangle word.

the 'words.txt' has a bunch of words in this format:

"ABSTRACT"
"YOUTH"

there's about 1000 words in that format.

And for any triangle words I find, I put it into another text file which I called triangle.txt.

Now for my program, it pulls the 'words.txt' file just fine but it doesn't recognize any of the words in the file as triangle words.

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <cmath>
#include <cstdlib>
int getCharValue(char a);
double sum1(std::string name);

[code]....

View 2 Replies View Related

C# :: While Statement Not Recognizing Non-null String

Oct 10, 2014

The List[] array contains some empty entries but most are filled, yet every time I run this routine the variable Index makes it to the end of the array. I've tried many different routes and can't seem to figure out this simple issue.

string Result = string.Empty;
while ((Index < (List.Length - 1)) || !string.IsNullOrEmpty(Result))
{
Result = List[Index];
Index++;
}
return Result;

View 9 Replies View Related

C :: Linked List Program Not Recognizing A Function

Oct 22, 2014

I'm writing a linked list program for class that has a simple text based menu and I believe I am nearly done, it just wont recognize my "count" function as a function and I don't know why. The error comes up at line 70.

Code:

#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int datum;
struct node *next;
} node_t;

[code]....

View 3 Replies View Related

C++ :: Intellisensor Not Recognizing String Data Type

Apr 26, 2014

So Im working on my semester prject for my programming class. It is to make a roulette game. And Im working on getting my table set up but the intellisensor in my Visual Studio seems to not be working and recognizing the string variable type. Its not changing to blue when I enter it.

This program is a roulette simulation, designed to be used for online gambling.

#include <iostream>
#include <iomanip>
#include <Windows.h>
#include <string>
#include <ctime>
using namespace std;
//Function Prototypes
void welcome();
double getBalance();

[Code] .....

When I run the program it gives me an error as well sometimes. This one: Unhandled exception at 0x0f681f68 (msvcp100d.dll) in Roulette Final Project.exe: 0xC0000005: Access violation reading location 0x8bb59d35.

Which opens another tab named "iosfwd" and points to this bit of code:

static int_type __CLRCALL_OR_CDECL to_int_type(const _Elem& _Ch)
{// convert character to metacharacter
return ((unsigned char)_Ch);
}

View 5 Replies View Related

C++ :: Using GNU GCC Compiler

Jun 9, 2014

I am programming with the Code::Blocks IDE and using the GNU GCC compiler. When I create an simple console application that uses strings it kind of glitches out, but here's the code:

#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
ered: " << x;

[code].....

What the output is:

Please enter a string of text: Hello World
You entered: Hello
Process returned 0 (0x0) execution time : 4.735 s
Press any key to continue.

Anyway I don't know why it removes what I typed after the space I put in between Hello and World.

View 1 Replies View Related

C :: Gcc Compiler And Pointers

Mar 3, 2013

The first sample program that I am reading on the book has the following code:

Code:

* Demonstrates basic pointer use. */
#include <stdio.h>
/* Declare and initialize an int variable */
int var = 1;
}

[code]....

Is this a compiler error or is there a proper syntax for pointers using the gcc compiler?

View 3 Replies View Related

C++ :: Class Not Seen By Compiler?

Sep 18, 2014

I have an issue. VS 2013 isn't recognizing objects that I've declared when I use class functions.I'm getting this error: "Line 14 and 15: Error C2228: left of '.asciiToFpc6' must have class/struct/union"...Here's the relevant code:

Source.cpp

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include "fpc6.h"

[code].....

Additionally VS apparently doesn't like my bitwise operators in my class functions and doesn't think they're doing anything. It gives "warning C4552: ['|', '<<', '>>', '&'] : operator has no effect; expected operator with side-effect" for all of them, but it seems to me the code should work fine and actually accomplish things....

View 9 Replies View Related

C++ :: Compiler Says There Is No Constructor But It Does Have One

May 29, 2013

Code:
activity = new Idle(this, NULL);
class Idle : public Activity {
private:
float mTimeInIdle;
public:
Idle() : mTimeInIdle(0) { }
Idle(Objects *actor, Goods *target) : Activity(actor, target)
{
}

Error 1 error C2514: 'Idle' : class has no constructors d:jackydocumentsvisual studio 2010projectsperfectsimperfectsimperfectsimObjectsObjects.h 43 1 PerfectSim

The activity = new Idle(this, NULL) line is located inside the Objects::Objects(...) constructor.

Would it be caused by some cyclic dependencies? How do I go about resolving it?

View 3 Replies View Related

C++ :: Compiler Optimization And Num Accuracy?

Jun 11, 2014

I could not find anything I could understand on this, so I have heard that -O3 option may reduce the numerical accuracy of doubles. Is this true?

View 11 Replies View Related

C :: Compiler Keeps Freezing / Crashing

Feb 11, 2014

I wrote this code as an assignment

Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
main(){

int story, age=0;
int ranColor, ranCar, ranItem;

[Code] ....

And my compiler keeps freezing/crashing. using Dec C++

View 4 Replies View Related

C/C++ :: Compiler Configuration With Eclipse

Jul 7, 2014

I am using Eclipse to write C program. I download the CDT. However, I wrote the code but when I build it, I got an errors.

Make:*** No rule to make target all, Stop

View 10 Replies View Related

C/C++ :: Download And Install Gcc Compiler?

Jul 20, 2014

how to download and install gcc compiler?

View 4 Replies View Related

C/C++ :: Splint Warning In GCC Compiler?

Jun 7, 2012

/*@out@*//*@null@*/char *string_read ( ) {
int ch , pos = 0;
char *string;
if ((string = (char *)malloc (STRING_SIZE*sizeof(char))) == NULL)

[Code] ......

Fresh storage string not released before return A memory leak has been detected. Storage allocated locally is not released before the last reference to it is lost. (Use -mustfreefresh to inhibit warning) string_read.c:6:7: Fresh storage string created

View 1 Replies View Related

C++ :: Check If Compiler Has 11 Enabled?

Jan 28, 2012

Is there a way to check if a compiler has c++11 enabled?

I have a library and it has converters between std strings and the internal string type. I current have preprocessor surrounding the converters for u8string, u16string, and u32strings, but it requires the end user flip the switch manually. It would be nice if I could know at compile time without being told whether or not those types exist.

View 3 Replies View Related

C++ :: When Compiler Do Template Instantiation

May 2, 2014

As we know in the compilation stage, the compiler will instantiate a concrete type for a template, for example:

template<class T> void test(T m ) {
cout << m << endl;
}
int main() {
int kl = 0;
test<int>(kl);
}

In the main function, the compiler will try to have a int entry. Also we know that in the compilation stage, generally we have several steps: lexical analysis, syntax analysis, grammer analysis and intermediate language(IR).

So my question is: In which step is the instantiation done? Before IR or after IR?

View 1 Replies View Related

C++ :: Compiler Command Line Arguments

Jun 15, 2013

I have found this C++ online compiler (to use when I am at work): Compile and Execute C++ online

When you write and compile a program, on the right side (the "output" side), you can read this command line arguments:

$ g++ main.cpp -o demo -lm -pthread -lgmpxx -lreadline 2>&1

What is the meaning of the following arguments? -lm [link the math header file, right?]

-pthread
-lgmpxx
-lreadline

Any book (ebook, tutorial, printed book, whatever) where I can find all (absolutely all) these and other possible arguments?

View 2 Replies View Related

C++ :: Compiler Error C2664 And C2228

Nov 9, 2013

Working on a basic class program and I'm generating two compiler errors that I'm not sure how to fix. Header file, implementation cpp and main cpp are shown below. The specific errors are shown after the code.

Header file Code:

#include <iostream>
#include <string>
#include <cstdlib>
#include <iomanip>
using namespace std;

[Code].......

The file generates the second error, C2228, at lines 37-41 and 43. Basically where I tried using the second created object. Error message is "left of '.setFirstName' must have class/struct/union"

View 8 Replies View Related

C++ :: Compiler Error C2370 And C2011

Nov 29, 2013

Working on a solution involving inheritance. The whole solution is pretty massive at this point so I'll just focus on the problem areas. I'm getting a lot of "redefinition" and "undefined class type" compiler errors, including C2370, 2011, 2504, and 2027, in Benefit.h, Employee.h (the constant members are a big occurance) I'm also getting 2027 and 2079 in EmployeeMain.cpp. with my Benefit and Employee object calls.

Clearly I missed something in about how to code this correctly. Sadly the course textbook focuses on general OOP theory instead on the accompanying C++ syntax.

Benefit.h
Code:
#include <iostream>
#include <string>
#include <cstdlib>
#include <iomanip>
using namespace std;

[Code] .....

View 4 Replies View Related

C :: Determine Compiler Version And Which Standard It Uses?

Jul 18, 2013

Is there any code I can use to determine my compiler version and which Standard It uses? I know the following code determine that my compiler followed ANSI But how about a version of that? ****My OS is now Ubuntu

Code:
#include <stdio.h>
int main(void){
printf("File :%s
", __FILE__ );
printf("ANSI :%d
", __STDC__ ); //return 1 if it follow ANSI but version?
return 0;
}

View 3 Replies View Related

C :: Does Compiler Only Check Qualifiers Of End Destination

May 28, 2014

Code:

#include <stdio.h>
#include <stdlib.h>

const int* const ret_con()
{
typedef const int* const cip_to_c;
}

[code]....

I have two basic questions about what is happening:

1. The return value of ret_con should be pointing to const, but instead it's pointing to a (non-const) pointer to const. Does the compiler only check the qualifiers of the end destination, why doesn't this give a warning?

2. The original variable from ret_con (ci) is a local automatic, shouldn't its lifetime have expired when you leave the scope?

I also checked this with C++ compiler (taking out the auto keyword), it gave no warnings either.

View 4 Replies View Related

C :: Compiler That Change All Variable In One Occurrence?

Feb 3, 2013

what compiler that change all variable in one occurrence?

View 5 Replies View Related

C++ :: Writing Simple Compiler For A Language

Mar 13, 2014

I have a problem about compiler.I want to write a simple compiler for a language.

stm -> id := expr
| print expr
| if expr then stm
| while expr do stm
| begin opt_stmts end

[Code] .....

I guess I should create main.c to convert source code.Also,I should create a source.c to write a example program that is relevant with above grammar.

View 1 Replies View Related

C++ :: Unexpected Expression Compiler Error

Jul 30, 2013

My compiler (GCC) keeps expecting an expression where it shouldn't in 1 specific piece of my code:

int zxcNewWindow( HWND parent, TCHAR *text, zxWINDOW *kid,
UINT style, int x, int y, int w, int h, int type )
// right here
{
*kid = zxDefWINDOW;

The project contains only 2 files right now and the settings are just the default for an empty Code::Blocks 12.11 project. Both files are in UTF-8 format (tried in ASCII too), I just cannot see why this is not compiling correctly. I'll post the files in the next two posts.

Edit: For those of you who didn't get what the error was from the above here's the full log:

mingw32-gcc.exe -Wall -g -DzxDEBUG -c C:MePrjscppzxGUImain.c -o objmain.o
C:MePrjscppzxGUImain.c: In function 'zxcNewWindow':
C:MePrjscppzxGUImain.c:39:10: error: expected expression before '{' token
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)

View 8 Replies View Related

C++ :: Functions Are Exceeding Compiler Limitations?

May 21, 2014

I have made a novel library project but my functions are exceeding compiler limitations... I tried to resolve it but failed

View 1 Replies View Related

C++ :: Compiler Error - Expression Must Have A Constant Value

May 20, 2014

I am trying to run this source code but i am getting the compiler error Expression Must Have a Constant Value. I tried making both the variables x and y constants and assigned them to a significantly big number but then i am getting the error expression must be a modifiable lvalue.I have made comments in the code in front where Visual Studio is giving me the syntax error (red squiggly line).

#include<iostream>
#include <string>
#include<cmath>
using namespace std;
int main(){
int x;
int y;

[Code] ......

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved