C :: Not Getting Actual Output While Displaying Hex Numbers In Decimal Format
Apr 26, 2013
I need to display 0-15 hex numbers[0X00-0x0F] in decimal value...& I'm getting the output but it's not exactly what it should be,below is my code.. [This not the complete code,but main part where the changes are done]
Actual output i should get is for 1v it should generate 0001,for 2v it should generate 0010 and simultaneously till [15v-1111]... But what i'm getting is exactly different to this for eg for 7v,8v&9v the bits generated are 1101,1011,1011 respectively...
event................. red house.............. blue house........... yellow house Chess ......................12.................... 5....................................8 TableTennis .................. 4.......................... 11.....................17 Basket Ball .................... 6......................... 5......................14 karathe ..........................5........................... 8.........................10
Write a program to input the house name, and the score (as shown in the table) of the sport event obtained by the corresponding house. Then find the total score . You should use nested selection statements.
i) If the user inputs a wrong house name, display the error message "In valid House Name".
ii) Modify the program to handle many data. After calculate and disp ay the total score of the house, the program should display a prompt "Do you need to enter nother house name?".
If the user inputs "y" or "Y", program should ask for the next house name and the scores. If the user inputs "n" or "N" after entering all three houses, program should terminate by printing the score of the winner. If the user inputs "n" or "N" and without entering all three houses, program should display an error message "Error in finding the winner" and terminate without printing the ranks.
Note: format the output into two decimal places.
Sample output: Enter the house name: red house Enter the score of Chess: 12 Enter the score of Table Tennis:4 Enter the score of Basket Ball:6 Enter the score of karathe 5 Score is: 27 Points Do you enter another house name? y
Enter the house name: blue house Enter the score of Chess:5 Enter the score of Table Tennis:ll Enter the score of Basket Ball:5 Enter the score of karathe 8 Score is: 29 Points Do you enter another house name? y
Enter the house name: yellow house Enter the score of Chess:8 Enter the score of Table Tennis: 17 Enter the score of Basket Ball: 14 Enter the score of karathe 10 Score is: 49 Points Do you enter another house name? n The winner scored: 49 Points
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.
Enter first prime numbers that will be used or -1 to end: 20 Twin Prime Number : (3,5) Twin Prime Number : (5,7) Twin Prime Number : (11,13) Twin Prime Number : (17,19)
But what I want is:
1. {3;5} 2.{5,7} 3.{11,13}
4. {17,19}
else if (i - prime_number == 2) { cout << "{" << prime_number << ";" << i << "}" << endl << endl; prime_number = i; }
User enters sentence "The Smiths have two daughters, three sons, two cats and one dog." (The numbers may change depending on what the user chooses to enter. He told us the range would be from zero to nine.) and we have to convert the written numbers within the sentence into actual decimal numbers and print out the new sentence. Ex. The Smiths have 2 daughters, 3 sons...etc.
I have written the following bit of code which reads the string and finds all the "written numbers" but I am not sure how to proceed from there. I am stuck on how to print out the new sentence with the converted numbers as my professor mentioned something about creating the new string using dynamic memory allocation.
Code: #include <stdio.h>#include <string.h> int main () { char A[100]; int length = 0; int i;
I am trying to write a c program to convert centimeters to inches and then to feet. I have most of the code written but not sure how to debug it. I keep getting "0" as all of my output.
#include <stdio.h> // Main Function int main(void)
I have turbo c++ on windows xp SP2.....whenever i compile my code in turbo c++ i am getting output outside the screen.....but when i used code::block....i get the correct output...fits to screen ...
Code: #include <iostream> int multiply (double x, double y) { double result = x*y; return (result);
[Code] ....
I get the answer 5.94 (which is what I'm looking for). I can't work out why the first example is not outputting a decimal number. I have set the variables as a double so I just can't see why this is not working for me.
I am learning c because I want to get back into programming microcontrollers, which I previously did in assembly. I wanted to make something fairly tight in terms of program memory and RAM to show me an output in binary form. When you are troubleshooting a file register or serial interface when you can see the actual bit values (on a small LCD for a micro-controller) and compare it to a datasheet.
Code: #include <stdio.h> #include <math.h> int main() { int i; int decimaltoconvert; int convertingarray[7]; int convertingarray2[7];
[Code] .....
Also, how might I go about putting that into a function that I could call?
which worked well at first because on my command prompt screen the numbers had two decimal places and looked liked this:
Premium for Pol1 is $14101.62 Premium for Pol2 is $14221.16 Premium for Pol3 is $582390.50 Premium for Pol4 is $220384.49
However, I also have the program outputting to a textfile called "output.txt" and when I opened this text file the numbers only had one or no decimal places.
Premium for Pol1 is $14101.6 Premium for Pol2 is $14221.2 Premium for Pol3 is $582391 Premium for Pol4 is $220384
How come the code for two decimal places is working for my output to command prompt but not my output to the text file?
This program has to convert an unsigned binary number into a decimal number. No matter what binary number I enter, however, it always outputs that the decimal number is 0.
My code is as follows:
#include <iostream> #include <cmath> #include <algorithm> using namespace std; int main() { string binarynumber; cout << "Enter an unsigned binary number up to 32 bits." << endl;
[Code] ....
And my output:
Enter an unsigned binary number up to 32 bits. 00001111 That number in decimal is 0
The output should have shown the binary number in decimal to be 15, and I cannot find my error.
I'm a student. I've complete an exercise where the goal is to parse some user input to output phone numbers using EXACTLY this style (not including the quotes): "1-888-8888".
Some rules that I've set for my parser are,
1) the phone number can be mixed in with other text, e.g. "My number is 38888888" or "1asdfk8888888" and
2) the first number found must be a valid calling code (1-9).
I wanted the parser to be flexible. Is this nesting too deep?
std::string format_phone_num(std::string &s) { std::string formatted_num = ""; bool call_code_found = false; short num_count = 0; for (unsigned int i = 0; i < s.length(); i++)
I have been given an assignment to make a code to read some text nd display all the words nd the number of times they appear in another file or as output without displaying the repeating words. I made the code but its not giving any output.
Write a C++ application program to accept a signed decimal integer as input and output the equivalent 2s complement version in 16-bit binary. Include a space between every four bits in the output string. The input will only be processed by the application if it falls in the valid range that can be represented in 2s complement format with 16 bits. The range of a decimal number from - to + is -32768 to 32767.
Now I have the binary numbers printed out in my code, but I don't know how I can covert them into to decimal.
#include <iostream> #include <iomanip> #include <string> #include <cmath> using namespace std; int main() { int numberOfDigits; int numberOfRows; char flag;
So I am trying to write a program that converts roman numerals into decimal numbers. I so far have come up with:
Code: #include <stdio.h> #include <ctype.h> // importing the tolowerfunction //variables int decimal, total; char numeral[];
[Code] .....
But each time I compile it, it times out as if it were hitting an infinite loop. I have a feeling that I am not passing an individual character to the roman_to_decimal function but am unsure why.
Write a program which stores 10 decimal numbers in an array. For these numbers accept input from the users. Once the array is populated do the following:
Display each elements of the array Display the sum of all the elements of array
Write a program which stores 10 decimal numbers in an array. For these numbers accept input from the users. Once the array is populated do the followings:
Display each elements of the array Display the sum of all the elements of array