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.

Recommended Answers

All 2 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.