C++ :: Trigonometry Programming - Solving Triangle By Using Cosine And Sine Law

Jun 3, 2013

I am writing a program to solve a triangle. Given any three pieces of information, find the other three. I am having trouble with SSA. I use the cosine law to find the unknown side. Then I use the sine law to find the other two angles. The sine law will give me each of the other angles. If one of the unknown angles is over 90 degrees, my program gives an angle as under 90 degrees. Not surprisingly, the correct angle and my wrong angle add up to 180 degrees. If you draw out the triangle you can deduce the right answer. How to have my program find out when the angle needs to be over 90 degrees.

View 5 Replies


ADVERTISEMENT

Visual C++ :: Make Transition From Console Programming To GUI Programming?

Nov 30, 2013

my a book or website where I can make a transition from console programming to GUI programming. I'm totally confused about this. I know how to program in console and can make a whole program based on console. I also know the OPP programming, but it's clear that nobody uses console programming anymore.

View 10 Replies View Related

C++ :: Anagram Solver Not Solving All Words

Dec 17, 2013

I'm working on an anagram solver, and started with words 3 characters big. But it can solve some words and not others.

std::string str = "enp";
std::string match = "";
int chk = 0;

[Code].....

With the string "enp", it knows it matches "pen". But if I use "mum", it doesn't match it with "mum".

Is there something flawed with my algroithm?

View 4 Replies View Related

C++ :: Solving Linear System Of Equations Using Threads

Dec 14, 2014

I am trying to write a code that solves a system of linear equations such as A*B=C. My system has a dimension equal to 1600. The matrix A cab be separated into 4 sub matrices and each can be handled by a different thread. I tried to solve this using the following code:

int main() {
int count = 0;
//Inputing matrix A
ifstream matrix;
matrix.open("example.txt");

[Code] ....

Although the above code gives the correct answer, the time needs to find the solution is bigger than that needed without using threads.

View 1 Replies View Related

Visual C++ :: Solving Factorials - Large Numbers?

Nov 21, 2013

If i m writing a code for a program to solve factorials, what is the best approach if i have large numbers in mind?

If i use int, i can only go upto 4bytes and if i use double i can go upto 8bytes. so should i create new type or is there any other way to get this done.

View 14 Replies View Related

C++ :: How To Calculate X And Y In Sine Wave

Apr 24, 2012

I have the following initial code:

Code:
double objectAngle = -90.0f;
double objectSpeed = 3.0f; // meters per second
double objectDistance = 300.0f;
double objectTime = 0.0f;
double objectHeading = 90.0f;
double elapsedTimePerCycle = 1.0f;

My coordinate system looks like this:

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

I want to calculate a new x,y such that it follows a sine wave like pattern until it gets to point (0,0). I want the width of the arc to go out to about -45 degrees, and the same on the other side to about -135 degrees.

How can I compute these new x,y coordinates in C++?

View 14 Replies View Related

C++ :: Sine Wave Movement With The Saucer

May 4, 2014

I am currently working on an arcade game for my final assignment this year. I am struggling to get a sine wave movement with the saucer. Here is the code for it:

void ArcadeGame::spawnSaucer() {
Texture* pTexture = getTexture("saucertexture");
m_pSaucer = new GameObject(pTexture, "saucer");
m_pSaucer -> setPosition(1000, 300);
m_pSaucer -> setVelocity(-1, 10 * sin(1 * 3 * PI / 180), sin(1) * OBJECT_DEFAULT_SPEED);
addGameObject(m_pSaucer);
m_pSaucer->setSolid(true);
}

View 8 Replies View Related

C++ :: How To Create Multiple Sine Waves

Apr 21, 2014

#include <cstdlib>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include "dp_lib.h"
int main() {
int A =1;

[Code]...

im new to coding but ive written this code for an assignment and it creates 2 sine waves and adds them together but i want to be able to create a range of different sine waves at different frequencies and play them one after the other like in my code,but with the end result being that i would like each sine wave to represent a different note, so when your on the the console screen the user will be able to choose from a select number of notes and input them in any order so that the WAV file produced plays the sine waves in the order the user chooses so they can make a simple tune. but my code only plays it in the order it is in the code

View 8 Replies View Related

C++ :: Calculator Program - How To Do Sine Calculation

Apr 26, 2013

I am basically trying to make a program for a calculator. I am struggling with how to do the sine calculation. this calculation will take place at line 158.

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

double firstNumber = 0.0;
double secondNumber = 0.0;
char operation =' ';

[Code] ....

View 1 Replies View Related

C/C++ :: Creating Multiple Sine Waves

Apr 18, 2014

#include <cstdlib>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include "dp_lib.h"
int main() {
int A =1;
float* data;

[Code] ...

I am doing ive written this code that creates 2 sine waves and adds them together but my question is that im trying to write a code where i can create multiple sine waves assign each sine wave to a separate values (musical notes ie A B C) and then be able to add them together in any order to create a tune.

View 2 Replies View Related

C# :: Can't Get Math (Sine) Function To Work

May 21, 2014

I'm having trouble with getting a sine function to work. All variables are defined earlier in the same section. I have the code in a button (where I figured it would go) but I get the following error:

WindowsFormsApplication2.Math does not contain a definition for 'Sin'

For reference, I am using Microsoft Visual Studio Express 2013, and am coding a Windows Forms Application.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

[Code] ....

I've tried other functions as well (abs, sqrt, etc.) to no avail, as Math only seems to pop up with two options: Equals and ReferenceEquals.

View 2 Replies View Related

C/C++ :: Approximate Sine Function With Taylor Series

Dec 22, 2014

Write a C program with a separate function which calculates the sine function from the first principles according to the formula below. The code should find the sine value in 5 stages and then final answer

formula below :

sin(x) = x −x3/3!+x5/5!−x7/7!+x9/9!

I have done the code and it just gives me a final sine wave

it should find a error then plus one so on till it gets the answer

Link:

These are images of what it should look like and the image of a the formula ....

View 7 Replies View Related

C/C++ :: Sine Wave - Printing Files To Excel

Mar 7, 2014

I need to create a sinewave. I have the values in an Excel file. The code reads the excel file and prints the values in the cmd but I need it to print back into excel as a sine wave. Pretty sure its currently values for a triangle wave but whatever I want a wave before I care about the type.

Description: Creates an array of values of a triangle wave, prints the result to the screen and creates a CSV (comma separated variable) file of data points. Allows user to enter number of amplitude and number of cycles

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define N_SAMPLES 1000 // crashes if array size > 1000?
#define UP 1
#define DOWN 0

[Code] ....

View 11 Replies View Related

Visual C++ :: Creating Program To Make Sine Function Without Any Library Other Than Iostream?

Nov 10, 2012

My assignment is to create a C++ Program to find the sine of a number without any library other than iostream by using Taylor Series:

sin (x) = (x/1!) - (x^3/3!) + (x^5/5!) - (x^7/7!) + (x^9/9!) ...... (x^n/n!).

Here is what i have done till now:

#include <iostream>
double fact (int f); //declaration of factorial function
double power(double x, int y); //declaration of power function
double sin(int x); //declaration of sine function
//double cos(int x); //declaration of cosine function
//double tan(int x); //declaration of tangent function

[code]....

View 3 Replies View Related

C :: UDO Socket Programming

Dec 18, 2014

I am trying to test my client-server socket program wherein the client connects to the server,client sends a message, server receives it and echo back to the client.So far, in the program server receives the message from the client, prints it BUT when it tries to send the message back to the client it shows an error.

sendto(): Invalid argument.I am new to socket programming.

Code:

//Server
#include<stdio.h> //printf
#include<string.h> //memset
#include<stdlib.h> //exit(0)
#include<netinet/in.h>
#include<sys/socket.h>
#define BUFLEN 512 //Max length of buffer
#define PORT 10003 //The port on which to listen for incoming data
}

[code]....

View 3 Replies View Related

C :: Parallel Port Programming - On / Off LED

Sep 9, 2014

I try to ON and OFF the LED's via parallel port. I connect the cathode of LED's with pin number 18 that is ground and anode of each LED is connected through a 1K resistor to pin 2 to 8. I write the following programe

Code:
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#define PORTID 0x378
void main(){
outportb(PORTID,0x00);
getch()
}

But when i connect the LEDS to the parallel port all the LEDS are LIT while i also change the 0x00 to 0xff and so on. But no effect on the LED's.

View 8 Replies View Related

C :: How To Check Dates In Programming

Mar 6, 2015

I'm supposed to make a program that can tell which date, out of any number of dates entered by the user, is the earliest date. However, this is based off another program that I did not do in the last chapter. Since it's a pretty simple program to use as the base for the more "generalized" one, I decided to make the more basic one that can only take two dates, first. If it was just one integer, I could just use date1 for the first date and date2 for the second date, but each date uses 6-8 separate numbers.

how do I tell it something like, "if(date1 < date2)", with date1 and date2 including their month, day, and year. I could do a separate integer name/tag (I forgot what they're called) for each number, but that sounds like doing a lot more adding and subtracting, and like it could easily get messy.Should I, or can I, add all the numbers under the "date" together to see which date has the "lowest number" or "earliest date", or should I somehow handle each number, that is month, day, and year, separately?Here's the code so far:

Code:

include <stdio.h>int main(void)
{
int date1, date2;
printf("Enter first date (mm/dd/yy):
");
scanf("%d/%d/%d", &date1);
printf("Enter second date (mm/dd/yy):
}

[code]....

View 10 Replies View Related

C :: Socket Programming Getting Segfault

May 22, 2013

I am trying to send a packet across a client/server communication. I am getting a seg fault (while running the program(It compiles fine)) when I try to read the neighbor file, You should be able to see this below the comment /***** Read neighbor file***/ :

Code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
}

[code]....

View 2 Replies View Related

C++ :: Modular Programming With Template

May 16, 2014

I'm trying to create a stack of generic variable with template. This is the code.

BlockingStack.h
#include "stdafx.h"
#pragma once
template <class T>
class BlockingStack {
[Code] .....

I don't understand why ,but it dont work... It produce this errors:

1>Blocking_stack.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall BlockingStack<int>::BlockingStack<int>(int)" (??0?$BlockingStack@H@@QAE@H@Z) non risolto nella funzione _wmain
1>Blocking_stack.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall

[Code] ....

View 4 Replies View Related

C++ :: Can Be Used For Server Side Programming

Nov 28, 2013

I know this question must have been asked before, but the problem that I am facing is that I am using a library PoDoFo to parse PDF files. It seems that it is only compatible with C++.

Now I want the application to be web-based. That is, the user uploads a PDF file on the server, the server parses it and the parsed content is then sent back to the user.

Is such a thing possible with C++, or maybe any good work-arounds? Or should I look at server-side scripting languages like PHP and their respective libraries?

View 8 Replies View Related

C/C++ :: Programming Variable Name Rules?

Nov 13, 2014

Where are the c programming variable name rules defined? I usually use these two websites for figuring out these kind of things but I don't see it anywhere.

[URL]

View 4 Replies View Related

C :: Programming - Using Strlen With Text File

Oct 13, 2014

I am trying to read all the 9 letter words in a words list text file and print them to the screen. Here is the code I have so far, but I am currently printing nothing.

Code:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{

[Code]....

View 7 Replies View Related

C :: Make Alphabet Soup On Programming

Mar 19, 2014

I'm trying to make an alphabet soup on C programming, and I'm stuck with a problem.I need to make a function able to automatically find all the words that exist in alphabet soup.

View 4 Replies View Related

C :: Circuit Diagram - Programming A Timer

Jan 29, 2014

I have attached a circuit diagram below, which has been tested. Currently you have to manually push the switch to change the brightness of the bulbs. I want to program a chip to automate this.

Over 90 days the chip will output a high signal in replace of the switch every set period of time (say once every 1.5days). I can use any chip but the smaller the better!

View 1 Replies View Related

C :: Socket Programming And Console Control

Jan 4, 2014

I would like to make a program for final project, which can let me send any file to my computer at home, and i can access any files in my computer when i am not at home.sending and getting file will be with socket programming.

i would like to reach all folders in computer, not only the folder, where client program exist. how can i access other folders at remote computer by using my program?

View 4 Replies View Related

C :: Array Getting Lost Probably Fundamentals Of Programming

Sep 7, 2014

why an array would lose its contents when I believe it shouldn't. Below is a skeleton program just to kind of show what seems to be happening. Basically I set up the delims array with just a star. The program runs a good number of times but at some point the delims array gets lost. My guess is the stack is overflowing or something? But it "appears" all other variables are ok (although I cant be sure).

I move the char delims into the while loop. What is this "actually" doing to the original delims variable ... are we wasting memory here (bearing in mind the original delims variable is sometimes loosing the string :/)

Code:

somefunction()
{
char delims[] = "*" ;
char *result = NULL ;
while (1)
}

[code]...

View 6 Replies View Related







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