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


ADVERTISEMENT

C :: Creating A Library Function

Jan 27, 2015

I want to create a C library function that i can directly call in my code from any .c file having main program.following are codes...code of library function "foo.c"

Code:

#include "foo.h"
int foo(int x) /* Function definition */ {
return x + 5;
} header file "foo.h"

Code:

#ifndef FOO_H_ /* Include guard */
#define FOO_H_
int foo(int x); /* An example function declaration */
}

[code]....

to use this i have to compile the file in below manner...

Code: gcc -o my_app main.c foo.c

My concern here is that i want to compile the main.c and use function without compiling foo.c with i.e.

Code: gcc -o my_app main.c

any user of this function should only compile his program and should be able to use the function, the foo.c file should remain hidden from him

my system is Linux 2.6.18-308.4.1.el5 #1 SMP Wed Mar 28 01:54:56 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

View 9 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++ :: 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# :: 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

Visual C++ :: Creating DLL From Program

Jan 15, 2013

I wanna create a DLL from my C++ program. My output of my C++ program is a text file called Centre_Cartouche.txt My output is two text files called brd.txt and sym.txt

At the beginning my program was just a main which contains all development (Main.cpp). Now I created function (in _Cartouche.h and _Cartouche.cpp).

My debugger tell me that the simulation works. But my file Centre_Cartouche.txt is not create.

_Cartouche.cpp_Cartou.hbrd.txtsym.txt

View 1 Replies View Related

Visual C++ :: Creating DLL That Will Be Used As Plugin In External Program Using MFC

Jan 30, 2013

This is the problem in detail:

I have a VC++ project to create a DLL that will be used as a Plug-in in an external programm. This DLL uses some MFC functions. The initial configuration of the project was:

-Use of MFC: Use MFC in a Static Library

-Common Language Runtime support: No Common Language Runtime support

-Runtime Library: Multi-threaded Debug (/MTd)

This configuration worked fine, there were no compilation errors and the resulting DLL worked correctly.

The problem came when it was necessary to add to the DLL some functions of .NET, using the namespace System and similar. To do that, I had to change the Common Language Runtime support, to Common Language Runtime Support (/clr). Then, when I tried to compile, I got this message:

'/MTd' and '/clr' command-line options are incompatible

So I changed the Runtime Library to Multi-threaded Debug DLL (/MDd). Then I got this error message:

Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version

So I also changed the Use of MFC to Use MFC in a Shared DLL.

After this, the compilation was correct. Then logically the size of the generated DLL is smaller, but this new DLL does not work correctly, the external program in which this DLL is used crashes.

I don't know what to do to fix the problem. Maybe I need to add some other DLLs or files to the directory where the DLL is located, where the external program uses it. But I would prefer to include a single DLL file, but this seems to be incompatible with the use of .NET functionality.

View 11 Replies View Related

Visual C++ :: Implementing Classes And Creating Driver Function?

Nov 30, 2012

I'm am having a few issues with this program, they stem from passing the color.h and .cpp into another .h and .cpp, and frankly getting how those two things really fit together.

For this problem, you will design and implement 2 classes and then write a driver function to test these classes. The first will be a C++ class for an abstract data type color with a public enumeration type colorType that has the color values shown in Listing 10.8. Your abstract data type should have an attribute for storing a single value of type colortype and member functions for reading (readColor) and writing (writeColor) a color value as well as setting and accessing it. The function readColor should read a color as a string and store the corresponding color value in the value attribute of a type color object. The function writeColor should display as a string the value stored in the value attribute of a type color object (see Figure 7.5). Modify class circle and the driver function in Listing 10.9 to include and use this class. You'll need to remove the declaration for color in class circle. Test your modified driver function with the new color and circle classes.

The second class will be to design and implement a rectangle class similar to class circle. Be sure to incorporate the new color class you have written and tested in the first part of the programming exercise. Write a client program that asks the user to enter a shape name (circle or rectangle) and then asks the user for the necessary data for an object of that class. The program should create the object and display all its attributes.

The circle class .h and .cpp files as well as the original driver function will be supplied. You are to provide the .h and .cpp files for the new color class and the modified driver function as well as the .h and .cpp files for the rectangle class and the client program that uses all three classes.

color.h

Code:

//color.h
//Color class definition
#include "stdafx.h"
#ifndef COLOR_H

[Code].....

View 3 Replies View Related

Visual C++ :: Creating A Function That Needs To Determine Perfect Scores

Jun 24, 2013

This program is incomplete as I am having difficulty creating the function that needs to find the number of perfect scores entered by the user. I have everything but the function complete ,here is my code:

Code:
// Write a modular program that accepts at least 10 integer test scores from the user and stores them in an array.
// The main should display how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function.
// Input validation: Do not accept scores less than 0 or greater than 100.

#include <iostream>
using namespace std;
int countPerfect(int intArray[], int); // Function prototype

[Code] ....

View 14 Replies View Related

Visual C++ :: Dice Game - Creating Pass By Value Function Reference

Nov 27, 2014

i have a project where i create a dice game, the user rolls 2 dice and the computer roles 2 dice. the player that wins 3 out of 5 rolls wins the game. I have completed the requirements, but i wanted to create a pass by value function for "void Dice()", I'm not too sure how that works?

Code:

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
//creating my variables and their values
int compinput;

[Code] .....

View 5 Replies View Related

C++ :: Make Visual Studios Step Into A Function?

May 2, 2013

if there is a way to make Visual Studios step into a function while I am debugging.. I am trying to see the value of a certain int and making sure it is what I need it to be.. but whenever I use step into visual studios just skips right over the function and it does all the calculations..

View 4 Replies View Related

Visual C++ :: How To Make A Shape Outside Of Main Function

Sep 9, 2014

I know how to define a shape (here, a rectangle) and attach it to a window in C++ as follows:

Code:
#include <Simple_window.h>
void cir() { Circle c(Point(100,100),50); }
int main() {
Simple_window win(Point(100,100),600,400, "test");

[Code] ....

But how to define a shape (say a circle by that cir() function which is) outside of the main() function that is how to create a circle inside of the cir() function and it returns that circle when I called it in my main() function so that I can attach it on the window win to be visible?

View 14 Replies View Related

Visual C++ :: Cross Platform Program - Make A Note Of Value Of PA

Nov 4, 2013

I'm working on a project which uses gtk+ and gtkmm. We use them in preference to MFC because the program needs to be cross-platform. For quite a long time, customers on OS-X and Linux have sometimes complained that the program would crash during shutdown but the Windows version (which I work on) never seemed to suffer. However, I'm now transferring my build environment to a new PC and I'm noticing the same shutdown crashes. It's a bit complicated so let me start with a small example:-

Code:
namespace Whatever {
class B {
public:
virtual ~B();
private:
int bb;

[Code] ....

Suppose I run the above program. When it stops at breakpoint #1 I make a note of the value of pA. Eventually the program reaches breakpoints #2 and #3. At each point my this pointer is exactly the same number. If the value of pA was 0x03604fb0, my this pointer is identical at both stages.

Now let's consider the real example:-

Code:
namespace Gtk {
class Widget {
public:
virtual ~Widget() {}

[Code] .....

Suppose I run the real example. At breakpoint #1 the value of pW is 0x03604fb0. But by the time I reach breakpoint #2 my this point is slightly different:- 0x03604fcc. It doesn't seem right to me and I'm wondering if it might be contributing to our shutdown crashes.

View 6 Replies View Related

C++ :: Make Colors Transparent Using 3rd Party Library

Jan 19, 2014

I'm trying to make colors transparent in c++ using a 3rd party library. I've successful made my background transparent but I feel I'm cheating by not understanding how I entered the value.

"0xff, 0xff, 0xff" is the color white but i'm not sure how it's the color white like with RGB values.

View 5 Replies View Related

C/C++ :: Program To Make CMD Stop Without Using Getch Function

Mar 30, 2013

Program in c++ that if i ran it the cmd window will stop without using getch statement and conio.h header file, or how ?

View 7 Replies View Related

Visual C++ :: Reverse Sentence - How To Make Program Non Case-sensitive Using Vectors

May 25, 2014

I had been tasked to create a program that reverses a word i.e.

cat
tac

How to make my program non case-sensitive using vectors?

Code:
// BackWardsSentence.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
string BackWords (string sentence);
int BackSentence (string sentence);
string BackWords1 (string sentence);

[Code] .....

View 2 Replies View Related

C++ :: Formatting Iostream For Readable Hex

Feb 22, 2015

My problem is that the setfill('0') doesn't affect the output; I want four columns of 64bit numbers in hex which I read in binary mode from a file.

Here is the problem:

fffffff2 f1040000 fff10000 780000
76000d 11740000 0 5f
5f40405f 50636853 796d5f40 30304055
66687669 68556867 76657655 776c7866

and the code to produce it:

cout << hex << setw(4) << setfill('0') ;
unsigned long test,inc,grp;
grp = 0;
for (int i = 0; i < size; i += 4){
test = buffer[i];

[Code] .....

View 6 Replies View Related

C++ :: Cout And Cin Objects Of Iostream Class

Feb 17, 2013

i ran the following code in the latest version of code::blocks and it tells me that the objects cout and cin are not declared in this scope. what is the problem?

I used to use Turbo C++ 3.0 and i had no problem whatsoever with that compiler. But now i am trying to move to code::blocks but it is proving very very hard as all the standards have been changed.

I am a school student and thus, we had been told to practice on Turbo C++ 3.0 and now i am unable to unlearn it. Also, if i use printf in place of cout there is no error but i want to use cout as it is what i am comfortable working with.

#include<fstream>
#include<conio.h>
int main() {
using namespace std;
char name[20];

[Code] ....

Is there some document to which i can refer so as to get the latest C++ standards which is C++0x i believe?

View 7 Replies View Related

C++ :: Creating A Class To Make WinHttp Requests Easier

Apr 11, 2014

I'm using Visual C++ 2010 Express on Windows 8. What I want to do at the moment, is to create a class to make WinHttp requests easier. This is the code that I'm basically using to build the class: [URL] ....

This is what I got so far. (Completely untested). Example of how I hope that it will work:

HttpRequest MyRequest;
MyRequest.Initialize("Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0","","");
htmlCode = MyRequest.SendRequest("www.cplusplus.com","GET","");
cout << htmlCode << endl;

The code:

#include "stdafx.h"
#include <windows.h>
#include <winhttp.h>
#pragma comment(lib, "winhttp.lib")
class HttpRequest {

[Code] ......

View 6 Replies View Related

C/C++ :: Fatal Error - Iostream / No Such File Or Directory

Aug 4, 2014

I keep running into this error, even though the first few times i built and ran something it worked perfectly, and since I'm new to CodeBlocks (or any IDE/Compiler for that matter) what to do.Any code i put in, it'll give me this error....

View 3 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++ :: Using A Library Function?

May 9, 2013

I have been trying to find a way around the following:

I am using a library functor to solve the root of a non linear equation. It passes two doubles and the name of a function that contains the equation to be solved.

Its xtor and operator are

RootFind(double tL,double tR,double (*fn)(double t));

void operator()(double tL,doubleR,double (*fn)(double t));

I want to be able to send another variable to function fn; I don't know what the value of the variable will be ahead of time.

How do I get the library functor to take an extra variable in the function passed?

View 1 Replies View Related

Visual C++ :: Compiling Matrox Imaging Library

Mar 1, 2013

Has compiled Matrox Imaging Library using Visual Studio 2010. I have downloaded MIL and trying to compile a simple program in the installed directory called 'msimple.cpp', but getting the following error:

1>------ Build started: Project: msimple, Configuration: Debug x64 ------
1>msimple.obj : error LNK2001: unresolved external symbol _fltused

1>LINK : error LNK2001: unresolved external symbol wmainCRTStartup

[Code] .....

View 4 Replies View Related

Visual C++ :: CString Class In Non-MFC Static Library

Sep 13, 2013

I have a non-MFC static library which I share between a number of different projects, some non-MFC and some MFC. Currently the static library uses a typedef of std::wstring and std::string for UNICODE and non-UNICODE builds.

After discovering it's possible to use CString in non-MFC applications, by including atlstr.h header, I decided I'd rather that than using stl strings and having to keep converting between the different types. However, I seem to be struggling with linker errors when linking the library with a MFC application.

Can I create a non-MFC static library using CString from atlstr.h and link it with a MFC application?

View 11 Replies View Related

Visual C++ :: Custom Control Library Design?

Mar 15, 2015

i want to design a custom control (Ui widget library) , this library can be used by any IDe developer to develop his UI.

how to design a custom control library and plug in.

View 11 Replies View Related







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