can any one help me plz .! =(

Joined
Apr 9, 2010
Messages
3
Reaction score
0

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:
1  

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:




 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top