VINAY KUMAR GUPTA
3.Write a program to find out the how many 9 is present in given input eg:100 to 10000 ?
By VINAY KUMAR GUPTA in Algorithms in C# on Sep 07 2015
  • Sai Kirat
    Sep, 2016 6

    --looped in SQL, can be done similarly in c# as well declare @min int = 0,@max int=100,@ctr int =0,@nines int = 0,@str nvarchar(10)=''while (@min<=@max) Begin set @str = convert(nvarchar(10),@min) set @nines = @nines + (len(@str)-len(replace(@str,'9',''))) set @min=@min+1 End select @nines

    • 0
  • VINAY KUMAR GUPTA
    May, 2016 12

    public static void Main() { int a = 100; int b = 10000; int count = 0; int c = 0; int x = 0; for (int i = a; i <= b; i++) { c = i; while (c != 0) { x = c % 10; c = c / 10; if (x == 9) { count++; } } } Console.WriteLine(count); }

    • 0
  • VINAY KUMAR GUPTA
    Sep, 2015 7

    public static void Main() {int a = 100;int b = 10000;int count = 0;int c = 0;int x = 0;for (int i = a; i <= b; i++){c = i;while (c != 0){x = c % 10;c = c / 10;if (x == 9){count++;}}}Console.WriteLine(count); }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS