Skip to content
Loading
  • Rafnas T P
    0
    hi,
    try below code for getting all the odd nombers from your input nombers
     
    1. using System;  
    2.                       
    3. public class Program  
    4. {  
    5.     public static void Main()  
    6.     {  
    7.          string result,getnum;  
    8.          Console.WriteLine("Enter the Number");  
    9.          getnum =Console.ReadLine();  
    10.   
    11.         while (getnum.Length > 0)  
    12.         {  
    13.             result = getnum.Substring(0,1).ToString();  
    14.             if (Convert.ToInt32(result) % 2 != 0)  
    15.             {  
    16.             Console.WriteLine("These are the Odd Numbers" + result);          
    17.             }  
    18.             if(getnum.Length==1)  
    19.             {  
    20.                 getnum="";  
    21.             }  
    22.             else if(getnum.Length>1)  
    23.             {  
    24.             getnum=getnum.Substring(1,getnum.Length-1).ToString();  
    25.             }   
    26.          }        
    27.           
    28.     }  
    29. }  
     
    0