Hello everybody!

My program which is able to calculate your age, has been updated!
See http://www.daniweb.com/software-development/cpp/threads/432997/age-calculator for the old version.

The programs asks your birthdate and the current date. With that information, the program is able to calculate your age. It calculates the years, months and days.

This program is originally written in Dutch, so you can still find Dutch words like "jaar", "maand" and "dag", but don't worry. You won't see those words if you are running the program.

Now, my program won't you allow to enter invalid data. The program won't accept characters and symbols if values are required.

Here is the source code:

#include <iostream>
using namespace std;

int bjaar, bmaand, bdag, hjaar, hmaand, hdag, ljaar, lmaand, ldag, tjaar, tmaand, tdag;
char vraag1;

void wrongbirthyear()
{
     cout << endl << "Enter a valid value for your birthyear: ";
     cin.clear();
     cin.ignore();
     cin >> bjaar;
}

void wrongbirthmonth()
{
     cout << endl << "Enter a valid value for your birthmonth: ";
     cin.clear();
     cin.ignore();
     cin >> bmaand;
}

void wrongbirthday()
{
     cout << endl << "Enter a valid value for your birthday: ";
     cin.clear();
     cin.ignore();
     cin >> bdag;
}

void wrongcurrentyear()
{
     cout << endl << "Enter a valid value for the current year: ";
     cin.clear();
     cin.ignore();
     cin >> hjaar;
}

void wrongcurrentmonth()
{
     cout << endl << "Enter a valid value for the current month: ";
     cin.clear();
     cin.ignore();
     cin >> hmaand;
}

void wrongcurrentday()
{
     cout << endl << "Enter a valid value for the current day: ";
     cin.clear();
     cin.ignore();
     cin >> hdag;
}

int main()
{
    system("CLS");
    cout << "\n\n\t\t Mark Wierings's Age Calculator \n\n";
    cout << "In which year were you born? (Example: 1995) ";
    cin >> bjaar;
    while(cin.fail())
    {
                     wrongbirthyear();
    }
    cout << endl << "In which month were you born? " << endl << endl;
    cout << " 1) January \n 2) February \n 3) March \n 4) April \n 5) May \n 6) June \n 7) July";
    cout << endl << " 8) August \n 9) September \n 10) October \n 11) November \n 12) December";
    cout << endl << endl << "Enter a value: ";
    cin >> bmaand;
    while(cin.fail())
    {
                     wrongbirthmonth();
    }
    while(bmaand <= 0 || bmaand > 12)
    {
              system("CLS");
              cout << endl << bmaand << " is an invalid value. ";
              cout << "1 to 12 are valid values." << endl;
              cout << "Enter a valid value: ";
              cin >> bmaand;
              while(cin.fail())
              {
                               wrongbirthmonth();
              }
    }
    cout << endl << "On which day of the month were you born? ";
    cin >> bdag;
    while(cin.fail())
    {
                     wrongbirthday();
    }
    if(bmaand == 1 || bmaand == 3 || bmaand == 5 || bmaand == 7 || bmaand == 8 || bmaand == 10 || bmaand == 12)
    {
          while(bdag <= 0 || bdag > 31)
          {
                  system("CLS");
                  cout << endl << bdag << " is an invalid value for a day of a month." << endl;
                  cout << "Enter a valid value. 1 to 31 are valid values: ";
                  cin >> bdag;
                  while(cin.fail())
                  {
                                   wrongbirthday();
                  }
          }

    }
    if(bmaand == 4 || bmaand == 6 || bmaand == 9 || bmaand == 11)
    {
          while(bdag <= 0 || bdag > 30)
          {
                  system("CLS");
                  cout << endl << bdag << " is an invalid value for a day of a month." << endl;
                  cout << "Enter a valid value. 1 to 30 are valid values: ";
                  cin >> bdag;
                  while(cin.fail())
                  {
                                   wrongbirthday();
                  }
          }

    }
    if(bmaand == 2)
    {
              if(bjaar%4 == 0)
              {
                         if(bjaar%100 == 0 && bjaar%400 != 0)
                         {
                                      while(bdag <= 0 || bdag > 28)
                                      {
                                                 system("CLS");
                                                 cout << endl << bdag << " is an invalid value for a day of a month." << endl;
                                                 cout << "Enter a valid value. 1 to 28 are valid values: ";
                                                 cin >> bdag;
                                                 while(cin.fail())
                                                 {
                                                                  wrongbirthday();
                                                 }
                                      }
                         }
                         else
                         {
                                      while(bdag <= 0 || bdag > 29)
                                      {
                                                 system("CLS");
                                                 cout << endl << bdag << " is an invalid value for a day of a month." << endl;
                                                 cout << "Enter a valid value. 1 to 29 are valid values: ";
                                                 cin >> bdag;
                                                 while(cin.fail())
                                                 {
                                                                  wrongbirthday();
                                                 }
                                      }    
                         }
              }
              else
              {
                   while(bdag <= 0 || bdag > 28)
                   {
                              system("CLS");
                              cout << endl << bdag << " is an invalid value for a day of a month." << endl;
                              cout << "Enter a valid value. 1 to 28 are valid values: ";
                              cin >> bdag;
                              while(cin.fail())
                              {
                                               wrongbirthday();
                              }
                   }
              }
    }
    if(bmaand == 1)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th January " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 2)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th February " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 3)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th March " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 4)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th April " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 5)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th May " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 6)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th June " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 7)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th July " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 8)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th August " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 9)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th September " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 10)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th October " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 11)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th November " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    if(bmaand == 12)
    {
              system("CLS");
              cout << endl << "You were born on the " << bdag << "th December " << bjaar << "." << endl;
              cout << endl << "Is that right? (Y/N) ";
              cin >> vraag1;
              if(vraag1 != 'Y' && vraag1 != 'y')
              {
                        cout << endl << "The program will be restarted so you can enter your ";
                        cout << "data again." << endl << endl;
                        system("pause");
                        main();
              }
    }
    system("CLS");
    cout << endl << "Which year is it now? ";
    cin >> hjaar;
    while(cin.fail())
    {
                     wrongcurrentyear();
    }
    while(hjaar < bjaar)
    {
                cout << endl << "Your birthyear can't be bigger than the current year." << endl;
                cout << "Enter a valid year: ";
                cin >> hjaar;
                while(cin.fail())
                {
                                 wrongcurrentyear();
                }
    }
    cout << endl << "Which month is it now? " << endl << endl;
    cout << " 1) January \n 2) February \n 3) March \n 4) April \n 5) May \n 6) June \n 7) July";
    cout << endl << " 8) August \n 9) September \n 10) October \n 11) November \n 12) December";
    cout << endl << endl << "Enter a value: ";
    cin >> hmaand;
    while(cin.fail())
    {
                     wrongcurrentmonth();
    }
    while(hmaand <= 0 || hmaand > 12)
    {
              system("CLS");
              cout << endl << hmaand << " is an invalid value. ";
              cout << "1 to 12 are valid values." << endl;
              cout << "Enter a valid value: ";
              cin >> hmaand;
              while(cin.fail())
              {
                               wrongcurrentmonth();
              }
    }
    while(hjaar == bjaar && hmaand < bmaand)
    {
                system("CLS");
                cout << endl << "You aren't born yet. This program is only intended for the people who are born" << endl;
                cout << "Just wait a few months, or enter a valid current month: ";
                cin >> hmaand;
                while(cin.fail())
                {
                                 wrongcurrentmonth();
                }
    }
    cout << endl << "Which day of the month is it now? ";
    cin >> hdag;
    while(cin.fail())
    {
                     wrongcurrentday();
    }
    if(hmaand == 1 || hmaand == 3 || hmaand == 5 || hmaand == 7 || hmaand == 8 || hmaand == 10 || hmaand == 12)
    {
          while(hdag <= 0 || hdag > 31)
          {
                  system("CLS");
                  cout << endl << hdag << " is an invalid value for a day of the month." << endl;
                  cout << "1 to 31 are valid values. Enter a valid value: ";
                  cin >> hdag;
                  while(cin.fail())
                  {
                                   wrongcurrentday();
                  }
          }

    }
    if(hmaand == 4 || hmaand == 6 || hmaand == 9 || hmaand == 11)
    {
          while(hdag <= 0 || hdag > 30)
          {
                  system("CLS");
                  cout << endl << hdag << " is an invalid value for a day of the month." << endl;
                  cout << "1 to 30 are valid values. Enter a valid value: ";
                  cin >> hdag;
                  while(cin.fail())
                  {
                                   wrongcurrentday();
                  }
          }

    }
    if(hmaand == 2)
    {
              if(hjaar%4 == 0)
              {
                         if(hjaar%100 == 0 && hjaar%400 != 0)
                         {
                                      while(hdag <= 0 || hdag > 28)
                                      {
                                                 system("CLS");
                                                 cout << endl << hdag << " is an invalid value for a day of the month." << endl;
                                                 cout << "1 to 28 are valid values. Enter a valid value: ";
                                                 cin >> hdag;
                                                 while(cin.fail())
                                                 {
                                                                  wrongcurrentday();
                                                 }
                                      }
                         }
                         else
                         {
                                      while(hdag <= 0 || hdag > 29)
                                      {
                                                 system("CLS");
                                                 cout << endl << hdag << " is an invalid value for a day of the month." << endl;
                                                 cout << "1 to 29 are valid values. Enter a valid value: ";
                                                 cin >> hdag;
                                                 while(cin.fail())
                                                 {
                                                                  wrongcurrentday();
                                                 }
                                      }    
                         }
              }
              else
              {
                   while(hdag <= 0 || hdag > 28)
                   {
                              system("CLS");
                              cout << endl << hdag << " is an invalid value for a day of the month." << endl;
                              cout << "1 to 28 are valid values. Enter a valid value: ";
                              cin >> hdag;
                              while(cin.fail())
                              {
                                               wrongcurrentday();
                              }
                   }
              }
    }
    if(hjaar == bjaar && hmaand == bmaand && hdag < bdag)
    {
             system("CLS");
             cout << endl << "You aren't born yet. This program is only intended for the people who are born." << endl;
             cout << "Just wait a few days, or enter a valid day: ";
             cin >> hdag;
             while(cin.fail())
             {
                              wrongcurrentday();
             }
    }
    cout << endl << "The system is calculating your age..." << endl << endl;
    ljaar = hjaar - bjaar;
    lmaand = hmaand - bmaand;
    ldag = hdag - bdag;
    if(lmaand < 0)
    {
              ljaar = ljaar - 1;
              lmaand = 12 + lmaand;
    }
    if(ldag < 0 && lmaand == 0)
    {
            ljaar = ljaar - 1;
            lmaand = 12 - 1;
            if(hmaand == 1 || hmaand == 3 || hmaand == 5 || hmaand == 7 || hmaand == 8 || hmaand == 10 || hmaand == 12)
            {
                   ldag = 31 + ldag;   
            }
            if(hmaand == 4 || hmaand == 6 || hmaand == 9 || hmaand == 11)
            {
                   ldag = 30 + ldag;
            }
            if(hmaand == 2)
            {
                      ldag = 28 + ldag;
                      if(hjaar%4 == 0)
                      {
                                 ldag = 29 + ldag;
                                 if(hjaar%100 == 0 && hjaar%400 != 0)
                                 {
                                              ldag = 28 + ldag;
                                 }
                      }
            }
    }
    if(ldag < 0 && lmaand != 0)
    {
            lmaand = lmaand - 1;
            if(hmaand == 1 || hmaand == 3 || hmaand == 5 || hmaand == 7 || hmaand == 8 || hmaand == 10 || hmaand == 12)
            {
                   ldag = 32 + ldag;   
            }
            if(hmaand == 4 || hmaand == 6 || hmaand == 9 || hmaand == 11)
            {
                   ldag = 31 + ldag;
            }
            if(hmaand == 2)
            {
                      ldag = 29 + ldag;
                      if(hjaar%4 == 0)
                      {
                                 ldag = 30 + ldag;
                                 if(hjaar%100 == 0 && hjaar%400 != 0)
                                 {
                                              ldag = 29 + ldag;
                                 }
                      }
            }
    }
    cout << "Birthyear: " << bjaar << endl;
    cout << "Birthmonth: " << bmaand << endl;
    cout << "Birthday: " << bdag << endl << endl;
    if(ldag != 1 && lmaand != 1)
    {
            cout << "You are " << ljaar << " years, " << lmaand << " months and " << ldag << " days old.";
    }
    if(ldag == 1 && lmaand == 1)
    {
            cout << "You are " << ljaar << " years, " << lmaand << " month and " << ldag << " day old.";
    }
    if(ldag != 1 && lmaand == 1)
    {
            cout << "You are " << ljaar << " years, " << lmaand << " month and " << ldag << " days old.";
    }
    if(ldag == 1 && lmaand != 1)
    {
            cout << "You are " << ljaar << " years, " << lmaand << " months and " << ldag << " day old.";
    }
    if(ljaar == 0 && lmaand == 0 && ldag == 0)
    {
             cout << endl << "You are just born!" << endl;
    }
    if(ljaar != 0 && lmaand == 0 && ldag == 0)
    {
             cout << endl << endl << "Happy birthday! You have become " << ljaar << " years old now!" << endl;
    }
    cout << endl << endl;

    system("pause");
    return 0;
}

My program which is able to calculate your age, has been updated!

No offense intended, and not to diminish the effort you put into writing it, but your program isn't so interesting or clever that anybody would care about updates.

Congratulations on having working code. Are you interested in suggestions for possible improvements?

Updates should be "Updated". Unfortunately I can't change it now.

Bob.
Yes, of course I am interested in possible improvements. :-)

deceptikon.
I think a lot of people are interested in updates!

I think a lot of people are interested in updates!

Name one.

Ancient Dragon
You.

Updates should be "Updated". Unfortunately I can't change it now.

You could reply to the existing thread rather than creating a new one... :rolleyes:

Yes, of course I am interested in possible improvements. :-)

I'd start by dropping the Dutch variable and function names, and switching to English. If you want people on an English speaking forum to offer improvements then it's wise to make the code as readable as possible for those people.

I think a lot of people are interested in updates!

On a simple program that any reasonably competent C++ beginner could write? You might find a few people who are interested, but they're all going to be beginners like you who have homework similar to your program's description.

I think you need to adjust your opinion of this program to be more realistic. You're 14 (according to your signature), so it's understandable that you think the world revolves around you and everything that you produce is magic, but I'm willing to bet that most of the people who see this program will think the same thing I did. It's quaint, and props to you for doing it, but it's clearly written by a beginner and I could quickly write a better version with minimal effort. Therefore, I have zero interest in either the original program or updates.

If you have any specific questions about how to improve the program, I'll be happy to offer some opinions. However, I'm not going to lavish you with praise, which is clearly what you're expecting by not only showing off the first program as if it's the next Halo, but also starting a new thread with an "update". I really don't see any point in inflating your ego bigger than it already is.

I'd start by dropping the Dutch variable and function names, and switching to English. If you want people on an English speaking forum to offer improvements then it's wise to make the code as readable as possible for those people.

That is completey unnecessary. It would only takes effort and it won't change the program. I only translated the text between " ", because that is what people see when they are using the program.

Changing the name of the functions and variables doesn't change anything. I can call it whatever I want. I can call it "book", "chair", "table", "apple", "banana", "computer", "teletubbies", "dora", "winxclub", "socialism", "liberalism", "capitalism", "house", "earth", "moon", "stone", "keyboard" etc.

The only reason I have used words like "jaar", "maand" and "dag", is because it was easier for me to remember and easier to program. For example: using the the word "socialism" for the current year would be a little bit confusing.

deceptikon.

You're 14 (according to your signature),

I am 15 years old now. I became 15 on the 7th August.

The only reason I have used words like "jaar", "maand" and "dag", is because it was easier for me to remember and easier to program. For example: using the the word "socialism" for the current year would be a little bit confusing.

I don't think you understand. Unless the reader knows what jaar, maand, and dag mean, they'll have trouble understanding your code without making assumptions based on context or doing a Dutch to English translation. I'm suggesting that you use the English version of the same words: year, month, and day. I'm not suggesting that you name your variables something completely random, and I can't imagine how you inferred that.

On a simple program that any reasonably competent C++ beginner could write? You might find a few people who are interested, but they're all going to be beginners like you who have homework similar to your program's description.

I wish you wouldn't speak for everyone, because you don't. I'm not a beginner, and I'm interested. I contributed to the earlier thread, I respect the OP for coming back with an improved attempt, and in keeping with the spirit of DaniWeb, I'd be more than happy to offer further support with it.

I think you need to adjust your opinion of this program to be more realistic. You're 14 (according to your signature), so it's understandable that you think the world revolves around you and everything that you produce is magic,

Respectfully, I don't think that's called for.

but I'm willing to bet that most of the people who see this program will think the same thing I did. It's quaint, and props to you for doing it, but it's clearly written by a beginner and I could quickly write a better version with minimal effort. Therefore, I have zero interest in either the original program or updates.

Anyone who has no interest in it surely only needs to skip the thread?

If you have any specific questions about how to improve the program, I'll be happy to offer some opinions. However, I'm not going to lavish you with praise, which is clearly what you're expecting by not only showing off the first program as if it's the next Halo, but also starting a new thread with an "update". I really don't see any point in inflating your ego bigger than it already is.

Respectfully, I don't think that's called for either.

I respect the OP for coming back with an improved attempt, and in keeping with the spirit of DaniWeb, I'd be more than happy to offer further support with it.

I'm also happy to help, but the OP has failed to ask any kind of specific question about how to improve the code. Both threads strike me more as "look at my awesome code!" rather than "I'm concerned with these parts of my code, how can I improve it and do you have any other suggestions?"

I'll also note that my first suggestion was immediately rejected as "completely unnecessary". That's not exactly indicative of an open mind.

Respectfully, I don't think that's called for.

Respectfully, I do. I get the distinct impression that the OP is getting a big head, and that big head needs to be deflated otherwise his progress will quickly stagnate. The more you blow sunshine up someone's ass, the more they'll have unreasonable expectations.

commented: Testing where rep counts. +14

Okay. Apologies, I must have taken a wrong turn.

You are still calling main in your if statements to get back to the top of your code. This should NEVER be done. Main is to be called by the OS not the program. You need to rethink your approach so you dont have to call main to get back to entering the birthdate.

This should NEVER be done.

Technically it's illegal in C++. So if it works, you'd be relying on a compiler extension.

Thanks deceptokon. I new it was bad but I wasnt sure if the standard said it was illegal.

I don't think you understand. Unless the reader knows what jaar, maand, and dag mean, they'll have trouble understanding your code without making assumptions based on context or doing a Dutch to English translation. I'm suggesting that you use the English version of the same words: year, month, and day.

To be very honest, I think the people will understand. Because when they see the text

cout << "In which year were you born? (Example: 1995) ";

it won't be hard to guess what

cin >> bjaar;

,which they can find right below that line, will mean.

Moreover those words aren't Russian or Chinese. Dutch words are good readable, and they look like the English words.

Dutch words are good readable, and they look like the English words.

There are very few words that start with BJ in English. There's BJ Hunnicut from M*A*S*H. Hmmm, that's the only one I can think of. Oh, and Bjorn Borg. No, wait, he's not from here, is he? ;o)

Honestly, I agree. With the prompt "Enter year" it's somewhat obvious what bjaar means. Not that we can remember 20 lines down, though...

You are still calling main in your if statements to get back to the top of your code. This should NEVER be done. Main is to be called by the OS not the program. You need to rethink your approach so you dont have to call main to get back to entering the birthdate.

I also tried to replace the whole code to another function, AgeCalculator(), and to fill in at main() to jump immediately to AgeCalculator(). I replaced alle main()-statements by AgeCalculator()-statements, and I got exactly the same result. Nothing happened, so I changed it back.

But, now I am working to another update. This time I will use abort() to close the program. That's the most efficient way, I think.

I also tried to replace the whole code to another function, AgeCalculator(), and to fill in at main() to jump immediately to AgeCalculator(). I replaced alle main()-statements by AgeCalculator()-statements, and I got exactly the same result. Nothing happened, so I changed it back.

You were supposed to get the same result if you programmed it properly.

But, now I am working to another update. This time I will use abort() to close the program. That's the most efficient way, I think.

Wrong... It's one of the wort ways.

This time I will use abort() to close the program. That's the most efficient way, I think.

No, its not. The most efficient way is to return from main(). If you want to close the program from somewhere else then call exit(), not abort().

If you want to close the program from somewhere else then call exit()....

But only if you are not in main().

And if you are in a function, it's still best to try to return to main(), if possible, to exit (using return of course).

There are very few words that start with BJ in English.

Also in Dutch there are a very few words which starts with BJ. The right word is "jaar", which means: "year". I added a "b" to it, which stands for "birth". I did it for myself, because it was easier to remember and easier to program.

commented: And how ere we supposed to know that???? +14

I did it for myself, because it was easier to remember and easier to program.

If you're writing code only for yourself then that's fine. If you want other people to read it too then you need to keep them in mind while writing the code. Granted this is a fairly minor thing because an astute reader will be able to decipher your variables' meaning through context, but that still requires extra effort. Unless I'm required to read and understand your code (I'm not, by the way), the amount of effort needed is inversely proportional to the likelihood of me even bothering. Put another way, the harder code is to read, the less likely I'll take time to read it.

I wont even read code that is not in code tags.

here in 51 line of code there is some error please build again..

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.