Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,394 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,148 people online right now. Registration is fast and FREE... Join Now!




Absolute Number

 
Reply to this topicStart new topic

Absolute Number, Help with absolute number of a double

vipx9x
23 Oct, 2006 - 11:22 AM
Post #1

New D.I.C Head
*

Joined: 23 Oct, 2006
Posts: 20


My Contributions
Could you help me in these codes.
see the attachment.



Attached File(s)
Attached File  help_me_please.doc ( 31k ) Number of downloads: 78
User is offlineProfile CardPM
+Quote Post

Vextor
RE: Absolute Number
23 Oct, 2006 - 11:54 AM
Post #2

D.I.C Regular
Group Icon

Joined: 22 May, 2002
Posts: 288



Thanked: 1 times
Dream Kudos: 25
My Contributions
</DIC> members don't do homework assignements. Instead, give it a shot and post your attempt on the boards and we'll give you some help and guidance. But you have to make that attempt yourself.

Thanks,
Vextor
User is offlineProfile CardPM
+Quote Post

vipx9x
RE: Absolute Number
25 Oct, 2006 - 10:44 AM
Post #3

New D.I.C Head
*

Joined: 23 Oct, 2006
Posts: 20


My Contributions
I tried a lot.
I want to get the benefits nothing more.
I hope that all members will help me.

regards,
vipx9x

This post has been edited by vipx9x: 25 Oct, 2006 - 10:54 AM
User is offlineProfile CardPM
+Quote Post

gregoryH
RE: Absolute Number
26 Oct, 2006 - 12:20 AM
Post #4

D.I.C Regular
Group Icon

Joined: 4 Oct, 2006
Posts: 417


Dream Kudos: 50
My Contributions
QUOTE(vipx9x @ 25 Oct, 2006 - 11:44 AM) *

I tried a lot.
I want to get the benefits nothing more.
I hope that all members will help me.

regards,
vipx9x

It would help if you post your code... then we can guide you... OK
User is offlineProfile CardPM
+Quote Post

vipx9x
RE: Absolute Number
31 Oct, 2006 - 11:23 AM
Post #5

New D.I.C Head
*

Joined: 23 Oct, 2006
Posts: 20


My Contributions
I did this
CODE

#include<stdio.h>
#include<math.h>

double absolute(double absolute_value[])  
{
int size;
double i;
for(i=1; i<size;i++){
if (absolute_value[i] >= 0) absolute_value[i];  
return -absolute_value[i]; }
return absolute_value[i];}

int main()
{
int size;
double i, actual_data[1],absolute_value[1];

printf("Enter the number of elements that you need:\n",size);
scanf("%d",&size);

printf("Please,Enter the numbers:\n");
for(i=0.0; i<=size;i=i+1.0){
scanf("%lf",&actual_data[i]);
}
absolute(actual_data[i]);
printf("   Actual Data\t |Absolute Value|");
for(i=0.0; i<=size;i=i+1.0){
printf("\n\t%lf\t\t%lf\t",actual_data[i],absolute(actual_data));}
return 0;
}

But there is a mistake in this could it does not accept a double numbers(the arrays should be double).
User is offlineProfile CardPM
+Quote Post

Dark_Nexus
RE: Absolute Number
31 Oct, 2006 - 03:47 PM
Post #6

or something bad...real bad.
Group Icon

Joined: 2 May, 2004
Posts: 1,309



Thanked: 3 times
Dream Kudos: 625
My Contributions
CODE

double i, actual_data[1],absolute_value[1];


you've declared a standard double type variable, followed by 2 double arrays with a size of 1. this is pointless. these arrays can only contain a single number. you are better off to work with standard double types.
User is offlineProfile CardPM
+Quote Post

Xing
RE: Absolute Number
31 Oct, 2006 - 04:15 PM
Post #7

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
Few More Points
1. Look at the array subscripts. They should be integers.
2. Take array larger than 1 and pass the size to absolute function.
User is offlineProfile CardPM
+Quote Post

vipx9x
RE: Absolute Number
1 Nov, 2006 - 07:38 AM
Post #8

New D.I.C Head
*

Joined: 23 Oct, 2006
Posts: 20


My Contributions
QUOTE(Dark_Nexus @ 31 Oct, 2006 - 04:47 PM) *

CODE

double i, actual_data[1],absolute_value[1];


you've declared a standard double type variable, followed by 2 double arrays with a size of 1. this is pointless. these arrays can only contain a single number. you are better off to work with standard double types.



What did you mean by standard double types.

This post has been edited by vipx9x: 1 Nov, 2006 - 07:39 AM
User is offlineProfile CardPM
+Quote Post

vipx9x
RE: Absolute Number
1 Nov, 2006 - 10:36 AM
Post #9

New D.I.C Head
*

Joined: 23 Oct, 2006
Posts: 20


My Contributions
Dear friends,

I fixed the problem of entering the numbers corectely
but the function double absolute(double absolute_value[]) has amistake that it takes the first number only and repeat it for the others numbers.


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:42AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month