| View previous topic :: View next topic |
| Author |
Message |
MegaForum Grandmaster Cheater
Reputation: 0
Joined: 20 Aug 2007 Posts: 558
|
Posted: Thu Oct 25, 2007 5:46 pm Post subject: C++ Problem |
|
|
Hi everyone. i am making an age converter in c++ ( all by myself! LOL)
i was wonder whats wrong with my code. im getting error for int b as
undeclared identifier. how do i link int b to cout << "Your Age:"
ty
#include <iostream>
using namespace std;
[code]
int main ()
{
int a = c;
int c = a * 7;
cin >> "Enter your age";
cout << " Your age:";
return 0;
}
|
|
| Back to top |
|
 |
Hackerdevelopment Advanced Cheater
Reputation: 0
Joined: 11 Oct 2007 Posts: 55
|
Posted: Thu Oct 25, 2007 5:49 pm Post subject: |
|
|
| You have to declare if its like a floating point,integer or text.
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Oct 25, 2007 5:52 pm Post subject: |
|
|
#include <iostream>
using namespace std;
int main ()
{
int a;
int c ;
cout << "Enter your age: ";
cin >> a;
c = a* 7;
cout << " Your age:" c;
cin.ignore();
cin.get();
return 0;
}
you can't cin a line. You use a cout then a cin
cin = c input , so your not inputting Enter you age: your cout'ing it (c output)
_________________
Last edited by HomerSexual on Thu Oct 25, 2007 5:55 pm; edited 3 times in total |
|
| Back to top |
|
 |
Hackerdevelopment Advanced Cheater
Reputation: 0
Joined: 11 Oct 2007 Posts: 55
|
Posted: Thu Oct 25, 2007 5:53 pm Post subject: |
|
|
| Wat does this do anyways?
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Oct 25, 2007 5:53 pm Post subject: |
|
|
looks like it takes your age * 7?
and where the fuck does b come into play?
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Thu Oct 25, 2007 5:55 pm Post subject: Re: C++ Problem |
|
|
Do you want to convert the age of a dog to the age of a human? (Judging by the coding you have done, that is what I think.)
| Code: | #include <iostream>
int main ()
{
int b = 0;
std::cout << "Enter the dogs age: ";
std::cin >> b;
std::cout << "Age in human years: " << (b * 7) << std::endl;
std::cin.ignore();
std::cin.get();
return 0;
} |
|
|
| Back to top |
|
 |
MegaForum Grandmaster Cheater
Reputation: 0
Joined: 20 Aug 2007 Posts: 558
|
Posted: Thu Oct 25, 2007 6:03 pm Post subject: Re: C++ Problem |
|
|
| Flyte wrote: | Do you want to convert the age of a dog to the age of a human? (Judging by the coding you have done, that is what I think.)
| Code: | #include <iostream>
int main ()
{
int b = 0;
std::cout << "Enter the dogs age: ";
std::cin >> b;
std::cout << "Age in human years: " << (b * 7) << std::endl;
std::cin.ignore();
std::cin.get();
return 0;
} |
|
lolz yes human age to dog age xD
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Oct 25, 2007 9:23 pm Post subject: |
|
|
Many pople are wrong but dogs life are like this:
First year: 12 years of dogs.
Secnd year: 12 years of dogs.
Rest are 4 years.
3 years old dog is 28. (2 times 12 = 24+4 = 2 - 4 years are 32 and so on...
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Fri Oct 26, 2007 6:04 am Post subject: |
|
|
| Code: | #include <iostream>
int main(int argc, char **argv)
{
int age;
std::cout << "Enter a number: ";
while( !(std::cin >> age) ) {
std::cout << "Enter a NUMBER ffs: ";
std::cin.sync(); // Sync the stream
std::cin.clear(); // Clear the bit
}
std::cout << "The number multiplied by seven: " << age*7 << std::endl;
std::cin.ignore(); // Ignore the input (pause the proggie)
std::cin.sync(); // and discard the input
return 0;
} |
|
|
| Back to top |
|
 |
|