Advertisement
Guest User

targil6p60

a guest
Aug 23rd, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace targil6p60
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             for (int i = 0; i < 3; i++) //Doing a loop that will run 3 times and stop....
  14.             {
  15.                 bool thereis5 = false; //That is the boolean that needs to say if there is 5 or not..
  16.                 Console.WriteLine("Enter a number (Only if u HAYA!)"); //Requesting the user to input a number (only HAYA).
  17.                 int num = int.Parse(Console.ReadLine()); //Converting what the user inputs to int and saving it in int variable with the name num
  18.                 while (num != 0) //Loop that runs while num is NOT equals to 0
  19.                 { // In every run of the code of the loop:
  20.                     if (num % 10 == 5) //Checks if num % 10 equals to 5,
  21.                     { //If yeah:
  22.                         thereis5 = true; // Making the value of thereis5 to be true. (see line 15)
  23.                         break; //Breakink, it means stopping the loop and continuing run the code after the loop.
  24.                     }
  25.                     num /= 10; //Dividing num by 10 (Why? beause now it "removing the last number of the num (the number that we now checked if equals to 5, and next run of the loop code, that will check the next number....
  26.                 } //End loop
  27.                 //Now, if theres 5 in the number, thereis5 wilk be true. if not, false HAYA.
  28.                 if (thereis5) //Checking if threis5 is true, if yeah:
  29.                     Console.WriteLine("u r HAYA then there is 5 in this number !!!"); //writing it to the user because he's a HAYA.
  30.                 else //else,
  31.                     Console.WriteLine("solly but u r not a HAYA ....."); //writingg that there is no 5 in the number because he's not a HAYA...
  32.             }
  33.             Console.ReadLine(); //end of code, reading line for profaram will not close.....
  34.         } //shahal, please don't call me till u understand how this code working exactly + how i thought for getting this code.....
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement