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...
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;
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.
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
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
Create a program that will ask the user to enter a decimal value (1-999999) then display its corresponding binary numbers. Repeat this process until the value entered is equal to 0. Use the following Function Prototype:
void BinCodes(int value); Sample Input/Output: Enter a Decimal: 35 Binary: 100011 Enter a Decimal: 184 Binary: 10111000 Enter a Decimal: 0
I am trying to make a program that will convert a list of binary numbers from a file into decimal and print the decimal to the screen. I have no problem doing the conversion, the problem comes up when our teacher wants the input file in a format as such:
3 10110101 11111111 10101010
The first number is supposed to tell the program how many different 8bit strings it is going to have to convert, and then the following lines are those binary numbers.
I am not very experienced with file inputs, and I know how to open files and read lines in.. The problem is, how to say "ok the first line says 3, so now I have to convert the next 3 lines" . I am assuming it is just a simple loop that I am missing....
I would like to know if there's a way to show at least two numbers in the output instead of just one. For example: instead of showing 4 it shows 04. Its for a console application.
This is one part of my program, I need a loop that checks through the input(specifically the agent numbers) and then outputs the agent numbers that aren't in the input, from 1 to 20(because there should only be 20 agent).
the first numbers are the agent numbers so 1 , 2 ,15 are agent numbers and out output for agents who didnt participate are : 2 , 5 , 6 , 7, 8, 9, 10 , 11 , 14 , 16 , 17 ,19 20
this is the code ive wrote but its not working.
void not_part() { ins.open(in_file); int i=0; int sum=0; cout<<"AGENTS WHO DID NOT PARTICIPATE IN THE CAMPAIGN"<<endl; cout<<fixed<<showpoint;
This is one part of my program, I need a loop that checks through the input(specifically the agent numbers) and then outputs the agent numbers that aren't in the input, from 1 to 20(because there should only be 20 agent).
the first numbers are the agent numbers so 1 , 2 ,15 are agent numbers and out output for agents who didnt participate are : 2 , 5 , 6 , 7, 8, 9, 10 , 11 , 14 , 16 , 17 ,19 20
This is the code:
void not_part() { ins.open(in_file); int i=0; int sum=0; cout<<"AGENTS WHO DID NOT PARTICIPATE IN THE CAMPAIGN"<<endl; cout<<fixed<<showpoint;
Write a program that reads in ten whole numbers and that output the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the ten numbers just once each and the user can enter them in any order.
Your program should not ask the user to enter the positive numbers and the negative numbers separately. Assume the user will type integer numbers.
this is what i got but it wont run saying there is an error
#include<iostream>; using namespace std; int main() { int count=0; int num; int positive=0; int negative=0;