C++ :: Generate Data Set Of Angles Automatically And Provide Three Columns (Sin / Cos / Tan)

May 8, 2014

Given an array of angles A = [0 30 60 90 120 150 180 210 240 270 300 330 360]

Write a program that will generate the data set of angles automatically and provide three columns; sin(angle), cos(angle), tan(angle). Make this program as compact and readable as possible.

View 2 Replies


ADVERTISEMENT

C++ :: Data Changes Automatically In Array

Dec 9, 2014

I am trying to execute a very simple piece of code. But I am unable to find how the value of T[i][j] is changing all of a sudden. CODE:-

insert Code:

void initialize(float** &T,int NP,int D,int low,int high) {
int i = 0,j = 0;
T = (float **)malloc(NP*sizeof(float));
for(i = 0;i<NP;i++)

[code].......

View 2 Replies View Related

C++ :: Storing Data From 2 Columns In CSV

Oct 17, 2013

I have a file that can range from 100 rows to 10000+ that is comma delimited with 8 columns. The first 32 rows (also comma delimited) will always be ignored (geographical header information). I will be wanting the data from column2 and column3.

For this I believe I would need (2) For Loops as such:

for(i=0;i<2;++i) {
getline("do something here");
}

and

for (i=0;i<3;++i) {
getline("do something here")
}

Also would using a vector or array with dynamic storage be the better way to tackle this problem? Where to start from after accessing the file.

View 19 Replies View Related

C++ :: How To Add Labels For Different Columns Of Data

Sep 20, 2014

I am trying to add labels to the data. I have data in a file divided by space:

1 2 3 4 5 6
7 8 9 10 11 12

I need it to look like this:

label_1: 1 2 3 4 5
label_2: 6
label_1: 7 8 9 10 11
label_2: 12

How can this be done?

View 1 Replies View Related

C++ :: Make A Table Class That Will Be Able To Have Multiple Columns Of Data?

Sep 17, 2014

I am trying to make a table class that will be able to have multiple columns of data. I want it to have something to hold data (I was using a 2D vector for only one data type) in it, somewhat like a pair, but for any number of data types. The class is a template to make it generalized.

I have looked a little at variadic templates, but I don't know how to declare the vectors for each data types then.

View 4 Replies View Related

C/C++ :: Columns In Fstream Data Reading Zero (Array Of Payroll Objects)

Dec 4, 2014

Basically for homework, we gotta make an array of payroll objects, using the general format I've made below...

I'm having trouble. The .dat file we are given to test looks like this:

40.0 10.00
38.5 9.50
16.0 7.50
42.5 8.25
22.5 9.50
40.0 8.00
38.0 8.00
40.0 9.00
44.0 11.75

When I execute the program, it shows the first column of objects, but will always replace the 2nd column values with a 0.

It's definitely NOT reading that column, and using the constructor to set it to zero. I don't know why it's not reading that column though...

(TL;DR.... Currently it reads "Employee #1: 40, 0" rather than "Employee #1: 40, 10.00"... etc)

Here's my code.... (not 100% done yet just testing datafile output atm)

#include <iostream>
#include <fstream>
using namespace std;
class Payroll {
private:
double payRate; // holds an employee hourly pay rate

[code]....

I want it to read the other column without giving me zero />

View 2 Replies View Related

C++ ::  Class Creation And Storing Angles

Dec 22, 2013

I have a quick question. I need a way to represent orientation in degrees. I made a class which automatically changes negative angles into positive ones (adds 360 until >0) and makes sure they are under 360 (subtracts 360 until <360).

Now I realized I also need a class to represent angular movement, which must be in the range ]-360;360[

I don't think custom types with the unsigned keyword is a thing, but I'm just looking for a better way to do this then making two classes. Or would you just create a class which inherits from angle and overloads a few methods?

Or I could just use floats to represent rotation, because testing if an object does more than 1 turn per second isn't really required.

View 9 Replies View Related

Visual C++ :: MFC Coordinate System - Drawing Of Angles?

Oct 11, 2013

I am drawing in a simple (square) MFC window. I realize that (0,0) starts in the upper left hand corner. I wanted to see how MFC handled drawing of angles, so I use this code:

Code:
double CompassDegreesToRadians(double compassDegrees) {
return((PI / 2.0f) - (compassDegrees * PI / 180.0f));
}
// Make pen
CPen penRed;
penRed.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(255, 0, 0));
// Test Angles

[Code] .....

Using this code, and changing the value of angle1 to these values (0, 90, 180, 270) I think MFC uses the coordinate system:

Code:
180 -y
|
|
-x 270---------------- 90 +x
|
|
0 +y

This seems like a strange coordinate system to use. Am I doing something wrong? If this is correct, how can I convert my calculations to this coordinate system? (compass degrees):

Code:
0 +y
|
|
-x 270---------------- 90 +x
|
|
180 -y

View 4 Replies View Related

C++ :: How To Generate Two Files And Write Data Into

Apr 5, 2013

I try to write my data into two different files and i just use something like this

ofstream myfile;
myfile.open("phase 1.txt");
if (myfile.is_open()) {
for(i=0;i<M; i++) {

[Code] .....

But it only generate the first file. How should i modify this?

View 2 Replies View Related

C++ :: Generate Random Data (fast)

Feb 20, 2013

I just want to know how fast can C++ generate data? For example, I have a downstream device that is connected to my pc via a Gigabit Ethernet, and I have to generate some pattern and send it over the Gigabit interface.

I was curious if there is a way that I can see how fast I can generate data? I was curious if I can exercise a good portion of the bandwidth ! for example, sending about 600 Mbits/sec.

How do I find out, first, whether I can do this with C/C++, and, second, how do I know how fast I am sending data?

View 4 Replies View Related

C++ :: Generate A Binary String Based On Hex Data

Apr 23, 2013

Generate a binary ascii characters(weird character ) based on Hex:54313032202020303030 data in C++

View 3 Replies View Related

C++ :: Generate Array Of Data Using Templates Into Programme Memory?

Apr 24, 2013

When you have constant arrays, they are stored in the programme memory space. Upon execution, they are copied into the data space for easy access. To save space in the data space, it is possible to stop it from being copied. Some compilers will deal with this by just specifying the array as const, g++ has a type modifier called PROGMEM.

In any case, the problem is that I'd like to generate some data, preferably without using an external programme to do it. Hence, my question using the template system. Now I could possibly use macro metaprogramming via boost instead of template metaprogramming, and I may have to go that route. However there are limitations, especially since its numbering system is only equivalent to an unsigned byte, which I possibly could use, but could become more messy than if I use the template system that has long long types as well as a whole slue of type safety mechanisms.

View 14 Replies View Related

C :: Generate A Program That Will Allow User To Enter Data For A Stock And Calculate Amount Of Stocks

Oct 5, 2013

Okay, so my assignment for my C class is to generate a program that will allow the user to enter data for a stock and calculate the amount of stocks that ended up being positive, negative, and neutral.I tried to do this using one stock, here is my code;

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

Code:

void main()
{
float Neg;
float incst;
float shrs;
float bpps;
float crnt;
float crntcst;
float yrfes;
float pft;
float tpft;
}

[code]....

View 6 Replies View Related

C++ :: Graph Class - How To Provide Virtual Iterators

May 29, 2013

I have a 'Graph' class, which has derived classes for Adjacency Matrix and Adjacency List representations.

How do I provide iterators for traversing vertices and edges, when the iterator classes would have different implementations for the different derived classes ?

The following way is the only one I can think of, but seems quite cumbersome.

Code:
class Base {
public:
class BaseIterator {

};
virtual const BaseIterator& begin();
virtual const BaseIterator& end();

[Code] .....

Or is there a pattern for doing this that I'm not aware of ? Would composition be a better idea here compared to polymorphism ? I mean, I can think like..a Graph can 'have' several representation 'objects' within it.

All the involved classes are templates,not sure if that makes the situation different.

View 7 Replies View Related

C++ :: Program Should Provide Option To Save Outputs In A File

May 6, 2014

I need to do a code that gave me Original string, uppercase string, lowercase string, reverse string (if letter is upper then convert to lower, and if lower then convert it to upper) and uppercase first (first character of each word in uppercase).

I need to do it in functions but i dont know hot to use strings. The program should provide the option to save the outputs in a file.

View 4 Replies View Related

C++ :: Best Way To Show A Program Remotely And Also Provide Console Input?

Sep 27, 2013

I want some people to see my C++ program, enter inputs (they can enter number 1, 2, 3, etc) as CIN, and then the program runs as it would if they were sitting in my place.

I have seen a few places which try to do this e.g.

[URL]

The problem is the CIN is not fully featured. For example in the first website you have to enter the input before you run the program. So that would not work for a program where CIN was being done all the time.

So I can get a domain, ask them to telnet into the Linux shell and compile and run my c++ Demo program. Is that the best way? Thats the worst case. I send them the .cpp file and they'll have to run and compile it on their own machine.

The best case is that they click on a link, get an online console and interact with it like they would with a real input/output c++ interface.how this can be done?

View 1 Replies View Related

C# :: Abstract Class Provide Functionality Without Affecting Child Classes?

Mar 6, 2014

The abstract class can provide more functionality without affecting child classes.If we add any method to the interface ,then will it affect all the child classes ?

View 2 Replies View Related

C++ :: Using OOP To Implement Matrix Class That Provide Basic Matrix Operations

Mar 27, 2013

i want to know how i can solve this question? do i need to create a class or write the program codes.

View 12 Replies View Related

C++ :: Does Int Vars Automatically Get Assigned (0)

Feb 13, 2015

I am wondering if integers and unsigned integers automatically assigned to zero (0) upon declaration like so:

bool randomFunction() {
int i;
if (i == 0) {
return true; //Will most modern compilers return true here?
} else {
return false;
}
}

I am just curious as I have always initialized my ints/unsigned ints variables. Would save me a lot of typing if I didn't have to do this all of the time.

I know that floats and doubles you still have to initialize.

View 4 Replies View Related

C++ :: Adding New String Automatically For Each Name

Sep 17, 2012

Im doing a little game, casting dices etc. The problem is that the program will ask for player 1 then if i enter a name and enter it will ask for player two and so going on until i just press enter with a empty field and then continue the game.

The problem is i don't have any clue what code bits to start studying and how i shall lay it up, feels like i need a new string declaration automatically for each name.

View 5 Replies View Related

C++ :: Template Parameter Automatically With Class Name

Mar 8, 2013

I have a triple hierarchy class:

template<class T> class Singleton;
class Base;
class Sub : public Base, public Singleton<Sub>;

I' using underlying auto pointers, that's why Singleton is a template class and Sub passes itself as a template parameter. I'm developing Singleton and Base and a public API allows anyone to add their own sub classes. I actually want a real triple hierarchy like this:

template<class T> class Singleton;
class Base : public Singleton<Base>;
class Sub : public Base;

So that external developers don't have to worry about templates and complexity. The problem with this is that my implementation in Singleton will now call the constructor of Base whenever I create an instance of Sub (since the template parameter is Base).I was wondering if this could be done by pre-processor macros:

template<class T> class Singleton;
class Base : public Singleton<__CLASS_NAME__>;
class Sub : public Base;

Where __CLASS_NAME__ is the class name that will be replaced by the pre-processor. Theoretically this should be possible, since the __PRETTY_ FUNCTION__ macro actually returns the class name. The problem is that one cannot do string-manipulation to remove the function name from __PRETTY_FUNCTION__.

how I can accomplish this so that the Sub class is not aware of inheriting from a Singleton<template> class?

View 9 Replies View Related

C++ :: Is Memory Freed Automatically In WxWidgets

May 7, 2013

When using wxWidgets, i am tempted to deallocate memory using delete in the destructor, but my program crashes on closing. I try to do something like this:

class mainwnd:public wxFrame{
public:
mainwnd():wxFrame(NULL,wxID_ANY,wxT("test")){
menubar=new wxMenuBar;

[Code] .....

tell me why? and is it done automatically?

View 3 Replies View Related

C++ :: Move Mouse Pointer Automatically?

Mar 26, 2012

How do I tell c++ to move the mouse in place x?

for example, I run a c++ program and the mouse moves to the top left corner of my screen.

How do I go about doing something like that?

View 2 Replies View Related

C++ :: How To Move Object From Right To Left Automatically And Opposite

Apr 13, 2014

I'm using Visual C++ 2010 and SFML game library. I want to know how to move an object from right to left automatically and back left to right??

View 2 Replies View Related

C++ :: Pointers To Automatically Null When Object Is Deleted

May 18, 2013

Say I have an object and 10 pointers to it in several other objects of varying class types. if the object gets deleted, those pointers have to be set to null. normally I would interconnect the object's class with the classes which have pointers to it so that it can notify them it is being deleted, and they can set their pointers to null. but this also has the burden that the classes must also notify the object when THEY are deleted since the object will need a pointer to them as well. That way the object doesn't call dereference a dangling pointer when it destructs and attempts to notify the others.

Auto pointers and shared pointers are not what I'm looking for - auto pointers delete their object when they destruct, and shared pointers do the same when no more shared pointers are pointing to it. What I'm looking for is a slick method for setting all pointers to an object to null when the object destructs.

View 1 Replies View Related

C++ :: Increasing Integers Automatically Within Two Dimensional Array

Nov 15, 2013

I am new to programming all together but i have been writing a program in c++ and im coming up against an issue with my array.

#include<iostream>
#include<iomanip>
#include<string>
using namespace
int main () {
int a ;
int b ;
char answer ('Y') ;

[Code] ....

I am trying to get the program to increase say year one by 1 when the condition is met i have tried

if ( a >= 70 && a <= 100 && b == 1)
{grade [0][0] = 0 + 1;}

and

for (grade[0][0] = 0 ; a >= 70 && a <= 100 && b == 1 ; grade [0][0]++)
{grade [0][0]= 0 + 1 ;}

Now all that i want is that the array will take the information from int a and int b and then add 1 to the appropriate part of the array . I have tried putting it in deferent places but its not working for ether. the program will run but it will not add to the array.

View 13 Replies View Related







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