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

Here's the Output given:


Enter your date of birth:

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>
char date of birth[15];
printf("Enter your date of birth:");
scanf("%s", date of birth);
char Day[15]
scanf("%s", Day);
char Month[15]
scanf("%s", Month);
char Year[15]
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.

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;
What's the OP supposed to do with that? Don't just belch some code out without explaining it.

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.

This question has already been answered. Start a new discussion instead.