0

Hi!

I have another assignment regarding writing a program based on a given output.

Here's the Output given:

Output:

Enter your date of birth:
Day:
Month:
Year:

My birth date is on 31 August 1980.

So, here's my answer( Although it is wrong; with about 6 ERRORS in it):

#include <stdio.h>
main()
{
char date of birth[15];
printf("Enter your date of birth:");
scanf("%s", date of birth);
char Day[15]
printf("Day:");
scanf("%s", Day);
char Month[15]
printf("Month:");
scanf("%s", Month);
char Year[15]
printf("Year:");
scanf("%s", Year);
printf("\n\nMy birth date is on %s\n", date of birth);
return 0;
}

So, this is SO NOT CORRECT, right???

Can anyone tell me where did I go wrong in writing this program code? Coz I got 6 ERRORS in it!!!

And it's due tomorrow too! BUMMER.

Please! Please! Please! S.O.S

p/s: I'm waiting patiently for a reply thread here ASAP. Thanks in advance.

Edited by WaltP: Added CODE Tags -- please use them

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Fbody
-2
cout << "Enter your date of birth:" << endl;
cout << "Day: ";
cin >> day;
cout << "Month: ";
cin >> month;
cout << "Year: ";
cin >> year;
cout << endl;
cout << "My date of birth is on: " << day << " " << month << " " << year << endl;
Votes + Comments
What's the OP supposed to do with that? Don't just belch some code out without explaining it.
0

Well, this actually reads more like C code than C++ code, but we can still help you out. Would you elaborate on the errors you're getting? What compiler/IDE are you using?

One thing I can see for sure is that your "date of birth" variable is an illegal identifier. Try dateOfBirth (or similar) instead.

Edited by Fbody: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.