jeudi 16 juillet 2020

How do I make something return if they fail to get answer something from if and else if? C++

After entering a number in the input. I want the user to put in a correct data. But after the first attempt, it immediately goes to the char function. How do I put in the else statement, a return function to repeat the same function for entering input?

#include<iostream>

int main()
{
    int num;
    std::cout << "Enter specific age library : ";
    std::cin >> num;
    std::cout << "Entered age library : " << num << "\n\n" << std::endl;



    if (num == 19)
    {
        std::cout << "Jaber : September 18, 2000" << "\n" << "Jayjay : July 18, 2000" << "\n";
    }

    else {
        std::cout << "Sorry, but it looks like the number you've entered contains no data on our library." << "\n" << "\n";

    }


    char name[50];
    std::cout << "Enter your name: " << std::endl;

    std::cin >> name;
    puts(name);
}

Aucun commentaire:

Enregistrer un commentaire