Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   C - Write algorithm (http://www.go4expert.com/forums/c-write-algorithm-t3807/)

wahsunny 9Apr2007 17:05

C - Write algorithm
 
Q. 1 Write algorithm for the following :

a) to check whether an entered number is odd / even.

b) to calculate sum of three numbers.

shabbir 9Apr2007 18:57

Re: C - Write algorithm
 
Would you post some code that you have attempted for the same.

bughunter2 10Apr2007 05:04

Re: C - Write algorithm
 
Code:

int is_numeven(int number)
{
        if(!(number % 2)) /* Mod
                return true;

        return false;
}

int SumThreeNumbers(int num1, int num2, int num3)
{
    return num1+num2+num3;
}

The first example divides the given parameter by the smallest even number that can be divided with and then it checks the remainder. (correct me if I'm wrong)

The second example should speak for itself.

bughunter2 10Apr2007 05:06

Re: C - Write algorithm
 
Ignore the comment '/* Mod' I didn't finish the comment.

DaWei 10Apr2007 05:28

Re: C - Write algorithm
 
I would suggest that producing someone's work for them is not in their best interests, when it comes to learning. It is, in fact, discouraged in the "Before you make a query" thread:
Quote:

10) Dont put your complete assignment. You should not be putting your complete assignments like I need <Some program> can you help me.
It is better for the poster to post attempts and ask for help, or for the respondent to perhaps provide some pseudo-code or design guidelines.

You may think otherwise, of course.

bughunter2 10Apr2007 05:43

Re: C - Write algorithm
 
You're right, but the topic starter can ask questions after reading the small example. I mean, I just wrote a few lines of code for him and explained it a little bit.

Not sure what I'm doing wrong, however I agree to your point that it might be better if I'd have just given a few guidelines or references to documents.

DaWei 10Apr2007 08:07

Re: C - Write algorithm
 
Also, please put code you write into code tags to preserve its indentation and formatting. I heartily recommend reading the "Before you make a query" thread, linked at the upper right of this page.

There is nothing wrong with writing code or rewriting code -- provided that the learner is showing that he or she is putting forth effort to learn. Getting one's homework done entirely for free (or even for a price) is doing a disservice to the poster and to potential employers and coworkers who have to discover that the supposed skills were not actually learned.

bughunter2 10Apr2007 08:18

Re: C - Write algorithm
 
I didn't look into it that way, I guess you're right. Thank you.

(btw on the code tags, I saw I should have added them but couldn't edit my post - where is the edit button?)

shabbir 10Apr2007 08:29

Re: C - Write algorithm
 
Quote:

Originally Posted by bughunter2
I didn't look into it that way, I guess you're right. Thank you.

(btw on the code tags, I saw I should have added them but couldn't edit my post - where is the edit button?)

I have done that for you and to edit your own posts you need to have minimum no of posts before you can do that.

wahsunny 10Apr2007 10:40

Re: C - Write algorithm
 
Thank you all....


All times are GMT +5.5. The time now is 21:34.