3
Reply

3.Write a program to find out the how many 9 is present in given input eg:100 to 10000 ?

VINAY KUMAR GUPTA

VINAY KUMAR GUPTA

Sep 07, 2015
1.2k
0

    --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

    Sai Kirat
    September 06, 2016
    0

    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); }

    VINAY KUMAR GUPTA
    May 12, 2016
    0

    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); }

    VINAY KUMAR GUPTA
    September 07, 2015
    0