1)What should be the best variable for adding two 6-digit hexadecimal,such as 0034AD,0057EA? I would like to use array of character but it seems hard to handle.
I'm trying to convert 4 hex register into floating point value using IEEE 754 floating point format. My device will reply 4 register value. The problem is that it always reply for example 0x10 as 10 when i use getc() hence using char variable to store it is not ideal.
i need to code a function that converts an array of 64 bits into a hexadecimal value, the one is tested gives me correct value except for the last hexadecimal letter.
#include<stdio.h>#define MAX 1000 int main(){ char binaryNumber[MAX],hexaDecimal[MAX]; long int i=0; printf("Enter any hexadecimal number: "); scanf("%s",hexaDecimal);
[Code]...
So this is my current code, is there anyway I can reduce the size and use a main function to ask for input and a call function to do all the conversion and return it? I am confused for the past few days trying to figure it out and finally ended up here. Anyway can I write it as a something like this
Code:
int main() { //ask for user input hexadecimal into here and call a let's say hex2binary() function }
int hex2binary(...) { //an array with dynamic memory, malloc? and convert it and return values }
I don't really need the full code, just a simple instruction on how and where to start.
I'm trying to write a program that takes input from the user (thats a char) and outputs it to the monitor in hex form.The program is meant to continuously take input from the user then output to the monitor in hex form until an EOF is detected this triggers the program to close.The following code does this except that I get a lower case 'a' at the end of each output.
example:
input from user: ABC output to monitor: 41 42 43 a
#include<iostream.h> #include<conio.h> class vector { float x_comp1,y_comp1,z_comp1,x_comp2,y_comp2,z_comp2; float add_x,add_y,add_z;
[code]....
Now the problem is that when i run the program, i get correct value of the two vectors, but i am not getting the right value for the addition...it might be the x_comp1 and so on are not getting those values even i am assigning them..
I need addition array1 array2 in new array before I make this program but the values of array1 and array2 there are in code c# that is worked without problem.
But now i need the user enter the values of arrays, i make that but i failed in addition array1 and array2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MyArray {
What my ultimate goal here is to make a program that asks the user how many numbers they would like to add followed by asking the user what numbers they want to add. I want the amount of numbers they can add to be infinite and have the loop continue adding the numbers until it reaches the final number. I just need to know how to do this.
Here's my code:
#include <iostream> #include <string> using namespace std; int main() { //variables int amount; float num; float sum;
i new to c++ programming. i have a program due soon in vector addition. i am to design should be able to add vectors with certain magnitude and direction and give its resultant magnitude and direction (i know how to do this mathematically but programming is not working. the user should be able to select how many vector he/she wants (i don't know how to do this, so i added 3 vectors). here's my work - i did this purely algebraically. it's still incomplete but it compiles. my "if else" statement also doesn't respond correctly.
#include <iostream> #include <string> #include <vector> #define PI 3.14159 #include <math.h> std::vector<int> v; // declares a vector of integers using namespace std;
I'm working on a matrix class and I've hit a few snags. Here's what I've got so far:
Matrix.h
#include <iostream> #include <conio.h> using namespace std; class Matrix { private: int matrix[50][50];
[Code] ....
Where I have questions is in implementing the addition and subtraction bits into the class itself. I understand that I'm going to have to do a copy operation (this from reading in C++ Primer Plus 5th Edition). Right now I'm just after adding/subtracting as the rest will be variations on the same theme.
So, here it goes:
As I understand the problem, I need to pass my two matrices as arguments to an addition function. This is going to involve having to copy the values of the two existing matrices into temporary matrices within the addition function, then I'll add them, and store them in a new matrix which will be my return value. So...something like this:
int Matrix::matrixAdd(int R, int C, const Matrix & matrix1, const Matrix & matrix2) { int sum; Matrix matrix; for (int i = 0; i < R; i++)
[Code] ....
I do end up with errors there...C2240, and C2662. Again, I'm new to working through this, but that's what I've got. My idea is that I'm passing the maximum size of the array as defined by the user, in this case a 2x2 array, it'll cycle through and add up to that imposed limit...I went 2x2 because it's small enough that testing doesn't drive me up a wall.
Below is a code that is used to calculate complex numbers (a+bi, where i = sqroot (-1)) through multiplication and addition.
However, on my output file, no Header is being printed; the only thing that is being printed is "8 + 7i + = "
"complex.h" is included at the end of the code.
Code: // Trey Brumley// CMPS // Dr. Tina Johnson // March 1, 2013 // Program 2: Classes // This program will demonstrate the use of classes by using a custom "complex-number" (a+bi) class.
I'm writing an addition and subtraction calculator that takes input as: 5+6-3+2. You should be able to add or sub as many numbers as you want. I want the while loop to stop when the user hits enter. I put the getchar() function to catch the and break the loop but it is also swallowing the '-' sign, which I want to use to subtract and is instead adding the numbers with "sum+=number". How can I get around that?
Code:
#include <stdio.h> int main(int argc, char *argv[]){ int number, sum = 0;
I then overloaded the I/O operators so I could print to the screen information related Sales_data.
Code: // overload ostream in order for cout to work std::ostream& operator << (std::ostream & out, const Sales_data & cSales_data) { out << cSales_data.bookNo << ", " << cSales_data.units_sold << ", "
[Code] ....
My first issue is with overloading the addition operator. Everyone works correctly except for std::cout << item << std:endl; will no not output the ISBN number only the units_sold and revenue when added together.
After total = total + item;, I would like to print the total for this particular ISBN. However, I only get: blank, total units, total revenue where blank is where the ISBN would go but doesn't print after addition. My second question has to do with comparing the ISBN's of the books entered during the while loop. I would like to do something like
Code: if (item_i.bookNo == item_i+1.bookNo) { total = total + item; } else { std::cerr << "Books entered must have the same ISBNs" << std::endl; }
Unfortunately, I cannot figure out how to set up a comparison of the bookNos. If I used #include <casset> in the overload + rule, it will immediately exit since I have no way to compare the ISBNs.
I need to create a function that performs the addition of x days at a time, taking two integer values, the first being a date (yyyymmdd format) and a number of days to add / subtract that date.
How can I perform validation if the entire amount received is a valid date and how can I add x days of that date?
i m trying to write a code that would convert a each letter from a text to their decimal images . while i was able to write the part of entering the text , i cant do the converting part , i searched all day on the internet and found nothing.
Write the function itob(n,s,b) that converts the integer n into a base b character representation in the string s . In particular, itob(n,s,16) formats n as a hexadecimal integer in s .
Note that it says the result is formatted into a hexadecimal integer in the string s. Here is the example provided:
Code:
void itob(int n, char s[], int b) { static char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int i, sign; if ( b < 2 || b > 36 ) { fprintf(stderr, "EX3_5: Cannot support base %d
[Code] ....
Why does digits array hold the full alphabet when the maximum digit for a hex number is f?
int num; char g; int rem; int main(){ cout << " input num: "; cin >> num;
[code]....
I think i need to put the g and rem value into a string... which I'm not sure how to do since g will be a char value and rem will be a int value... and after I believe i need to then flip the numbers in the string.. oh it has to be in the format of 0000
I'm taking a university course and one of our first projects dealing with C is to write a hash table (with chaining as a collision solution) that will hash loads of hexadecimal values into the table. I'm just brain storming right now but how practical is it to hash the values by converting them to decimal and working with that value in another function to organize the values? I'm thinking this might take a lot of time and memory because our code will be tested with text files that could have a few lines of hexadecimal addresses or millions of them.
I am new at programming and I have some questions about converting decimal to hexadecimal WITHOUT using .net library. The problem is, that I don't know how to do vice versa. (if you type 1254, program returns 6,14,4. I want programm to return 4,14,6- this is almost hexadecimal number (14 is not converted to "E")). Also the task is, that program has to return value in string form.
static void Main(string[] args) { int a = 0; int result = 0; int n=1000000; int[] array = new int[n]; Console.WriteLine("Insert numbers"); a = int.Parse(Console.ReadLine());
Below is a program that generates random Addition for Subtraction problems depending on the user's choice. The user is prompted to input an answer and then it keeps your score. If you want to quit you just press zero.
Code: #include <iostream> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <iomanip> #include <string> using namespace std; int menu(); bool addition(int &reward); // function to return truth values