C :: Hexadecimal Digits Greater Than F?

Apr 21, 2014

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?

View 1 Replies


ADVERTISEMENT

C++ :: Input Integer Then Output Both Individual Digits Of The Number And Sum Of Digits

Oct 11, 2014

My problem needs to prompt the user to input an integer and then outputs both the individual digits of the number and the sum of the digits. An example would be entering 8030 and it spits out 8 0 3 0 as well as 8+0+3+0=11 and it needs to work with negative numbers.

Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int base;

[Code] ....

Now I don't know if any of this is right a hint my professor gave us is that to get the fourth digit you would do base mod 10 and to get the first digit you do base divided 1000...

Code:

{
int power;
int counter=0;
int value=1;
cout << "Enter the power of 10 you want: ";

[Code] ....

View 2 Replies View Related

C/C++ :: Char To Hexadecimal - Hexadecimal Back To Char

Sep 9, 2014

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 <stdio.h>
int main(void) {
char myChar;

[Code]....

View 3 Replies View Related

C++ :: Getting Number Greater Than Average?

Jul 24, 2014

#include<iostream>
using namespace std;
int main(){
int k,num,sum=0,GreaterNO=0;
double average;

[Code] .....

above is my program, I have received an assignment which the lecturer request us to find a series of k numbers then

-display the average
-display the total of numbers greater than the average

our lecturer request us do in 2 version, one is by using array, one is without using array, I have facing the coding problem when doing the VERSION WITHOUT USING ANY ARRAY to get the display the total numbers greater than the average, is there possible to get it?? because there are only one variable keep on looping, but the average will only get after get all the user input....?

View 8 Replies View Related

C++ :: How Many Elements Are Going To Be Greater Than NUM1

Jan 29, 2014

I was wondering if there was some sort of C++ equivalent for the IDL FIX function. For example, say I want to find all the elements of FLOAT ARRAY1[] that are greater than NUM1 and convert them to INT ARRAY2[].

The problem I have with writing this code myself is not knowing how many elements are going to be greater than NUM1, so I don't know how to initialize ARRAY2[?].

View 1 Replies View Related

C++ :: Elements Greater Than The Array Max?

Dec 11, 2013

im trying to write a program that finds the max in an array and divedes it by two than oututs a modfied list with all the elements greater than the max/2.

I got the first part but just not sure how to find the elements greater than the max/2 and output them correctly into the modfied list.

#include <iostream>
#include <iomanip>
using namespace std;

[Code].....

View 2 Replies View Related

C# :: Parameter Name - MaxValue Must Be Greater Than Zero

Oct 1, 2014

Where is problem in my code, it is a flappy bird. I dont know why put me that problem when click Start on game show me on 99 line error 'maxValue' must be greater than zero. Parameter name: maxValue

I copy exception to clipboard

System.ArgumentOutOfRangeException was unhandled
HResult=-2146233086
Message='maxValue' must be greater than zero.
Parameter name: maxValue
Source=mscorlib
ParamName=maxValue
StackTrace:

[Code] .....

View 6 Replies View Related

C/C++ :: Program Crashes When Records Greater Than 10

Feb 17, 2015

I've implemented a records system for a college assignment and everything works as intended. However upon increasing the amount of records to store in my array above 10, the program crashes upon adding a new employee and I can't work out why...

#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#define esize 10 /* Change max-records */

[Code] .....

View 3 Replies View Related

C++ :: Find And Print Average Of Odd Numbers Greater Than 5 And Less Than 100

Nov 5, 2014

I am new to programming in C++, and have got a project on this.

Write a C++ program that accepts three numbers from the user (All are integers):

Such as:

Enter the first mark: 3
Enter the second mark: 25
Enter the third mark: 23

The program should find and print the average of the odd numbers greater than 5 and less than 100.

View 4 Replies View Related

C++ ::  How To Obtain Total Of Numbers Greater Than Average Without Using Array

Jul 27, 2014

I am facing a problem which i could not obtain the total numbers which is greater than the average value. For example:

#include <iostream>
using namespace std;
int main (){
int size , count;
double no, max, min ,total, sum , average;

[Code] ....

In this case im able to compute the average of the numbers but when it comes to capture the total of numbers which is greater than the average value, how to compile the code , because the average number is only been compute once all the value capture by the input of user is sum up.

View 19 Replies View Related

C/C++ :: Selectively Choose Only Numbers Greater Than 1000 In Array?

Aug 4, 2013

I am doing my assignment that will calculate total tax amount per day and per week and finally sum those up.

One of the requirement is to filter out any number in the array that is less than 1000 to be assigned a value of zero instead of the stored value so as not to add it in the calculation. How to fulfill this requirement.

View 2 Replies View Related

C :: Find Factorial Of Any Number Greater Than Zero And Use Gosper Formula To Approximate It

Feb 24, 2013

I was given a question in my programming class to create a program to find the factorial of any number greater than zero and to use Gosper's formula to approximate it.

Code:
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
double equation(int n);
int

[Code] ....

View 2 Replies View Related

C++ :: User Input 10 Integers Of Array - Add Numbers Greater Or Equal To 10

Oct 29, 2013

create a program that asks the user to input 10 integers of an array the program will add the numbers greater or equal to 10.

View 6 Replies View Related

C :: Printing Value (in Hexadecimal) Of A Pointer

Oct 7, 2014

I'm trying to print the full value (in hexadecimal) of a pointer.This is my best attempt so far:

Code:
char *text = "x10x11x12x13x14x15x16x17";printf("%x", &text);

And it obviously doesn't work, best I've gotten is a single byte, but I want the whole lot of bytes.

View 4 Replies View Related

C :: Converting Letters To Hexadecimal

Jun 3, 2014

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.

View 3 Replies View Related

C :: How To Convert Array To Hexadecimal

Feb 21, 2013

I have an array:

Code: int array1[]={0,1,1,0}

I need to convert the entire array to Hexadecimal.

My first thoughts to the approach was to convert the array to a string then strcmp but i cant seem to find how to convert an array to a string either.

How to convert the array to hexadecimal directly? or, How to convert the array to a string to be strcmp'ed?

View 6 Replies View Related

C++ :: Convert To Hexadecimal And Hex Addition

Nov 20, 2013

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>

[Code]...

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.

View 3 Replies View Related

C++ :: Decimal To Hexadecimal Code

Jun 8, 2014

I have to write a code that converts a hexadecimal value to a decimal value.So far I have

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

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

View 5 Replies View Related

C/C++ :: Hashing Hexadecimal Addresses?

Feb 25, 2015

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.

View 2 Replies View Related

C# :: Converting Decimal To Hexadecimal

Feb 20, 2015

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());

[Code] ....

View 12 Replies View Related

C++ :: Print Hexadecimal Strings From Binary

Aug 19, 2013

How to search in C or C++ a hexadecimal patterns within a binary file.

For example:

String1:

Code: 0x44 0x65 0x07

Then, once found, extract those 3 bytes and the next 11 bytes (14 bytes in total).

Finally, from those 14 bytes, print without spaces "bytes 1 to 6", "bytes 6 to 12", and byte "13 to 14".

Then I would like to print last 2 bytes (13 to 14) joined in decimal format.

The output without any conversion would be:

Code:
446507c90688 888000800005 0015
4465072ec918 059173495269 002C
44650700cc01 01811bc90b00 00AB

But the output converting to decimal the last 2 bytes would be:

Code:
446507c90688 888000800005 21
4465072ec918 059173495269 44
44650700cc01 01811bc90b00 171

The sample file is attached, and looks like this:

Code:

06 00 00 80 00 00 00 80 09 3c c9 06 88 88 80 00
80 00 44 65 07 c9 06 88 88 80 00 80 00 05 00 15
37 06 01 00 00 01 00 65 00 00 00 02 00 00 02 00
18 00 00 00 03 00 00 03 00 17 00 00 00 04 00 00

[Code] .....

View 8 Replies View Related

C :: How To Convert Hexadecimal Into Floating Point

Mar 10, 2013

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.

Code:

union {
char c[4];
float f;
} conv;

View 4 Replies View Related

C :: How To Convert Binary Table To Hexadecimal Value

Oct 2, 2013

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.

Code:
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <fstream>
#include <cstdlib>
#include <string>
typedef unsigned __int64 Ebyte;
#define length 64

[Code] .....

View 12 Replies View Related

C/C++ :: Reading Hexadecimal Bytes From A File?

Jan 19, 2014

#include <stdio.h>
#include <stdlib.h>
int main(int argc, int * argv) {
   char buffer[16];
   FILE *fp;
   unsigned long long test;
   unsigned char key[16];
   fp = fopen("D:key.txt","r");

[code].....

i searched for a code for reading bytes from a file and i found this one but when i run the program, it doesn't return the bytes written in the file, it returns another bytes / what is the problem?

View 3 Replies View Related

C++ :: Displaying Constants As Decimal / Hexadecimal / Letter

Oct 13, 2014

I need to write a program in which you do the following:

Define three named constants using the appropriate data types:
DEC_NUM = 65;
HEX_NUM = 0x7a;
LETTER = 'f';

Then display each of these constants in decimal, in hexadecimal, and as a character using cout. Your program will have a total of nine cout statements.

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







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