a)         Write an algorithm to add and multiply two large integers, which cannot be 
represented by built-in types.
b)         Write a “c” function to find recursively the maximum and minimum element of 
    an array A of size “n” elements. Find also the number of comparisons required for 
this.





a)         Write an algorithm to add and multiply two large integers, which cannot be 
represented by built-in types.
b)         Write a “c” function to find recursively the maximum and minimum element of 
    an array A of size “n” elements. Find also the number of comparisons required for 
this.

Example of b

#include <stdio.h>

int Highest (const int l, const int r)
{
    return ((l > r) ? l : r);
}

int Lowest (const int l, const int r)
{
    return ((l < r) ? l : r);
}

void FindMinMax (const int A[], const int n, int* const min, int* const max)
{
    int curMin = 0, curMax = 0;

    if (n == 1)
    {
        (*min) = A[0];
        (*max) = A[0];
    }
    else if (n > 1)
    {
        curMin = A[0];
        curMax = A[0];

        FindMinMax(A + 1, n - 1, min, max);

        (*min) = Lowest ((*min), curMin);
        (*max) = Highest((*max), curMax);
    }
}

int main(void)
{
    int example[] = { 23, 488, 1, 2930, 99, 102 };
    int low, high;

    FindMinMax(example, sizeof(example) / sizeof(int), &low, &high);
    printf("lowest: %d, highest: %d\n", low, high);

    return 0;
}

Found "a" too boring so didn't bother doing that.. Could maybe help if you start on it so I only have to finish/correct it.

commented: The OP's question falls under our homework rule. -2
commented: not even single effort seen , yet you give the code instead of advices +0

Heeee! if you knew whom you are responding to, you wouldn't mind even teaching him 1+1 =2. I am a complete "newbie" to programming, started a few weeks ago. Its only that I am very much interested in grasping these things as much and as fast as I can. I know it takes time to learn, but I try!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.