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?
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: ";
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> 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....?
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[?].
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;
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:
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...
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.
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.
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
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.
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.
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());
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> #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?
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.
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++.