I have started to solve them but no use, im a beginner :o
with easy solution please,i will be greatful.. I hope that im didn't ask to much.

Q1)Write a program that read two integer and determined and prints if the first is a multiple of the second? {Hint: Use the modulus operator.} ?

Q2)(Hypotenuse) Define a function hypotenuse that calculates the length of the hypotenuse of the a right triangle when the other two sides are given. Use this function in a program to determine the length of the hypotenuse for each of the triangles shown below. The function should take two double arguments and return the hypotenuse as a double.

Triangle Side 1 Side 2
1 3.0 4.0
2 5.0 12.0
3 8.0 15.0

Q 3) Write a function multiple that determines for a pair of integers whether the second is a multiple of the first. The function should take two integers and return true if the second is a multiple of the first, false otherwise. Use this function in a program that inputs a series of pairs of integers.

Q 4) Write a program that inputs a series of integers and passes them one at a time to function even, which uses the modulus operator to determine whether an integer is even. The function should take an integer and return argument true if the integer is even and false otherwise.


Im new just saw the site rushed to to post these questions (im sorry)

Im studying (C++ how to program )

becouse i have other questions based on these i can solve others.

any hint on each question how to begin with... i have exams tomorrow ><

any hint on each question how to begin with... i have exams tomorrow ><

Better late than never, eh? ;)

Hints? OK:

Q1)Write a program that read two integer and determined and prints if the first is a multiple of the second? {Hint: Use the modulus operator.} ?

Read about the % operator.

Q2)(Hypotenuse) Define a function hypotenuse that calculates the length of the hypotenuse of the a right triangle when the other two sides are given. Use this function in a program to determine the length of the hypotenuse for each of the triangles shown below. The function should take two double arguments and return the hypotenuse as a double.

Triangle Side 1 Side 2
1 3.0 4.0
2 5.0 12.0
3 8.0 15.0

Check out the equation of a hypotenuse, and look at the sqrt() function in the header cmath

Q3) Write a function multiple that determines for a pair of integers whether the second is a multiple of the first. The function should take two integers and return true if the second is a multiple of the first, false otherwise. Use this function in a program that inputs a series of pairs of integers.

See Q1

Q4) Write a program that inputs a series of integers and passes them one at a time to function even, which uses the modulus operator to determine whether an integer is even. The function should take an integer and return argument true if the integer is even and false otherwise.

Also see Q1

This for Q2) really is it correct ? but other questions i need more hints or give me a solution for the difficult one and i try the others :( please,

# include <iostream>
#include <math.h>

using namespace std;

double hypotenuse (double, double);

void main ()
{
    double leng_hypot,side1,side2;
    
    cout<<"Enter Enter the two sides of the right triangle= ";
    cin>>side1>>side2;
    
    leng_hypot= hypotenuse (side1,side2);
    
    cout<<"\nThe length of the right triangle= "<<leng_hypot<<"\n\n";
    system("pause");
}

double hypotenuse (double side1,double side2)

{
       return sqrt((side1*side1) + (side2*side2));
}

These questions are very important, i think they will come on the exam :((

only these swear i wont bother you again or ask again please

You have to try to find the answers by yourself, how are you going to learn otherwise? We're here to help, not to give answers.
The code that you used for Q2 works. I don't know how your teacher requires but ussually int main() is standard. You also typed "Enter" for your prompt twice, not that any of those will affect the way your program runs. I would also recommned using cin.get() instead of system("pause").
Now for the other ones, have you taken the time to research what the % operator does? I would help you more if you still don't understand what it does or don't understand how to do a certain process in the questions, but first go look up what the % operator does, it should help you for the rest of the problems.

Ok I read but couldnt find relation between it and other questions.

It gave two condition either true or false (1 or 0) then....

Not quite. The % gives you the remainder of a division, like when you did long division and didn't use decimals for an answer when you were in middle school. For example, 25%5=0 because nothing remains, 25%4=1 because 6*4=24, remaining 1, 25%3=1 because 3*8 is 24, again remaining 1, and so on. Try to figure out a way to use this with some if statements, and that should give you the ability to solve your problems.

It gave two condition either true or false (1 or 0) then....

Have you tried this in a function?:

return( first_number % second_number == 0 );

Give me more explaination, pls

if((a%b)==0){multiple}
else{not multiple}

examples:
6%3 = 0
5%3 = 2
21%7 = 0
24%7 = 3

Give me more explaination, pls

You will have to modified for C++ in the main fuction, but this is
how I would do it in C

#include <stdio.h>

int check_it(int n1, int n2)
{
    return(n1 % n2 == 0);
}

int main(void)
{
    int num1 = 10;
    int num2 = 2;
    
    if(check_it(num1, num2))
    {
        printf("%d is a multiple\n", num2);
    }
    else
    {
        printf("%d is not a multiple\n", num2);
    }
    
    getchar();
    return 0;
}

Thank you it looks easy when someone solve it really thank you,

And what is the differ between Q1) and Q3 , Q4
how can i enter a series of integer at one time ?

pls just these questions :'(

Do I need to insert While for loop on Q4 ?

last question, pls

Do I need to insert While for loop on Q4 ?

last question, pls

That depends how you want to get the integers to be analized.
You can write a while loop asking to enter an integer every time until the user enters a sentinel or a stablished preselected key that will stop the loop. Or if you declare an integer array of selected numbers, you could use a for loop. The code below is a example of the latest:

#include <stdio.h>

int even(int integer)
{
    return(integer % 2 == 0);
}

int main(void)
{
    int i;
    int numbers[] = { 55, 66, 76, 45, 2, 4, 3 };
    
    for(i = 0; i <= 6; i++)
    {
        if(even(numbers[i]))
        {
            printf("%d is even\n", numbers[i]);
        }
    }
    getchar();
    return(0);
}

I'm haven't took array yet :'(
can you write it on while loop

but you specified the numbers, what if i want to enter nth number ?

I'm haven't took array yet :'(
can you write it on while loop

but you specified the numbers, what if i want to enter nth number ?

Could you at least show me what you have tried so far?. I think I have
writen too much of you assigment. I'm trying to help you to get these
concepts, but sorry I want you to try and learn.:-|. You should at least
know how to create the function to check for even numbers. Also you should
know already how to call that function inside a while loop, and how to
ask for a number from the use inside that loop.

Thank you Aia very vey much, you helped me a lot and also for other ppls . I will try others by my self.


respect,

Thank you Aia very vey much, you helped me a lot and also for other ppls . I will try others by my self.

respect,

When you get your code going please posted, specilally if you get stuck
in anything. People will be willing to help you if you try first.

You're welcome.

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.