Adding 2 difft int to form a number


 
Thread Tools Search this Thread
Top Forums Programming Adding 2 difft int to form a number
# 1  
Old 05-12-2009
Adding 2 difft int to form a number

got 1 problem..
can someone help me wit the logic?



Money Money :Smilieperator+(const Money &rhs)const
{

Money temp;

temp.a = a+rhs.a;
temp.b = b+rhs.b;

return temp;

}//end



i got 2 number e.g 6.2 and 3.8
6 is int a
2 is int b

3 is int a
8 is int b

how can i add them up so that they become 10?

anyone can help?
# 2  
Old 05-12-2009
In this case too sscanf() can be used to parse the floating point numbers and after that add the two numbers on the rhs of the decimal point to get 10.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Decimal conversion number of the form x.xx to 0x.xx, sed?

Hello I have a file of the form ... num 0.12 num num num 25.53 num num num 7.82 num num ...... and I want to convert the 2nd field of each line adding a "0" at the numbers >= 0 and < 10 so the output will have the form: ... num 00.12 num num num 25.53 num num num 07.82 num... (10 Replies)
Discussion started by: phaethon
10 Replies

2. Shell Programming and Scripting

Taking largest (negative) number from column of coordinates and adding positive form to every other

Hello all, I'm new to the forums and hope to be able to contribute something useful in the future; however I must admit that what has prompted me to join is the fact that currently I need help with something that has me at the end of my tether. I have a PDB (Protein Data Bank) file which I... (13 Replies)
Discussion started by: crunchgargoyle
13 Replies

3. Programming

Handle int listen(int sockfd, int backlog) in TCP

Hi, from the manual listen(2): listen for connections on socket - Linux man page It has a parameter called backlog and it limits the maximum length of queue of pending list. If I set backlog to 128, is it means no more than 128 packets can be handled by server? If I have three... (3 Replies)
Discussion started by: sehang
3 Replies

4. Shell Programming and Scripting

changing number in bash (number is in form of string)

I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as name1:name2:name3:1 when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so... (3 Replies)
Discussion started by: Learnerabc
3 Replies

5. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies

6. Shell Programming and Scripting

exporting number into .csv file in text form (no other extra charc) from shell script

I have written a k shell program which is executing a sql and exporting data in numeric form like 0412323444 into .csv file. the problem i am facing is that , the data is coming in excel formatted in scientific form like 4.1+E08,while my requirement is to store data as such 0412323444 in excel ( no... (5 Replies)
Discussion started by: Deepak_Rastogi
5 Replies

7. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

8. Shell Programming and Scripting

comparing float with int / number

Hi all, I'm looking to modify a script to check disk space usage. Here is the code at the moment: # # The control file, MONITOR_DISK_SPACE, must be in the format ... Drive:;threshold_percentage # eg. # C:;95 # D:;98 # E:;90 # # For each line in the control file (MONITOR_DISK_SPACE)... (2 Replies)
Discussion started by: lelliott
2 Replies

9. UNIX for Advanced & Expert Users

Changing Unix form to Microsoft Word form to be able to email it to someone.

Please someone I need information on how to change a Unix form/document into a microsoft word document in order to be emailed to another company. Please help ASAP. Thankyou :confused: (8 Replies)
Discussion started by: Cheraunm
8 Replies
Login or Register to Ask a Question