C++ program

This is a discussion on C++ program within the C++ Programming forums, part of the General Programming Boards category; This is the program....I don't know how to start it....any help would be helpful.!!!! Write a short code that promts ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    6

    C++ program

    This is the program....I don't know how to start it....any help would be helpful.!!!!

    Write a short code that promts the user to enter any 3 by 3 matrix, and then calculates its inverse.!!

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    Heh, perhaps you should reread your sig. Anyway, what have you got so far?
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    82
    Here's a good place to start:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() {
      // code here
      // also here
    }
    Claus Hetzer
    Compiler: Borland 5.5 (on Windows)
    Solaris CC (on Unix)
    Known Languages: C++, MATLAB, Perl, Java

  4. #4
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    well heres an example of taking in three values, might help.

    Code:
    #include <iostream.h>
    
    int main()
    {
       int value1, value2, value3;
       cout<<"Enter a value: ";
       cin>>value1;
       cout<<"Enter a value: ";
       cin>>value2;
       cout<<"Enter a value: ";
       cin>>value3;
    
       cout<<"The values u enterd were "<<value1
              <<" "<<value2<<" "<<value3<<"."<<endl;
    
       return 0;
    }

  5. #5
    tetra
    Guest

    try this.

    use a multi- dimensional array...


    so instead of having all those values, you could pass them through a function as well.



    so something like this to start you off.

    int matrix ( int [] , int[], int[]);


    int main ()

    {

    cout<<" Enter three values for horizontal array.";

    for ( int i = 0; i < 3 ; i ++ )

    cin>>value [ i ] ;

    then for the second dimension , you copy and paste the above code. im not writing this for you, so figure out the the function to pass the int[ ] through

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    6
    HET TETRA REMEMBER THIS.....

    "i am supposed to write a program that will assign seats on a ten seat plane. dont worry, im not asking you to write code for me im getting a little better at this but my teacher still sucks... so here is what i have.

    btw. the program asks the person to pick a number , ( 1 for first class and 2 for seoncd.) im supposed to use arrays.... so..this is what i have but it doesnt work well... any help would be appreciated emensly." -TETRA


  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    6
    I posted the code for the program...........did you ever look at IT???!!!!? Here it is again....



    did this program a few days ago....here it is...the complete program......check if it works.....



    Code:
    //air
    
    #include <iostream.h>
    
    int main()
    {
    	int plane[11]={0};
    	int choice;
    	int seatFound =1;
    	int Firstclass =1;
    	int Economy =6;
    	int people =1;
    	
    	cout<< "Please type 1 for \"First Class\"" << endl;
    	cout<< "Please type 2 for \"Economy\"" << endl;
    	cin>> choice;
    
    	while (choice != -1)
    	{
    		if(choice==1) 
    		{
    			seatFound= 0;
    			choice=1;
    			while (choice<6)
    			{
    				if(plane[choice]<1 && Firstclass <=5) 
    				{
    					seatFound=choice;
    					plane[choice] =1;//put person in seat
    					choice=33;//exit loop
    				}
    				else
    					choice ++;
    					people++;
    			}
    			if(seatFound>0)//test if seat is found
    			{
    				cout<<"Boarding Pass"<<endl;
    				cout<<"-First Class-"<<endl;
    				cout<<"Seat#" << seatFound<<endl;
    			}
    			else
    			{
    				cout << "Do you want a seat in economy? " << endl;
    				cout << "\n1 = yes , 2 = no : ";
    				cin >> choice;
    				if ( choice == 2 )
    				{
    					seatFound=0;
    					choice=2;
    					while(plane[choice]<11)
    					{
    						if(plane[choice] > 0 && Economy <= 10 )
    						{
    							plane[choice]=2; // put someone in the seat
    							seatFound=choice;
    							choice=33;
    						}
    					else 
    						choice++;
    						people++;
    					}
    		
    					if(seatFound>0) //test if seat is found
    					{
    						cout<<"Boarding Pass"<<endl;
    						cout<<"Economy Class"<<endl;
    						cout<<"Seat#" << seatFound << endl;
    					}
    				}
    				else
    				{
    					cout << "Next flight leaves in three hours..." << endl;
    				}
    			}
    	}
    		else //economy class
    		{
    			seatFound=0;
    			choice=6;
    			while(plane[choice]<11)
    			{
    				if(plane[choice] < 1)
    				{
    					plane[choice]=1; // put someone in the seat
    					seatFound=choice;
    					choice =2;
    				}
    				else 
    					choice++;
    					people++;
    			}
    		
    			if(seatFound>0) //test if seat is found
    			{
    				cout<<"Boarding Pass"<<endl;
    				cout<<"Economy Class"<<endl;
    				cout<<"Seat#" << seatFound << endl;
    			}
    			else
    			{
    				cout << "Next flight leaves in three hours..." << endl;
    			}
    		}
    
    		cout<< "Please type 1 for \"First Class\" " << endl;
    		cout<< "Please type 2 for \"Economy\" " << endl;
    	
    		cin>> choice;
    	}
    
    	return 0;
    }

    &#91;code]&#91;/code]tagged by Salem

  8. #8
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    No, you're right, I was too lazy to look at it before. I love your subject line!

  9. #9
    Registered User jawwadalam's Avatar
    Join Date
    May 2002
    Posts
    131
    Originally posted by Little Tito
    I posted the code for the program...........did you ever look at IT???!!!!? Here it is again....







    code:----------------------------------------------------------------------------

    }
    code------------------------------------------------------------------------------
    I think You must use Code Tags.. for posting codes...

    instead of using your own.. for easy posting codes

    Read this thread for help...
    http://www.cprogramming.com/cboard/s...threadid=13473
    Last edited by jawwadalam; 11-16-2002 at 07:53 PM.
    One day you will ask what more important to you..
    I will say my life..
    and You will leave me with even knowing
    that
    You are my Life (L)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21