Thread: Hello and Help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Hello and welcome
    6) String literals are between double quotes, not a mix of quotes and square brackets.

  2. #2
    Registered User [Z-D]'s Avatar
    Join Date
    Oct 2006
    Posts
    37
    Thank you, but

    Okay then,.... I'll just read up more...

    1. Whats the difference between <iostream> and <iostream.h>? How do we know when t use them? (MAN! My lecturer sucks!!)
    3. Actually I wasn't thaugh how to use char of string yet... I just read up and tried experimenting in the Comp Lab.
    5. sorry,... i don't really understand...
    6. screwed up there....


    To let you have an Idea on how n0000b I am...

    I was happy enough to answere this question.
    Write a programme that can convert temperature from RFarenheit to Celcius and viceversa:
    Code:
    #include <iostream>
    
    main()
    {
    	int ConversionChoice, F, C;
    
    	cout << "Press '1' for F to C, and '2' for C to F:";
    	cin >> ConversionChoice;
    
    	if (ConversionChoice == 1)
    	{cout << "Enter temperature in degree Farenheit:";
    	cin >> F;
    
    	C = (F - 32) / 1.8; 
    
    	cout << "Temperature in Degree Celcius:" << C << endl;
    	}
    
    	if (ConversionChoice == 2)
    	{cout << "Enter temperature in degree Celcius:";
    	cin >> C;
    
    	F = 1.8*C + 32;
    
    	cout << "Temperature in Degree Farenheit:" << F << endl;
    	}
    
    	else if (ConversionChoice != 2, ConversionChoice != 1)
    	{cout << "What do you think you're doing? None of the conversion was chosen!" << endl;
    	}
    
    	return 0;
    }
    I was able to do this....

    For the question that I was struggling with, I think I could do something like tis:
    Code:
    #include <iostream.h>
    
    main ()
    {
    	int name;
    
    	cout << "Choose a family member:";
    	cout << "Press '1' for [name1]";
    	cout << "Press '2' for [name2]";
    	cout << "Press '3' for [name3]";
    	cout << ....
    	....
    	....etc.
    	cin >> name;
    
    	if (name = 1);
    	{cout << "Relation: Father";
    	cout << "Height: bla bla bla";
    	cout << "weight: bla blab la...;
    	cout << ....
    	....
    	.....etc ... << endl;
    	}
    
    	if (name = 2);
    	{cout << "Relation: Mother";
    	cout << "Height: bla bla bla";
    	cout << "weight: bla blab la...;
    	cout << ....
    	....
    	.....etc ... << endl;
    	}
    
    
    	else if ( name != 1, name != 2, name != 3, ....etc.... );
    	{cout << "invalid number.. bla blab la" << endl;
    
    	return 0;
    }
    But this way im using integers to represent the family members. I don't know how to do something similar but using characters instead of integers.

    I don't know wheter this would be breaking ther forum rules, but could someone show me an example of using if for words?... I'll figure out the rest by myself

Popular pages Recent additions subscribe to a feed