lundi 17 juillet 2017

C# Program with if else statements returning some absurd value [duplicate]

This question already has an answer here:

`class Program
{
    static void Main(string[] args)
    {
        int Likes = 1;

        Likes = Console.Read();

        if (Likes == 1)
        {
            Console.WriteLine("Friend1 likes your post");
        }
        else if (Likes == 2)
        {
            Console.WriteLine("Friend1 and Friend2 like your post");
        }
        else
        {
            Console.WriteLine("Friend1 and Friend2 and" + Likes + "number of  
  other people like your post");
        }
        `

Output: 1 Friend1 and Friend2 and49number of other people like your post Press any key to continue. . .

Aucun commentaire:

Enregistrer un commentaire