Seo Services
Results for C# Interview Questions

Most Asked C# Interview Programs

October 28, 2022
In C# interviews, it is a common practice to ask for the coding questions. Today we will see the top 10 most Asked interview coding questions of C#.

C# Icon
C# Icon



 1. Print the String when input 2A3B4C then output AABBBCCCC? 

Ans:- 
 using System; 
 public class Test
  {
   public static void Main() 
     { 
        String s = "2A3B4C"; 
        String ans = ""; 
        for(int i = 0; i < s.Length;)
        {  
          int num = 0; 
         while(s[i] >= '0' && s[i] <= '9')
         { 
           num = num * 10 + (s[i] - '0');
            i++; 
          }
          while(num-- > 0)
           { 
            ans += s[i];
             } 
               i++; 
           } 
           Console.WriteLine(ans);
       }
 }

2. Check Whether the Entered Number is an Armstrong Number or Not.

Ans:- An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself.

/*
 * C# Program to Check Whether the Entered Number is an Armstrong Number or Not
 */ 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int number, remainder, sum = 0;
            Console.Write("enter the Number");
            number = int.Parse(Console.ReadLine());
            for (int i = number; i > 0; i = i / 10)
            {
                remainder = i % 10;
                sum = sum + remainder*remainder*remainder;
 
            }
            if (sum == number)
            {
                Console.Write("Entered Number is an Armstrong Number");
            }
            else
                Console.Write("Entered Number is not an Armstrong Number");
            Console.ReadLine();
        }
     }
  }
ads 728x90 B
Powered by Blogger.