C/C++ :: Falling Object Error When Coding

Mar 4, 2014

Write a program that computes how many feet an object falls in 1 second, 2 seconds, etc., up to 12 seconds.

1.Have a procedure called FallingDistance which has one input parameter, seconds, and one output parameter, distance.
2. Compute the distance in feet an object falls using this formula: d = ½ gt2
(where g = 32.2)
3. The main program should call FallingDistance within a loop which passes the values 1 through 12 as arguments.
4. Print a table with seconds and falling distance in feet.

Sample Output (This program has no input)

Seconds Distance
================
1 16.1000
2 64.4000
3 144.9000
4 257.6000
5 402.5000
6 579.6000
7 788.9000
8 1030.4000
9 1304.1000
10 1610
11 1948.1000
12 2318.4000

In C++, the procedure is called a function. Instead of using an output parameter, your C++ function FallingDistance should return a result of type double. This is what I created:

#include <iostream>
#include <cmath>
#include <string>
using namespace std;
const double g =32.2;
double fallingDistance(double);

[Code] ....

which gave me this error:

1>------ Build started: Project: Lab 6, Configuration: Debug Win32 ------
1> Source.cpp
1>c:usershanahdocumentsschoolprogamming ilab 6lab 6source.cpp(27): error C2065: 'fallingdistance' : undeclared identifier
1>c:usershanahdocumentsschoolprogamming ilab 6lab 6source.cpp(36): error C2065: 't' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

View 4 Replies


ADVERTISEMENT

C/C++ :: Simulating Falling Object Using Vectors

Mar 11, 2014

I'm just having a bit of troubles on getting my code to work from this psuedo code - It has been asked for the object to be set at at least a height of 30 units (in the y property). -

#include <iostream>
#include <Windows.h>
#include <conio.h>
using namespace std;
struct Player {
float position ;
float velocity ;

[Code] ....

Attached image(s)

View 14 Replies View Related

C++ :: Switch Statement Falling Through All Cases

Jan 16, 2014

I was getting errors and I looked into the error and it told me to fix it by adding Code: { } in my case statements. I did, it compiled but fell through the whole thing. Lets say I enter 1, it outputs the was not found 5 times in a row.

Code:
void addressbook::EditNameOrDate() {
std::cout << "Enter 1 to Edit the contacts First Name: " << "
";
std::cout << "Enter 2 to Edit the contacts Last Name: " << "
";
std::cout << "Enter 3 to Edit the contacts Street Address: " << "

[Code] .....

View 8 Replies View Related

C++ :: Animated Images Falling From Top Of Screen - Drag These Items Into A Basket

Apr 18, 2012

Im developing a game where i need 18 animated images to fall into view from the top of the screen with 14 of type A visible and 4 of type B. I then need to be able to drag these items off screen or into a basket at the bottom of the screen.

My current issues are:

I cant seem to drag the images off screen or to the basket when they are animated.I cant make the images fall randomly with delay between them.I was able to make the 18 appear, but not as listed above in the description with 14 of type A and 4 of type B.

View 2 Replies View Related

C++ :: Compilation Error Redefining Object

Oct 17, 2013

main:

#include <cstdlib>
#include <iostream>
#include <fstream>
#include "Board.cpp"
int main(int argc, char* argv[]){
argc=5;
argv[argc];

[Code] .....

I can't find a place where there are two definitions of any of the Board methods

View 9 Replies View Related

C++ :: Error Passing Object Reference

Nov 23, 2013

Code:

#include <Data.h>
int main(int arg_count, char** argv) {
if(arg_count!=3){
cerr<<"Files misisng
";
exit(1);

[code]...

This actually should work, because it is passing address of polymorphisms object.I have tried changing prototype of test in Data.h, but failed.passing object address/pointers in C++.

View 5 Replies View Related

C++ :: Error Returning Object From Function?

Nov 24, 2013

Code:

class Main{
class B b_obj;
C c_obj=b_obj.test("some",89); // I cannot get this done.!
}

Below are .h files:

class B{
public:
C* test(const char *, int); /// this doesn't work
constructor
//member variables

[Code] ....

However, map<string, vector<bol>> test(const char *, int); works.I know second thing will work, but how to take reference of class object?

I have include .h file in main, B and C, wherever it is required.

View 4 Replies View Related

C++ :: Enter Value For Coding

Oct 1, 2013

some where in main:

char value;
char* sname;
sname= new char[20];
for(int i=0;i!=19;i++)
{
cin>>value;
sname[i]=value;
}

I need a stopping case when user press enter array get closed and add '' at the end but how to do that?

View 1 Replies View Related

Visual C++ :: Compiler Error With Cout Object

Dec 15, 2012

I am asp.net C# developer. I decided to tackle C++, so I started today. This is probably something simple I am sure.

Code:
srand(static_cast<unsigned int>(time(0)));
int choice = rand() % NUM_WORDS;
string theWord = WORDS[choice][WORD];
string theHint = WORDS[choice][HINT];

[Code] ....

The error is happening on the last output operator, just before the jumble variable on the last line.The error is:

Code:
Intellisense: no operator"<<" matches these operands

operand types are: std::basic_ostream<char, std::char_traits<char> <<std::string

I understand what its saying, but jumble is a std::string

Here are my preprocessor directives and using statements

Code:
#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

View 4 Replies View Related

Visual C++ :: Object As Data Member Having Error

Sep 20, 2012

class CPop {
CBSVector<CTour> pop;
CBSVector<double> probability;
int popsize;
double TotalFitness;
CTour Elite;
CTspGAParams GAParameters;
}

error C2059: syntax error : 'constant'
error C2238: unexpected token(s) preceding ';'

I don't know y these errors, it runs fine in simple c++ environment

View 14 Replies View Related

C++ :: Passing Array Of Object Gives Compilation ERROR

Dec 21, 2012

This is my question : Define a class named HOUSING in C++ with the following descriptions:

Private members
REG_NO integer(Ranges 10 - 1000)
NAME Array of characters(String)
TYPE Character
COST Float

Public Members
-Function Read_Data( ) to read an object of HOUSING type
-Function Display() to display the details of an object
-Function Draw Nos( ) to choose and display the details of 2 houses selected randomly from an array of 10 objects of type HOUSING Use random function to generate the registration nos. to match with REGNO from the array.

Now I' trying to do this by this way

Code:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
class housing {
private:
int REG_NO;
char NAME[10];

[Code] .....

I am trying to pass the entire array of object in DrawNos(). but getting compilation error -

32: 'housing:rawNos(housing * *)' is not a member of 'housing'
48: Structure required on left side of . or .*

What is the problem? How can I pass the array of object in function and use it.

View 3 Replies View Related

C++ :: Coding And Debug Time Per LOC

Mar 23, 2013

I just spent 3 hours writing and debugging 37 lines of code. Is this normal or am I "below average" in coding abilities. I come from a C background and decided to write C++ code that I finally got right as shown below for the specific example:

Code: #include <iostream>
#include <fstream>
#include <string>
#define SPACE_SEARCH 10
using namespace std;

[code].....

I think it was more the learning along the way that consumed atleast 75% of my time for this specific case. But then again, I read that programming always entails learning along the way and so its somehow no excuse for the long time taken in this specific case.

So as a matter of interest, what pace do all of you operate on, on average? i.e. LOC/day, Debugs per day or any other indicator of productivity?

View 3 Replies View Related

C :: Coding MP3 File Into A Program

Oct 16, 2013

Is there a way to put a mp3 file into a c program without having the windows media player pop up in the background each time you compile the program? I just wanted to input a few seconds of an audio file..

View 3 Replies View Related

C++ :: Error / Variable-sized Object (largeArray2) May Not Be Initialized

Feb 28, 2013

when i compile my code i get this error : "error : variable-sized object 'largeArray2' may not be initialized"

Code:

float give_coefficients_routh_table_and_fill_two_first_lines(int denominator_degree)
{
float largeArray2[20][20] = {0};
int l = 0;
int c = 0;
int e = denominator_degree ;
for ( e = denominator_degree; e>=0; e--)

[Code] .....

View 9 Replies View Related

C++ :: Error When Using Volatile Object In Overload Assignment Operator

Jul 27, 2012

/*using GENERIC_COMMAND* A; as volatile generates error. but here i have to use union object as volatile i.e. volatile GENERIC_COMMAND* A; */

#include <iostream>
using namespace std;

typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
union GENERIC_COMMAND {

[Code] .....

View 14 Replies View Related

C++ :: Imebra Functionality QT Project Gives Malloc - Error For Object

Nov 2, 2012

I'm trying to convert dicom .dcm file to .jpeg using Imebra in C++ app using QT Creator as dev environment.

I've downloaded Imebra and was able to run QT project example for Dicom2Jpeg conversion successfully. But when I tried to copy same code to my C++ app it failed to run with following error msg:

malloc: * error for object xxxxxx: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug

I have followed steps on adding Imebra files to my project as it was shown on Imebra site. Also used their qt project as example. My main.cpp open dicom file, then loads it to dataset, then calls my dialog window. It crashes on loading dataset.

#include "QApplication.h"
#include "QHBoxLayout.h"
#include "mydialog.h"
#include "iostream.h"
include "library/imebra/include/imebra.h"
int main( int argc, char ** argv ){

[Code] ....

Deeper debugging showed that source of error is in JpegCodec.cpp file readStream() function when checking JpegSignature to see if it's in wrong format with resulting internal PUNTOEXE error "detected a wrong format".

Interesting thing is that while running same test dcm file using given dicom2jpeg example (which has exact same code of opening file and loading it) gives no errors and converts to jpeg successfully. So I know it's not the file issue, but the way imebra code is integrated into my C++ app.

My dev environment: macbook pro with Lion OS, QT Creator, QT project, C++ code, ITK library added, Imebra files are completely integrated as part of the Qt project.

So, my question is how do I work/link/reference/call Imebra functionality in QT project? Am I forgetting to link something, or some object is not instantiated/deleted on time?

View 2 Replies View Related

C++ :: How To Start Coding Audio Synthesizers

Mar 20, 2013

I'm interested in learning how to write the software for audio synthesizers. a friend of mine started on the hardware side for them and, as i have no experience with this type of code.

View 7 Replies View Related

C++ :: Compound Interest Formula Coding

Sep 24, 2014

Im having problems coding this
A = P(1 + r/n)nt

//Declared test cases
float principal = 200000.00, annualInt = 0.03;
float years = 10.0;

float calcInterest1(float principal, float years, float annualInt) {
float interest1;
float nt = annualInt*12;
float A = principal+annualInt;//Accrued Amount
interest1 = (A = (principal*(1+years/100))pow(nt));// A = P(1 + r/n)nt
return interest1;
}

View 1 Replies View Related

C++ :: Check The Coding Style Use In A Program?

Apr 30, 2014

Is there any opensource tool which can check the coding style use in a program.

View 2 Replies View Related

C++ :: How To Open Notepad Application Through Coding

Aug 14, 2012

I java We can be able to open any application through coding.. likewise Is it possible to open through c++?

View 3 Replies View Related

C :: Got Stuck In Simple Coding Process / How To Initialize Any Value

Mar 2, 2013

in order to calculate some logarithm approximation I need to make a variable, say s, search through the whole integer numbers.

Code:
int s;
for {;;s++){
}

[Code] ....

since the variable needs to be initialized right? how to go through all the numbers?

View 3 Replies View Related

C++ :: Coding A Loop Inside A Class To Use In Main

Feb 22, 2013

I am writing a program where all work is done in the class methods. Main is used to call the methods. I need to know how to get a loop to work without any variables in main that can be used outside the methods. This is what I have in main:

#include <iostream>
#include <string>
using namespace std;
#include "FerryBoat.h"
int main() {
//create a constructor for a ferry boat
FerryBoat myBoat('B', 20, 'A');

[Code] ....

View 3 Replies View Related

C Sharp :: Coding For Quantities In Online Shopping Carts?

Jan 11, 2013

I am trying to create an on-line product store. I'm having trouble with setting up the code to correctly acknowledge quantity desired per product item in the shopping cart at check-out. I want to be able to capture multiple impressions/hits/clicks per item and increase the # in the quantity box each time someone clicks on the same item. For example, if product A is clicked 3 times, then the quantity in the shopping cart should show "3". If it's clicked 5 times, it should show "5" and so on ... However, right now, it's showing the product multiple times in the shopping cart with a quantity of "1" for each time the item was clicked. How can I correct this?

View 2 Replies View Related

C++ :: Threads Giving Error - Call Of Object Of A Class Type Without Appropriate Operator Or Conversion

Jan 27, 2015

I made a simple binary tree then decide to try out threads too. I got the following error:

call of an object of a class type without appropriate operator or conversion

Code:
#include "Tree.h"
#include <iostream>
#include <thread>
void main(void){

[Code] ....

I am having a hard time figuring out why the error exists. I tried adding the new operator but that did not work.

View 11 Replies View Related

C++ :: Will Copy Constructor Does Object Initialization Using Another Already Created Object

Mar 16, 2013

will copy constructor does object initialization using another already created object? I understand that it can be applied for object initialization and not for assignment.Is it correct?

View 10 Replies View Related

C# :: Method Is Overwriting Both Instance Of Object And Original Object

Jul 3, 2014

I have a method to take a Tile object and make an instances of it based on some data from the original object. Than it is suppose to manipulate the a specific instance and save the results. The first loop through it works but it changes all instance as well as the base.

public static int recurse(int count, Tile[,] b,Huristic h,int check) {
if (check==1) {
boardState.Add(B)/>;
return check;
} if (check == 0)

[Code] .....

View 6 Replies View Related







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