dont know whats wrong

#include <iostream>
#include <tchar.h>
#include <stdio.h>

int main ()
{
int num; //for integer number
int wives; //for number of wives
int child; //for number of children
int dog; //for number of dogs
int pup; //for number of puppies


std::cout << "Enter Citizen’s ID:\n"; // for integer number
cin >> num = num + num; // get the sum and assign it to num
cin >> wives = num - num; //num (sum) – num (integer number)
std::cout <<"Number of wives:\n";
cin >> child = num - wives; //num (sum) – wives
std::cout <<"Number of children:\n";
cin >> dog = num - child; //num (sum) – child
std::cout <<"Number of dogs:\n";
cin >> pup = num - dog; //num (sum) – dog
std::cout <<"Number of puppies:\n";

return 0 ;
}


hey guys,,
Uhmm..
when i try to build this,, it says cin was not declared in this scope..
what will i do to fix this??

tnx
Try std::cin.
Further more, your cin calls seem a bit odd. Could you perhaps clarify what this program as a total is supposed to do? Since std::cin is used for user input, meaning they can type in a value which will be assigned to a data member. You're currently trying that AND changing the value with a = operator. I haven't the faintest idea what you're trying to achieve.
Last edited on
ahm.. i've done that didnt work..

In the land of Chicano, each male citizen is identified by an integer number. The same number will
tell the number of wives, the number of children per wife, the number of dogs per child, and the
number of puppies per dog of that person. For example, citizen number 6 has 6 wives with 6 children
per wife; 6 dogs per child; and 6 puppies per dog. Make a program that would input the citizen's ID
(integer number) and then output the total number of wives, children, dogs, and puppies of that
citizen.

there..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
// #include <tchar.h> Not needed in here, remove it
// #include <stdio.h> Not needed in here, remove it

int main ()
{
    int num, wives, child, dog, pup;

    std::cout << "Enter Citizen’s ID:" << std::endl;
    cin >> num;

    pup = dog = child = wives = num;
    std::cout <<"Number of wives:" << wives << std::endl;
    std::cout <<"Number of children:" << child << std::endl;
    std::cout <<"Number of dogs:" << dog << std::endl;
    std::cout <<"Number of puppies:" << pup << std::endl;
    return 0;
}


However, since you use every single number all the time, and you know it will remain that way, it's a stupid idea to store it in every integer.
Last edited on
Topic archived. No new replies allowed.