Require help with several errors (c2106, C4305)
Im new to programming. Infact, I started learning yesterday so I am inexperienced and require help. Im trying to make an age calculator. I havent even got halfway into the program and still it is giving me lots of errors. Please look at the code and the errors.
Thanks
Code:
#include <iostream>
using namespace std;
int main ()
{
int D1;
int D2;
int D3;
int M1;
int M2;
int M3;
int Y1;
int Y2;
int Y3;
int G;
int L;
int Valid;
cout<<"Age Calculator\n";
cout<<"\n Enter the date of the birth (DD MM YYYY): ";
cin>> D1;
cin>> M1;
cin>> Y1;
if (M1=1 || M1=3 || M1=5 || M1=7 || M1=9 || M1=11)
int L=31;
else if (M1=4 || M1=6 || M1=8 || M1=10 || M1=12)
{int L=30;}
else if (M1=2)
{int L=29;}
else if (D1<1 || D1>L)
{
cout<<"InValid Date. Enter Again"<<endl;
int Valid=0;
}
else if (M1<1 || M1>12)
{
cout<<"InValid Date. Enter Again"<<endl;
int Valid=0;
}
else if (Y1<0 || Y1>2011)
{
cout<<"InValid Date. Enter Again"<<endl;
int Valid=0;
}
cout<<"Enter the date of birth again ";
cin>> D1;
cin>> M1;
cin>> Y1;
while (valid=0);
cout<<"\n Enter second day of the month (01-31): ";
cin>> D2;
cout<<"\n Enter second month: ";
cin>> M2;
cout<<"\n Enter the second year: ";
cin>> Y2;
}
Errors:
Quote:
AgeCal.cpp
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(25): warning C4305: '=' : truncation from 'int' to 'bool'
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(25): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(25): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(25): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(25): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(25): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(28): warning C4305: '=' : truncation from 'int' to 'bool'
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(28): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(28): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(28): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(28): error C2106: '=' : left operand must be l-value
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(57): error C2065: 'valid' : undeclared identifier
1>c:\users\arsalan\documents\visual studio 2010\projects\agecal\agecal\agecal.cpp(57): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
1>