0

I am Building guessing game C# make a “youre close” answer ,closing guessing

 

I’m making a guessing game (guess between 1-1000). and I need answer that I’m wrong but was close. I have the code (int diff = Math.Abs(guess - num); if (diff <= 3) but I don’t know where to putt it.

I have made to that I have a number that is right so that it is easier to to see if I have done my code right (and will change it after)

 Console.WriteLine("gissa talet\nDu ska nu gissa ett tal mellan 1 ocn 100, sĂĄ 
 varsĂĄgod..\nskriv in ett tal");
 int guess = Convert.ToInt32(str);
 //gonna make it random between 1-100
 int num = (50);
 {
 //when im right
 if (guess == num)
 {
    Console.WriteLine("rätt");
 }
 //when it´s to small guess
 else if (guess < num)
 Console.WriteLine("för lite");

 // to large guess
 if (guess > num)
    Console.WriteLine("för stort");

 // when i make it random nr and i guess over 100
 if (guess > 50)
    Console.WriteLine("gissa mellan 1-100");

 Console.ReadLine();
 }

About Nilesh Raut

I am Nilesh,3+ years Exp of SEO, content writing, and keyword research. Also rocks it as a software dev with skills in OS, web dev, Flask, Python, C++, data structures, and algorithms. 3 on Leetcode, 5*on Hackerrank more platform.

Nilesh Raut Changed status to publish July 20, 2023