C++ :: Create A Program With Trigonometric Series

Mar 30, 2014

create a program that trigonometric series βˆ‘(k-3)sin(Ο€/k-3) with k = 4 until 13..

View 1 Replies


ADVERTISEMENT

C++ :: Program To Get Sum Of Series

Feb 26, 2013

Why isn't this program working?

#include<iostream.h>
#include<conio.h>
void main() {
clrscr();
int n;
float x, t, sum=0;

[Code] ......

View 15 Replies View Related

C/C++ :: Program To Find Arctan(x) Using Taylor Series?

Mar 10, 2015

I need to be able to test this algorithm 50 times including extremes and invalid inputs.

I keep getting invalid input

#include <stdio.h>
#include <math.h>
void main() {
double x, i, y, z;
int N, n;
printf("Enter limit polynomial N

[code]....

View 3 Replies View Related

C++ :: Parsing String To Recognize Trigonometric Functions

Sep 14, 2014

How do I create a function that can understand trigonometric functions?

Examples:

if I am to input: x^2 + sin(x)

The program will understand the the value between parenthesis preceded by a string "sin" will be computed as the sine of x. of any function in case.

I have the program here.

#include <iostream>
#include <cstdlib>
#include <cctype>
#include <cstring>
using namespace std;
enum types { DELIMITER = 1, VARIABLE, NUMBER }; //DEL = 1; VAR = 2; NUM = 3.
class analyzer {

[Code] .....

View 9 Replies View Related

C :: Program To Get Series Of Integers From A User And Storing Those Values Into Array

Feb 10, 2013

The problem deals with writing a program to geta series of integers from a user and storing those values into an array. Then use a function called selection_sort, when given an array with n elements, the function must sort the array from smallest to largest values.

I have code, and im trying to get it to compile but im getting these implicit declaration errors and conflicting types. Here is my code and the compiler errors.

Code:
Compilation started at Sun Feb 10 20:14:48

gcc -Wall -o ex9-1 ex9-1.c
ex9-1.c: In function 'main':
ex9-1.c:16:5: warning: implicit declaration of function 'selection_sort' [-Wimplicit-function-declaration]
ex9-1.c:20:2: warning: implicit declaration of function 'prinf' [-Wimplicit-function-declaration]
ex9-1.c: At top level:

[Code] ...

Compilation exited abnormally with code 1 at Sun Feb 10 20:14:49

Code:
#include <stdio.h>
int main(void) {
int a[100], i, j, N;
printf("How many numbers will you be entering: ");
scanf("%d", &N);

[Code] .....

View 4 Replies View Related

C++ :: Program To Read Series Of Comma Delimited Values From A File Into Vector

Aug 12, 2012

I'm trying to get my program to read a series of comma delimited values from a file into a vector. However, I am unsure how to actually go about doing this. I've posted my best guess below but it's really just a stab in the dark and I always receive a compiler error.

Code:

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
vector <string> v_input;
int main() {
ofstream fout ("Insert File Path Here.txt");
fout << "4, 8, 15, 16, 23, 42";

[Code] ....

View 3 Replies View Related

C++ :: Calculate Angle Value In Form Of Trigonometric Functions - Loops And Void

Jul 24, 2013

This is an assignment which the purpose is to calculate an angle value in form of trigonometric functions. These are the codes that I've wrote so far.

#include <iostream>
#include <cstdlib>
using namespace std;
void menu(double &value) {
system("cls");
cout<<"*****Trigonometry Program*****"<<endl;

[Code] ....

I have completed the codes for the interface part. Before I proceed with the formula for the trigonometric functions, I would like to make sure the program is Error-free, which if there is accidental invalid input from the user, the program would the user to enter another input until it is a valid response.

The only problem I have encountered for this matter was in menu(value)

If I enter an integer, the program will proceed without error. However, If I enter a character, the program will slip into an endless loop which constantly shows this

*****Trigonometry Program*****
Please enter an angle value => Is the angle in Degree or Radian?
Type D if it is in Degree
Type R if it is in Radian
Your response=> 0 //my initial input for value

Do you want to continue?
Type Y to continue
Type any other key to stop
Your response =>

Where is the source of the problem? I'm pretty sure it's the loop, but I don't know what to do.

View 2 Replies View Related

C++ :: Menu Program Broken Down Into Series Of Calls To Function For Each Of Menu Items

Aug 19, 2013

I am trying to write a menu program that will be broken down into a series of calls to function for each of the menu items. Two of the menu items will be simple programs which I wrote.

I want two of the functions to run one of the two programs I am trying to include as items in the menu.

So far I am only familiar with variables, loops, if statements, and I just learned how to write functions.

The problem I am have is that I don't quite understand how to write a function that will run one of the two programs. Also I am having a hard time writing the program in away that would allow the user to select the menu items.

View 2 Replies View Related

C++ :: Loop With Taylor Series

Feb 25, 2015

Write a function that computes the Taylor series expansion of ex using the following formula, where x is the exponent, and n is the number of discrete trials to run:
𝑒π‘₯=1+π‘₯+π‘₯2+π‘₯3+π‘₯4+β‹―+π‘₯𝑛 =βˆ‘π‘› π‘₯𝑖 2! 3! 4! 𝑛! 𝑖=0 𝑖!
NOTE: This formula will NOT work if you calculate the numerator and denominator separately and then add the division result. You must use your knowledge of algebra to make sure you’re not calculating the entire exponent and factorial, but rather their factors per loop iteration.

Input prompt
Enter the values for x and n:
Output Prompt
Taylor series estimation is XXXX.XXXX

This is what I have so far for the function:

void getTaylor() {
double estimation
cout << "Enter the values for x and n:" << endl;
cin >> x >> n;
cout << "Taylor series estimation is" <<
}

I now need to create the loop so that I can enter in for my function.

View 2 Replies View Related

C# :: Approximating Value Of Pi Using Leibniz Series

Oct 1, 2014

Write a program that approximates the value of Ο€ using the Leibniz series and compares the Leibniz series approximation against the known value of Ο€ and two other common approximations of Ο€ (22/7 and 355/113). The program must prompt the user for the desired number of terms (n) to use in the approximation (as an integer) and calculate the approximate value of Ο€ to the given number of terms. The program must display each approximation of Ο€ and display the difference between each approximation.

I understand how to prompt for the number, what I don't even get how to start is to use it to approximate the value of pie in that given number. Also how to tell the difference between each approximation...

View 1 Replies View Related

C/C++ :: Pi Approximation With Fibonacci Series?

Oct 11, 2014

I can't seem to get the math portion right. It is supposed to approximate pi using (sigma,i=-1 to infinity)(-1)^(i+1)(4/(2i-1))=4(terms of pi). And what I have does some math but it is incorrect because I get a negative value for pi and one that is entirely too large at that. The precision is also to be at 20 decimal places. I also need it to end immediately after if I get an invalid input, but I can't seem to get it to end after trying a few different things it will say that it is an invalid number, but will continue to run the math loop. I also need the final cout to print all the terms that is multiplied by 4.

[code]#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
int nterm, numerator;
double sum = 0.0;
const int upperBound = nterm * 2;
cout<<"This program approximates pi using an n-term series expansion. "<<endl;

[code]....

View 11 Replies View Related

Visual C++ :: Calculate PI Value Using Series

Mar 3, 2013

in code my prompt said :

(computing Ξ  (PI) ) You can approximate (PI) value by using the following

series:
Ξ  = 4( 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ... - 1/(2i -1) + 1/(2i + 1)

Write a method that calculate value of Ο€ by using the above series, using

the following header:
public static double pi()
assume i = 1000000

ok so I have been testing it but I really did get any far :

for ( double i = 1; i< 1000000; i+=2) {

// with these I try to increment the value of i to get to the series. I did these after and test it and the output is all wrong and I know it

sum = (1/((2*i)+1));
sum = sum + (1/((2*i)-1));
sum ++;
double pi = 4*(sum);

// I know is wrong I but I can't figure it out what to do.

View 6 Replies View Related

C :: How To Create A Program That Take AVI File

Jan 26, 2015

I want to create a program that would take an AVI file, alter each frame (ex: change contrast, invert colors, etc.) and dump a new AVI. I've wrote a simple program for this experiment that loads up the header information from the video and dumps it. It also dumps a list of the frame data chunks within the 'movi' chunk.

The info I've gathered from coding this:

1. The recommended buffer size for each type of stream (vids, auds, etc.) is the size of the largest frame of corresponding type, plus 1 or two extra bytes.

2. numFrames in main header is the total number of frames for all types of data (video,audio,etc.) The 'length' value within stream header of type 'vids' is the number of video frames. The sizeImage value within BITMAPINFOHEADER is 921600 (==640*480*3) and the specification states that, quoth, "This can be set to 0 for uncompressed RGB bitmaps."

3. This video uses DIVX encoding.

Now my problem is this: How do I get the data within each video frame in a simple BMP like format? Even the uncompressed frames (with chunk id 'nndb') have variable sizes...let alone the compressed ones.

Information about a software that converts AVIs to a format with fixed sized uncompressed frames. Or at least some information about the frame decompression techniques.

Here's a dump made by the program for a 9 sec, 640x480 video I recorded from Pokemon. (Without the frame dump that is, it'd have made the post too long.)

Code:

AviMainHeader
-------------
size = 56
usecPerFrame = 66666
maxBytesPerSec = 7680000
padSize = 0
flags = 0x00000810
numFrames = 162
initialFrames = 0
numStreams = 2

[Code]...

View 4 Replies View Related

C :: Create A Menu With Program

Oct 29, 2014

So, I was trying to code a menu for a personal movie database. But I'm having some problems.So, this is what I did,

Code:
#include<stdio.h>
int main();
{
do
{printf("Menu

[Code]...

But this is not working.Furthermore I would also like add a sub menu.

View 7 Replies View Related

C :: Program To Create 2D Array For Each Row

Feb 14, 2013

What I am trying to do is to have the program create 2D array that for each row, no two numbers are the same and only consists numbers between 1-9. The array lists out every possible combinations. Supposely I do not know the number of possible combinations, I had it keep adding new rows until there are no more possiblities left.

The problem with my code is when I print out the completed array, it gives out really, really large numbers. But when I print the array from inside the first loop, it gives correct values. I do not know exactly what happened.

Code:
#include <stdio.h>
int main(void) {
int double_digit[1][2];

int a = 1;
int b = 1;

[Code] ....

View 5 Replies View Related

C :: Algorithm To Find Kth Term Of A Series

Dec 8, 2014

I want to write an algorithm to find the kth term of a series given by the following recursive formula:

a_0=1 and a_(k+1)=a_k+1/k!

My code (part of it responsible for calculating the value of a series) does not want to compile:

Code:

float series(int n)
{
float F0 = 1;
float F;
unsigned int i;
if (n == 0)
return(1);

[Code]...

thus my question is why it does not want to work properly and what should i change (for certain factorial function is OK)?

View 7 Replies View Related

C/C++ :: Print Series Of Text From Loop

Sep 29, 2014

I'm attempting to print a series of text from this loop, but for some reason all I am getting is the sum total and the number 1, like this

1 5175.11

When I want to get it for each iteration of the loop. I've cycled over this and compared it to my other loops I've used and I'm lost as to why this isn't working. I also tried using a do while but that didn't work as well.

for (double total1 = 0; total1 < goal; total1 + save_amt) {
total2 = ((factor - one) * save_amt);
total3 = (total2 / fr_interest);
total1 = total1 + total3;
months_dis = (months_dis + one);
cout << months_dis << " " << total1 << endl;
}

View 14 Replies View Related

C++ :: Lowest And Highest Number Of A Series?

Feb 26, 2013

I'm having trouble, I want the inner loop to display the lowest and highest score. If I assign initial values for the high and low score, it won't always work (because if no/ all scores are above/ below my initial values...)

But without assigning initial values for highscore and lowscore, One of them will always be undefined during the first runthrough.

#include <iostream>
using namespace std;
const int AGRADE = 90;
const int BGRADE = 80;
const int CGRADE = 70;
const int DGRADE = 60;
int main() {

[code]....

how do i set this up so it stores a low and high score, and then compares those to each next number in the series?

View 6 Replies View Related

C :: How To Create A Program That Not Allow Negative Numbers

Sep 2, 2013

I have a homework assignment due that told me for the "input specification" that "n" is an integer greater then 0. How would I put this in and where?

View 1 Replies View Related

C :: Create A Program Which Consist Of 2 Function?

Apr 10, 2014

i want to create a program which consist of 2 function. one function should find the greatest number and the other one should calculate the average but when i run this program i get segmentation fault

Code:

#include<stdio.h>
int main() {
int k,i,A[k];

[Code]....

View 8 Replies View Related

C :: Create Program Which Requires The Input?

Nov 16, 2013

I would like to create a C program which requires the input in this form: number1 operator number2, where number1 and number2 are numbers of type double and operator is one of the characters +,-,*,/.

There is my attempt to write this code:

Code:

#include <stdio.h>
double main() {
char operator;

[Code]....

Now I have to solve these problems: This code above doesn't work and I don't know why.I don't know how to fix the case when some user enters the input in this form:

Code: 1.5896 *5 or
Code: 7 / 5

I mean how the program knows that

Code: 1.5896 *5 is the same as
Code: 1.5896*5

I don't know how to fix the case when the user enters the input in the incorrect form for example

Code: 3

View 4 Replies View Related

C++ :: Create A Program Using Nested Looping?

Nov 5, 2013

You are to create a program using nested looping. Your program is to have a menu asking the user to select which pattern to create and how many rows to use (it should accept 1 to 10 rows and keep the aspect ratio of the pattern). The patterns are 1 - Box, 2 - V, 3 - Inverted V. Note, if I select pattern 1 with 10 rows, the box will have 10 asterisks in the first row.

Okay so i came up with the box but i have been getting stuck at getting the V or inverted V.

View 1 Replies View Related

C++ :: Create Two Box In Program Using Default Constructor

Apr 6, 2014

Im trying to create two box in this program using the default constructor. When i call to try and display the info, it says that x, y, and z are not declared in this scope. i wanted to have the user cin the length, height, and width using the void setBox function.

#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
class Box{
public:

[code]....

View 2 Replies View Related

C++ :: Create Program That Will Accept 2 Integers?

Sep 4, 2013

how can I create a program that will accept 2 two integers. the user will also choose among the different operations:

1 for addition
2 for subtraction
3 for multiplication
4 for division

View 4 Replies View Related

C++ :: Create A Program For Multiple Windows

Aug 18, 2013

i am trying to create a program for multiple windows. Here is my code

#include<Windows.h>
// Store handles to the main window and application instance globally.
HWND ghFirstWnd =0;
HWND ghSecondWnd=0;
HWND ghThirdWnd=0;
HINSTANCE ghAppInst=0;

[Code]...

problem is when i try to execute the code it just say create window1- failed!!

View 1 Replies View Related

C++ :: Program To Create A Vector Of Integers

Feb 10, 2015

1. Write a c++ program to create a vector of integers. copy the vector contents into list, sort the contents, then copy selected items into another vector(like elements less than 10 etc)

View 1 Replies View Related







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