C/C++ :: Pointer Values Into Pythagoras Calculation
Mar 31, 2014
I have a doubly linked list, which reads in a set of coordinates x and y.
I need to pass these coordinates into a method called calculateImportance and execute Pythagoras on them. With this in mind I need to be able to access the pointers current, next and prev.
The issue I am having, is that I am unable to pass the pointers through to the method?
This is the list.h
#include <iostream>
class List {
private:
typedef struct node {
int xCoord;
int yCoord;
float importanceFactor;
[Code] .....
View 6 Replies
ADVERTISEMENT
May 2, 2013
Question: State the values of each of these int variables after the calculation is performed. Assumed that, when each statement begins executing, all variables have the integer value 5.
a) product *= x++;
b) quotient /= ++x;
What is the answer for a and b?
View 4 Replies
View Related
Nov 8, 2013
I have a text file in the form
5502 5202.3
1523 2536.1
1254 1256.2
17846 8956.2 and so on
left one is time and right one is pressure, I need to show the time value as it is but i need to use the pressure value to calculate air speed. I don't know how to use the strings to pick up the list properly. I did the calculation formula for the air speed but i can't pick the pressure value up from the text file. here's what i did:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
[Code].....
View 3 Replies
View Related
Mar 6, 2015
Here is the part of my code that I need to return two values. I am working on a roulette program and I need to return the choice and the number they are betting on. How can I use a pointer to achieve this?
Code:
int makeBet(char choice, int num){
printf("
What type of bet would you like to place? ");
printf("
Type n for number.
Type e for even/odd.
Type d for dozen.
[Code] ....
View 2 Replies
View Related
Feb 12, 2013
I am using pointer to display values of an array but its output is not correct example 23424,0, -323423 etc... whats the problem with my code:
Code:
#include<stdio.h>
#include<conio.h>
int main() {
clrscr();
int arr[10][10],rows,cols;
int* ptr;
[Code] ....
View 4 Replies
View Related
Jan 14, 2015
I am currently trying to printf several values of a struct pointer but with little success.
#include"Header.h"
/*
In header:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
struct FileStruct {
char FileQuestion[64];
[Code] ....
As you can see I am trying to re-crate the output from the first loop in my second loop, however it is with little success. The second loop's first run re-crates the last output of the first loop and if I use FileStructPointer++ or -- the output goes broke.
See attached for how it looks in the console window.
Attached image(s)
View 3 Replies
View Related
Aug 10, 2013
I can assign values to pointer character array like this...
Code:
char *array[4]={"abc","xyz","dgf","sdt"} ;
but the case is i don't know how to assign strings through key board ???? with using gets ,getchar or other suitable function
View 2 Replies
View Related
Mar 7, 2013
I am writing a C program to access a string into an array from a pointer array in Visual Studio 2010. Program is given below:-
Code:
#include <stdio.h>
#include <string.h>
void main() {
char data_a[6],data_b[6]="ABcde",*ptr;
ptr=&data_b[0];
data_a[0]=*ptr;
printf("%s",a);
}
I am getting some junk character first and then my actual data on console window. I want to where I am getting wrong and how to resolve it.
View 4 Replies
View Related
Nov 19, 2013
I am having an issue with my sort function. This is one part of the Hash table program. The main issue is that I am trying to sort the pointer table after all of the values have been entered. The ptr_sort function is not a class function and so I am therefore unable to use the class variables psize and pTable. Is there another way I should be trying this? it is a Vector should I use the sort() function from the vector class in STL?
#include "/home/onyuksel/courses/340/progs/13f/p9/util9.h"
#include "/home/onyuksel/courses/340/progs/13f/p9/hTable.h"
#ifndef H_TABLE1
#define H_TABLE1
void ptr_sort ( );
[Code] ....
View 1 Replies
View Related
Jan 3, 2014
i need to calculate crc32 of a input file and check with the original crc value of a file and return true/false,
View 4 Replies
View Related
Aug 8, 2013
I tried to write a simple program to calculate monthly yield, APR, and principle in various directions. Anyway, here's some code to get the APR from the principle and monthly yield. When I run it though, it spits 0 at me every time! What the problem is; the other functions work just fine and the code line for the APR calculation is just what it ought to be - I see neither a math nor tech problem here.
Here is the offending function:
Code:
void calculateAPR() {
int principle, monthlyYield, apr;
cout<<"
Please input the principle:";
cin>>principle;
cin.ignore();
[code]....
View 4 Replies
View Related
Mar 6, 2015
I would like to ask about how we calculates the following bitwise expression.
Code:
unsigned char ch[2] = {0x49,0x49};
ch[0] | ch[1] << 8; I'm thinking ch[1] << 8 as 0x00 ...
So, I think that the above expression converts to 0x49 | 0x00 ... and the complete expression should be 0x49 for me.
But, the compiler gives me the result of 0x4949 as two bytes.How does the compiler calculate this expression as two bytes?show me the steps included in the calculation of this expression?
View 2 Replies
View Related
Apr 9, 2014
I want to have calculations take place inside a switch statement that calls the appropriate function. The menu portion of the program works well, but I can't figure out how to let the user actually input 2 different numbers to the functions. My questions are:
1. If I use scanf to assign values to the variables, what determines end of input to each variable? (ie.. scanf("%d%d", &a, &b) what is the end of a, what is the end of b?)
2. Should I assign the variables to user input inside the switch, or try to do it in the functions below?
3. Is there something I haven't thought to ask that will screw me over? I'm really new to this.
Code:
#include<stdio.h>
int add(int b, int a);
int mult(int b, int a);
main() {
[Code] ....
This really was a test of multilayer menu, but I want to add functionality if I can.
Changed a variable before posting and didn't change all the conditions testing it.
View 3 Replies
View Related
Dec 17, 2013
void viewWasteReport(){
EXEC SQL BEGIN DECLARE SECTION;
char wasteid[5],wastetype[31],month[11],wastequantity[13],wasteweight[11];
//double wastequantity[13];
//double wasteweight[11];
EXEC SQL END DECLARE SECTION;
fnConnectDB();
[Code] ....
I want to obtain the the product of wastequantity*wasteweight, but i get error.
View 6 Replies
View Related
Aug 1, 2013
I am trying to calculate a CRC of a Base64 string.I give you the correct checksum : 2942042514...And now the string :
AQAAAAAAAABsYAAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0d2XIaSbI+hZ13
m0NCR0QNE7KOHcXKlkMwtnhyIIRkdjGwgGxpP35386jqursRsk0zQygkd+dR
lVmVmZVdl//3Xyl+E4/iixiJivgqBmIm5mIoJmIsfhW/iLp4LWrwbwUwY9EH
[code]....
I tried CRC 16, 32 and with polynomial 0xEDB88320L, and with all these tries, I cannot find the correct checksum, it is my main problem.I don't want C++ code source, but I am searching for the method or algorithm to find it. If you want to know, this string in base64 contains an string compressed in zip, which contains an UTF16 XML. I want to modify information, and modify Adobe Projet (prproj)
View 6 Replies
View Related
Oct 1, 2014
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
[Code]....
Write a program that outputs inflation rates for two successive years and whether the inflation is increasing or decreasing. Ask the user to input the current price of an item and its price one year and two years ago.
To calculate the inflation rate for a year, Uh, no, that’s wrong! To calculate the inflation rate for a year, subtract the price of the item ONE YEAR AGO from the price of the item for that year and then divide the result by the price a year ago. For example: 2014-Inflation-Rate = (2014-Price minus 2013-Price) / 2013-Price.
Your program must contain at least the following functions:
•a function to get the input
•a function to calculate the results
•a function to output the results
View 1 Replies
View Related
Dec 9, 2014
I need to create average calculating program using do while loop.
t = 1 - sin(x) when x > 0;
t = 1 + x when x = 0;
t = a + sin(x) when x < 0;
primary information:
x changes from 1 to -1 by step h = -0.5, a = -2
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main() {
int a = -2;
[Code] ....
How this program should look that's why this probably looks just like a mess.
View 2 Replies
View Related
Aug 1, 2013
I am trying to calculate a CRC of a Base64 string. I know the answer of the checksum, but I don't how to calculate it (It is for Adobe project).
I give you the correct checksum : 2942042514
And now the string :
AQAAAAAAAABsYAAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0d2XIaSbI+hZ13
m0NCR0QNE7KOHcXKlkMwtnhyIIRkdjGwgGxpP35386jqursRsk0zQygkd+dR
lVmVmZVdl//3Xyl+E4/iixiJivgqBmIm5mIoJmIsfhW/iLp4LWrwbwUwY9EH
+C1gx+KesH+IjjgTr4Bqj2h+Ey0hxRHQTMQNcHwSV/A0EYsA3oFSFlDngDAf
[Code] ....
I tried CRC 16, 32 and with polynomial 0xEDB88320L, and with all these tries, I cannot find the correct checksum, it is my main problem.
View 12 Replies
View Related
May 13, 2013
Is there any possible way of calculating some values at compile time? I have the following code of genereting upto 2000000010 palindrome numbers.
Code:
#include <iostream>
#include <string>
#include <sstream>
#include <string.h>
#include <stdlib.h>
[Code] .....
As you see, I have taken input from the user just after calculating the whole palindromes. So cant we calculate this at compile time? because runtime of this program is extremely slow.
Another qs. I first tried to use array but It didnt allow 2*10^9 sized array. so what should I do whenever I need that size of array?
View 12 Replies
View Related
Feb 8, 2014
I wrote a function to do factorization (n!). while this function works perfectly:
Code:
int fact (double x){
register int z=1;
if (x==0)
return 1;
else
for(x;x;x--)
z*=x;
return z;
}
this doesn't:
Code:
int fact (double x){
if (x==0)
return 1;
else
for(x;x;x--)
x*=x;
return x;
}
what makes the second one different from the first one? can't see the difference..
View 1 Replies
View Related
Mar 24, 2014
Why do i keep getting wrong results
Code:
#include "stdafx.h"#include <stdio.h>
#include <string.h>
nt main(void){
char name[40];
int numbers[50];
[Code] .....
View 4 Replies
View Related
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
May 22, 2014
I'm working on a payroll program and I'm having problems that are causing calculation errors.
My input file is
1234FredJones4025.00
2345 TerrySmith6010.00
The errors I get are from the regular pay, over time pay, gross pay, tax amount and net pay calculations. They all look similar to this (6e+002). I believe they are occurring because regular pay isn't calculating correctly and the rest depend on that for their calculations. However, I can't see why regular pay isn't calculating correctly.
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
class payroll{
ifstream fin;
char employeeid[100];
[Code] .....
View 14 Replies
View Related
Apr 4, 2013
// DEBUG3-4
// This program contains a class for a cylinder
// Data members are radius and height
// The volume is calculated as pi times radius squared times height
// If no height is given, it's not a cylinder - it's a circle!
#include<iostream>
using namespace std;
//declaration section
[Code].....
View 1 Replies
View Related
Dec 13, 2014
I am trying to work on a C++ program to calculate the quadratic formula using input files and classes. I have written my class, but I am trying to find a way to take an input file with unknown number of lines of coefficients. How do I take each integer from each line and set that value as "a" and "b" and so forth, then start over on the next line?
This is what i have so far.
fstream inputfile;//users input quadratic coefficients file
ofstream outputfile;// outputs a file with solutions
int main(int argc, char *argv[])// argc is argument count, char *argv[] is array of array of characters for arguments {
string dataline;
getline(inputfile, dataline);
[code].....
View 1 Replies
View Related
Sep 25, 2014
i want to calculate age of a person so then i try to make an algorithm which is used in a function like (i know to use math.h for abs()) double age_calculator( int year, int month, int day);
Code:
double age_calculator( int year, int month, int day);
// p means present(current)
int pyear=(2014-year)*365;
int pmonth=(abs(9-month))*30;
int pday=abs(25-day);
return (pyear+pmonth+pday)/365.0;
how can i use current date, i mean i want to use date of present day instead of 2014,25 and 9. I don't know how i can use date of every day.For instance my function returns 14.74 for the parameters; 2000, 01, 01 (for the current day 25/09/2014)
View 6 Replies
View Related