Skip to main content

Program in C sharp # to merge two numbers and findest nearest vowel to a inputted character ( question from bca previous year question paper very important )

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace npgc
{
   static  class math
    {
        public static string nearest(char ch)
        {
            int i=0;
            int j=(int)ch;

            string ret="";
            char[] arr = {'a','e','i','o','u'};
            for (i=0;i< arr.Length - 1; i++)
            {
                int tmp=(int)(arr[i]);
             int tmp2=(int)arr[i+1];

             if (j < tmp2)
             {
                 int a = j - tmp;
                 int b = tmp2 - j;
               
                 if (a == b)
                     ret += arr[i] +""+ arr[i + 1];
                   
                 else if (a > b)
                     ret += arr[i + 1];
                 else
                     ret += arr[i];

                 return ret;

             }

            }
            ret += arr[arr.Length - 1];
            return ret;

        }
        public static long merge(long a, long b)
        {
            long tmp = b,t=1;
            do{
                tmp = tmp / 10;

                t*=10;

            }while(tmp>0);
            a = a * t + b;
            return a;
        }

    }
}
namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            int ch = 1;
            Console.WriteLine("Enter 1 for merge numbers" + "\n" + "Enter 2 for nearest vowel");
            ch = Convert.ToInt32(Console.ReadLine());

            if (ch < 0 && ch > 2)
                return;
            else
            {
                switch (ch)
                {
                    case 1:
                        Console.WriteLine("Enter 2 numbers");
                        long a = Convert.ToInt64(Console.ReadLine());
                        long b = Convert.ToInt64(Console.ReadLine());
                        Console.WriteLine(npgc.math.merge(a, b));
                        break;
                    case 2:
                        Console.WriteLine("Enter a character");
                        string s = Console.ReadLine();
                        Console.WriteLine(npgc.math.nearest(s[0]));
                        break;

                }
            }

            Console.ReadKey();
        }
    }
}


Comments

Popular posts from this blog

PROGRAM TO PRINT COLOURS OF RAINBOW ACCORDING TO THE NO. INPUTTED BY THE USER

#include,stdio.h> #include<conio.h> void main() { int ch; printf("INPUT A NUMBER\n"); scanf("%d",&ch); switch(ch) { case 6: printf("Red"); break; case 5 : printf(" Orange"); break; case 4 : printf(" Yellow"); break; case 3 : printf(" Green"); break; case 2 : printf(" Blue"); break; case 1 : printf(" Indigo"); break; case 0 : printf(" Violet"); break; default : ("wrong input "); } } SIMPLE PROGRAMS FIND TYPE OF THE TRIANGLE TEMPERATURE CONVERSION COMMISSION OF A SALESMAN PRINT NUMBERS IN DESCENDING ORDER BIGGEST NUMBER AMONG THREE NUMBERS CALCULATE DIVISION A YEAR IS LEAP OR NOT A NUMBER IS ODD OR EVEN PRINT THE SQUARE ROOT ELSE PRINT N TO THE POWER 5 PRINT A NEW NUMBER BY ADDING 1 TO EACH DIGIT OF THE NUMBER PRINT THE NO. OF CURRENCY NOTES ACCORDING TO THE AMOUNT ENTERED DATA STRUCTURES ENTER DETAILS OF A STUDENT ENTER DETAILS OF A ST...

unix commands

 

Baby doge paws

Baby doge paws link 🎉 Join the BabyDoge PAWS Clicker adventure! Solve challenges, join daily events, and invite friends. Stay tuned for the token airdrop! 🐾 🌟 Earn 10k PAWS as a welcome bonus 🌟 Get 25k PAWS with Telegram Premium https://t.me/BabyDogePAWS_Bot?start=r_6394860582