Code:
explain in details
#include<iostream.h>
#include <math.h>
#include<process.h>
#include<conio.h>
// prototype for the the functions
void getVect(int &s, int &e );
void addition();
void subtraction();
void multiplication();
void length();
int main() // function main begins program execution
{
// let the user know about the program
clrscr();
cout << "\n\n\t program that describes something about vectors.";
char choice;
do{
cout << "\n\n \t\t\t 'M E N U' ";
cout << "\n\n\t\tAddition : A";
cout << "\n\t\tSubtraction : S";
cout << "\n\t\tMultiplication : M";
cout << "\n\t\tLength : L";
cout << "\n\t\tQuit : Q";
cout << "\n\n\t\tEnter your choice ";
cin >> choice;
//ff convert the choice to lower case
if ( choice < 97)
choice +=32;
switch ( choice )
{
case 'a' : addition();
break;
case 's' : subtraction();
break;
case 'm' : multiplication();
break;
case 'l' : length();
break;
case 'q' : //ff pause the screen
cout << "\n\n\t";
exit(0);
break;
default : cout << "\n\n\tYou have entered wrong choice";
} //ff end switch
} while (choice !='q'); // end do-while
return 0; //ff indicate program executed successfully
} //ff end of function, main
void getVect( int &f, int &s )
{
//fix" prompt and read the values into the vector
cout << "\n\tEnter the values for the vector:";
cout << "\n\tFirst Component : ";
cin >> f;
cout << "\tSecond Component : ";
cin >>s;
cout << "'\tThe vector is [ " << f << " , " << s << " ]";;
} // end function getVect
void addition()
{
//ff declare the variables
int a1, a2, b1, b2 ;
//ff get the values for the first vector
getVect( a1, a2 );
//ff get the values for the second vector
getVect( b1, b2 );
//ff do the addition
cout<< "\n\n\tThe sum is [ " << ( a1 + b1 )<< "," << ( a2 + b2 ) << "]" ;
} //ff end function addition
void subtraction()
{
// declare the variables
int al, a2, bl, b2 ;
//ff get the values for the first vector
getVect( al, a2 );
//ff get the values for the second vector
getVect( bl, b2 );
//ff do the subtraction
cout << "\n\n\t‘I‘he difference is [ " << ( al - bl )<<", "<<(a2-b2)<<"]";
} //fs'] end function subtraction
void multiplication()
{
//fix" declare the variables
int al, a2, bl, b2 ;
//fra" get the values for the first vector
getVect(al, a2) ;
//fra" get the values for the second vector
getVect( bl, b2 );
//ff do the multiplication
cout << "\n\n\tThe product is [ " << ( al * bl )<< ", " << (a2 * b2) <<"]";
}// ff end function multiplication
void length()
{
//ff declare the variables
int a1, a2;
float len;
//ff get the values for the vector
getVect(a1,a2);
//fir'] find the length
a1=a1*a1;
a2=a2*a2;
len=a1+a2;
len=sqrt(len);
cout << "\n\n\tlength is "<<len;
}
// end function length
basharat is online now
basharat
View Public Profile
Send a private message to basharat
Find More Posts by basharat
Add basharat to Your Contacts
Yesterday, 07:07 PM #9
basharat
Registered User
Join Date: May 2008
Posts: 4 Code:
#include<iostream.h>
#include <math.h>
#include<process.h>
#include<conio.h>
// prototype for the the functions
void getVect(int &s, int &e );
void addition();
void subtraction();
void multiplication();
void length();
int main() // function main begins program execution
{
// let the user know about the program
clrscr();
cout << "\n\n\t program that describes something about vectors.";
char choice;
do{
cout << "\n\n \t\t\t 'M E N U' ";
cout << "\n\n\t\tAddition : A";
cout << "\n\t\tSubtraction : S";
cout << "\n\t\tMultiplication : M";
cout << "\n\t\tLength : L";
cout << "\n\t\tQuit : Q";
cout << "\n\n\t\tEnter your choice ";
cin >> choice;
//ff convert the choice to lower case
if ( choice < 97)
choice +=32;
switch ( choice )
{
case 'a' : addition();
break;
case 's' : subtraction();
break;
case 'm' : multiplication();
break;
case 'l' : length();
break;
case 'q' : //ff pause the screen
cout << "\n\n\t";
exit(0);
break;
default : cout << "\n\n\tYou have entered wrong choice";
} //ff end switch
} while (choice !='q'); // end do-while
return 0; //ff indicate program executed successfully
} //ff end of function, main
void getVect( int &f, int &s )
{
//fix" prompt and read the values into the vector
cout << "\n\tEnter the values for the vector:";
cout << "\n\tFirst Component : ";
cin >> f;
cout << "\tSecond Component : ";
cin >>s;
cout << "'\tThe vector is [ " << f << " , " << s << " ]";;
} // end function getVect
void addition()
{
//ff declare the variables
int a1, a2, b1, b2 ;
//ff get the values for the first vector
getVect( a1, a2 );
//ff get the values for the second vector
getVect( b1, b2 );
//ff do the addition
cout<< "\n\n\tThe sum is [ " << ( a1 + b1 )<< "," << ( a2 + b2 ) << "]" ;
} //ff end function addition
void subtraction()
{
// declare the variables
int al, a2, bl, b2 ;
//ff get the values for the first vector
getVect( al, a2 );
//ff get the values for the second vector
getVect( bl, b2 );
//ff do the subtraction
cout << "\n\n\t‘I‘he difference is [ " << ( al - bl )<<", "<<(a2-b2)<<"]";
} //fs'] end function subtraction
void multiplication()
{
//fix" declare the variables
int al, a2, bl, b2 ;
//fra" get the values for the first vector
getVect(al, a2) ;
//fra" get the values for the second vector
getVect( bl, b2 );
//ff do the multiplication
cout << "\n\n\tThe product is [ " << ( al * bl )<< ", " << (a2 * b2) <<"]";
}// ff end function multiplication
void length()
{
//ff declare the variables
int a1, a2;
float len;
//ff get the values for the vector
getVect(a1,a2);
//fir'] find the length
a1=a1*a1;
a2=a2*a2;
len=a1+a2;
len=sqrt(len);
cout << "\n\n\tlength is "<<len;
}// end function length
Explain each and every statement and what functions insted of the functions are used and what other codes are used inted of that used in the program
clerify the steps