C/C++ :: Finding The Value Of Sin(x) Without Using Math Function

Apr 14, 2013

How can i solve a problem of sin(x) without using any math.h and only using my own declared function.

#include <stdio.h>
int fact (int a) {
    int i;
    int k = 1;
    for (i=1;i<=a;i++)

[Code] ....

View 3 Replies


ADVERTISEMENT

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 :: Math Function Using Exponential Growth Formula

Sep 3, 2013

Its a basic math function using the exponential growth formula which is correct but the computer is not outputting the right numbers.

Code:
#include <stdio.h>
#include <math.h>
int main() {
int blanketsquares, num1, num2, blanket,remainder;

[Code] .....

View 6 Replies View Related

C :: Math Quiz Program - Multiplication Function

Nov 16, 2014

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void correctResponse(void);
void incorrectResponse (void);
void multiplication( void ); // function prototype

[Code] ....

// end function multiplication

// It keeps crashing. How do I compile the responses into a grade?

View 5 Replies View Related

C++ :: Finding Maximum Of A Function

May 8, 2014

What is the syntax to find the maximum of a function over the interval a≤x≤b starting at a with a step size of Δx ?

View 1 Replies View Related

C++ :: Function Not Finding Largest Integer?

Feb 10, 2013

My code compiles fine but it doesn't seem to want to calculate the max integer. It calculates min and average fine but I'm not seeing what is wrong with my code. The max integer keeps coming out wrong.

#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <cstdlib>
#include <algorithm>
using std::swap;

[Code] ....

View 1 Replies View Related

C :: Finding Error In Delete Node Function

Sep 12, 2013

I have written a delete node function to delete a node in a linked list by the index number. Here is the code:

Code:

void delete_node(struct node **start,int index_no)
{ int counter=0;
struct node *current=*start, *prev=NULL;//Current holds start and prev holds previous node of current
while(current->next!=NULL)

[Code]....

note that I know if the head node turns out to be the indexed position, there is no way to delete that node in the current coding. But please after correcting the present node add that part of the code separately.

View 5 Replies View Related

C++ :: Finding Size Of Array In Called Function

Nov 27, 2013

How to find the size of an array in called function? When we pass the array a argument to function definition we will be having base address of array, so my understanding is that we will not get the size of an array? but is there any hacking for this to find size of array other than passing as size an argument to this called function?

View 3 Replies View Related

C++ :: Finding Sum Of Two Fractions - Return Array In Function?

Jul 30, 2013

I am making a function that finds the sum of two fractions(fractions are arrays of 2 elements). how would I return an array?

int addFrac(int f1[2], int f2[2]){
int num1 = f1[0]; // numerator of fraction 1
int den1 = f1[1]; // denominator of fractions 1

[Code] ......

View 2 Replies View Related

C++ :: Finding Function Documentation For Header File

Nov 23, 2013

I would like to see what functions the following header file has:

#include <tf/LinearMath/Transform.h>

Any website that has all the c++ libraries and where to find the functions that come with this?

View 4 Replies View Related

C :: Recursive Function For Finding And Summing Prime Factors?

Mar 6, 2015

main function:

Code:
int main(){
int n, s = 0;
printf("Insert number: "); scanf("%d", &n);
if (n == 0 || n==-1 || n==1){ printf("No prime factors!
"); return 0; }
if (n < -1) { n = - n; printf("Prime factors: -"); }

[Code] ....

Recursive function

Code:
static int i = 2;
int primefactors (int n) {
if (n == 1) return 0;
if (n%i == 0) {
printf("%d ", i);
return i + primefactors(n / i);

[Code] ....

View 8 Replies View Related

C :: Function Macro For Finding Square Root Of A Number

Jul 13, 2014

How to write a function macro in C for finding the sqrt of a number?

View 2 Replies View Related

C :: How To Write Powers Without Using Math

Sep 22, 2014

How would one write 3^i without using .math? (i being numbers 0-9)

More specifically, this is what I have:

Code:

#include <stdio.h>
#include <stdlib.h>
int main(void) {
int x, n, answer1, first;
x = 3;
n = 10;
first = 1;

[Code]....

And this is what I want it to produce:

1 0 1.0
3 1 0.333333343
9 2 0.111111112
27 3 0.037037037
81 4 0.012345679
243 5 0.004115226
729 6 0.001371742
2187 7 0.000457247
6561 8 0.000152416
19683 9 0.000050805

I believe I am only having troubles with the first column,

View 10 Replies View Related

C++ :: Inserting Math Functions From GUI

Feb 8, 2013

I have a problem with entering math functions in my Bisection method algorithm program. I just don't know how can I make the function that I enter in my GUI app to go from the GUI to the loop and find the root.As far as I googled I only find codes that you need to pre-enter a function in the double/float.

For example:I have a function f(x) = x^3 - cos(x) - x - 3; and I want to enter that function trough the GUI i made in c++..So this is the main code.

#include "bisection.h"
#include "ui_bisection.h"
#include <QFile>
#include <QString>
#include <math.h>
#include <algorithm>
bisection::bisection(QWidget *parent) :

[code]....

View 11 Replies View Related

C++ :: Math Formulas Using Variables?

Mar 21, 2013

Working on a program that converts infix to postfix math formulas. Ive successfully converted the infix to a postfix notation but now i am having trouble solving the equation from the postfix form. Im trying to set a result equal to three variables as shown below:

result = op1 ch op2;

where op1 and op2 are numbers and ch is the operator (+-*/) depending on what the user entered into a string. The error im getting is that it expected a ";" before postfix so clearly it doesn't understand what im trying to do. how to put the answer from op1 ch op2 into result.

View 4 Replies View Related

C :: Calculate Value Of Math Expression Using Strings

Nov 4, 2013

Here is my objective: Write a c program that calculates the value of a mathematical expression comprised of positive numbers and the operations "+" and "-" . Specifically, first prompt the user to input an expression, read itin as a string, and then print the value of the expression. You may assume that the expression does not contain spaces, maximumsize of the expression (including digits and operators) can be 20,and that all numbers are single digit numbers.

Note that, the digits would be read in as characters; you will need to translate them to numbers (recall the ASCII table). Implementation Requirements:

Write a function called "evaluate" that takes as input a mathematical expression(as a string) and returns the value of the expression. The prototype of the function is: intevaluate(char expr[]);

Sample Output:
Input: 4+2-1+7 Output:12

Code:
int main()
{
char expr[21];
int a,ssum;
printf("Input: ");
scanf("%20s", expr);

[Code] .....

the program runs, but the output is not coming out correct.

View 11 Replies View Related

C :: Trapezoidal Rule - Math Library

Mar 22, 2013

I am new to c programing and I had spend 2 days on a program and I can't fix the error:

Code] ....
gcc Test.c -o Test.exe
/tmp/ccZkbk0V.o: In function `f':
Test.c:(.text+0x2f): undefined reference to `sqrt'
collect2: ld returned 1 exit status

Tthe program I am working in is:

#include <stdio.h>
#include <math.h>
int f(int x){
return (sqrt(4.0 - x*x));

[Code] .....

View 2 Replies View Related

C :: Date Math Using Standard Libraries?

Dec 22, 2013

Is there any way to do date math using standard C libraries? I looked around in the time.h but didn't see what I needed.

What I need to do is be able to add a certain number of minutes to a date and have it give the current date/time. For example, add 15918765 minutes to 01/01/1980 00:00 and have it tell me 04/07/2010 4:45PM. I really don't want to write this myself or go platform-specific.

Does this exist somewhere or am I SOL?

View 13 Replies View Related

C :: Program That Solves Math Equations

Apr 30, 2013

I wrote a program that solves an equation of two numbers, but in addition to that, I want it to be able to continue to solve longer equations. Ex: ( solves 2 * 4, or 2 * 4 - 5).I want to put this part of the program's result into a variable and go from there. How do I place the result of the calculation into a variable, and where would it go?

Code:

#include <stdio.h>
#include <string.h>
int main(void) {
int a;
scanf("%d", &a);
char s[2];
scanf("%s", s);
int b;
scanf("%d", &b);
}

[code]....

View 4 Replies View Related

C++ :: Comparing Math Operator With A Variable?

Oct 14, 2013

I am trying to compare a math operator with a variable, but i keep getting this error:

postfixDriver.cpp:93: error: expected primary-expression before ')' token.

I'm sure it's probably something simple, but im just not seeing it. Here is the code snippet:

while (strlen(str) != 0) {
split (str, token);
Postfix stack;
double a;
double b;
double answer;
if (atof(token)==0.0)

[Code] .....

View 2 Replies View Related

C/C++ :: Interest Calculator Math Part

Feb 11, 2014

math part.

The equation I need to use is: payment = [(rate * (1 + rate)^number payments ) / ((1 + rate)^number of payments -1)] * loan

Also, the value of rate in the above equation is (interest/12)/100. So 12% annual interest would be 1% monthly interest.

heres my code:

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

[Code].....

View 4 Replies View Related

C/C++ :: Define Math Operators As Variable?

Aug 17, 2014

I have to create a program that read two numbers and the math operators +, -, * and /. After that I should print the operation required. But I tried to declare a <symbol> variable as char type, without sucess...

Here goes my script:
float num1, num2, result;
char symbol;
printf("Write two numbers:
");

[code]....

View 1 Replies View Related

C++ :: How Sub String And Math Can Be Used To Make Logical Decisions

Dec 1, 2014

This is an example of how sub string and math can be used to make logical decisions without using if/elses or switches. It works because of this equation

(x + |x|)/x = 2 if x > 0 and = 2 if x < 0.

#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
//declaration of variables

[Code] ....

View 1 Replies View Related

C/C++ :: CodeBlocks Random Math Quiz Generator

Nov 26, 2014

The user will be allowed to pick:

-the number of problems they want to do
-the type of problem (addition, subtraction, multiplication, division)
-the range of numbers for the problems (like 0 to 9, -100 to 100, etc.) [random numbers in the range]

Your program will then display the given number of problems and get the answer from the user. It will tell the user it they are correct or not. If they are incorrect, it will print the correct answer.

After the given number of problems are displayed, the program will give the user the final number correct and percentage correct. The user will be asked if they want to go again. If so, you will reprompt the user for all the information and run again.

I came up with code thinking I was going in the right direction but it doesn't work correctly at all. We have to use functions. My main issue is how do i call variables from another function so all of the functions work together. I repeat I don't understand parameters and calling functions. here's the code:

#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int get_user_range(int &x, int &y);
int get_random_number ();

[Code]......

View 1 Replies View Related

C/C++ :: Decoding RFID Data Hexadecimal Math

Feb 2, 2015

I currently am stuck at getting the needed outcome data from my RFID card. I got it decoded but now I need to do a few more things in order to get the final card number off the back of the card.

The cryptic value was E********B**0**E** (covered to protect card)
Decrypting it turned into 0000003048D1263B

Now I have 3 more steps to take in order to get to my wanted card number.

Quote
Step 1) Mask off the lower 20-bits (which should give me 0x1263B) I am unsure of how to go about doing that using C++.

View 2 Replies View Related

C :: Calculate Variance And Standard Deviation - MATH Error

Mar 6, 2015

The values in my file are 5,5,332,156,11,0,555,32,8,9 .... the computer when I scan and read is missing the first 5 and only showing 9 values which is messing up my mean and standard deviation. But when I have them put in order all of my numbers show up:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SIZE 100
void bubbleSort( int * const array, size_t size);// prototype

[Code] .....

if possible, why won't the median work. I have it commented off as of right now....

View 2 Replies View Related







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