Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   can any one help me plz .! =( (http://www.velocityreviews.com/forums/t720086-can-any-one-help-me-plz.html)

S A R A` 04-09-2010 04:25 PM

can any one help me plz .! =(
 

Hi all :ciao:

how r u .?

i want help to solve this program in c++

*******************
1- Write a program that accept an integer number from the user and print out all the divisors of the number. (Use while or do..while to implement the repetition.)

for example:

Code:

Enter an integer number: 30

The divisors:
1 2 3 5 6 10 15

Press any key to continue

Code:

Enter an integer number: 5

The divisors:


Press any key to continue

AND THIS MY ATTEMPTS :(

Code:

#include<iostream.h>
void main()

{
        int x;
        int i=1;

       

        cout<<"Enter an integer number: ";
        cin>>x;
        cout<<"\n";
    cout<<"The divisors: "<<"\n";
       
        while(x%i==0)
        {
               
        cout<<i;
                cout<<"\t";
                i++;
               

        }
       



}

***************************
2-Using switch statement writes a program that print out the following menu:
Code:

***************************
1- Read two numbers.
2- Define large.
3- One multiple of other.
4- Exit.
***************************
Enter your choice:

Description of the options:
- Option 1: always start with this option to allow the user enter two integer numbers.
- Option 2: compare both numbers and print out a message with the larger one.
- Option 3: check if the first number is multiple of the second and vice versa.
- Option 4: the user will be able to repeat choosing options until the user choose this option which ends the program. One statement will be in this case which is exit(0). Note: include the file <stdlib.h> to allow you to use the exit function.

AND THIS MY ATTEMPTS ,BUT IS NOT COMPLEATE SOLVE BECUSE I DO NOT KNOW HOW CAN I DO OPTION 2 >< :(

Code:

#include<iostream.h>
#include<stdlib.h>
void main()

{
        int number;
        int x;
        int y;

        cout<<"*************************";
        cout<<"\n1- Read two numbers.";
        cout<<"\n2- Define large.";
        cout<<"\n3- One multiple of other.";
        cout<<"\n4- Exit.";
        cout<<"\n*************************\n";

        cout<<"Please enter first number : ";
        cin>>x;
        cout<<"\n";
        cout<<"Please enter second number : ";
        cin>>y;
        cout<<"\n";

        cout<<"Please choose options from the menu : ";
        cin>>number;

        switch(number)
        {
        case 1:cout<<"your first number is : "<<x<<"\n";
                cout<<"your secon number is : "<<y<<"\n";
                break;

        case 2:
                if(x<y)
                {
                          cout<<"The first number is larger.!";
                }


      if(y<x)
                {
                cout<<"The second number is larger.!";
                }

       

        }


help me plz .!
bay :ciao:





S A R A` 04-09-2010 07:53 PM

any one plz =( .!

S A R A` 04-10-2010 04:59 PM

23 viwes & no answer .!

PLZ =( .!


All times are GMT. The time now is 12:01 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.