I received help here from experts nice enough to help me out so i am posting all my assignments.. Maybe someone will find the useful and leave from them.
Basic, for beginners.
question: Develop a program that prompts the user to enter two (2) numbers. The program will display the numbers based on these conditions:
a. if the first number is less than the second number the program will perform a swap operation on these two numbers and display them, otherwise
b. the program will display the numbers as entered.
Code:
#include<iostream>
using namespace std;
int main(){
//Declaration of variables
int number1 = 0, number2 = 0, temp = 0;;
cout <<"Enter Two Numbers: ";
cin >> number1 >> number2;
if(number1 < number2){ /*Conditional statement to check if
the first number is smaller than the second number*/
/*Swap operations*/
temp = number1;
number1 = number2;
number2 = temp;
}//end if
/*Output statements for the first and second number*/
cout <<"The first number is " <<number1 <<endl;
cout <<"The second number is " <<number2 <<endl;
system("pause");
return 0;
}