Support us on YouTube by Subscribing our YouTube Channel. Click here to Subscribe our YouTube Channel

Friday 11 December 2020

Wednesday 4 November 2020

Exception Handling in SQL Server

In this Article, we will learn How to Handle Exception in SQL Server and also see How to capture or Log the Exception in case of any DB Level Exception occurs so that the Developer can refer to that Error log, can check the severity of the Exception, and fix it without wasting too much time in finding the exception causing procedure or function or line which is causing the exception.

Sunday 25 October 2020

Program to generate Floyd’s Triangle in C#

Floyd’s triangle is a right-angled triangle of natural numbers used in computer science education. Floyd refers to the name after Robert Floyd. Floyd’s triangle is created by printing the consecutive numbers in the rows of the triangle starting from the number 1 at the top left corner.

I will recommend you to check the below link for Top C# Interview Programs asked during the Interview and Examination.
Program:

//Three variable one for outer loop, one for inner

//k to print the number

int i, j, k = 1;

for (i=1;i<=10;i++) {

    for (j=1;j<=i;j++) {

    //Print no. in console with horizontal space i.e. tab

    Console.Write(k++ + "\t");

    }

    //New Line

    Console.Write("\n");

}

//Console.ReadLine() to hold the screen after the execution of the program

Console.ReadLine();

Preview:

I hope this program will help you in your exam as well as Interview preparation.
Thanks

Sunday 27 September 2020

Deployment Manager and Monitoring in Google Cloud Platform

In this article, we will learn How to use the Deployment Manager to deploy VM Instance as well as monitor them in the Google Cloud Platform. If you are new to this series of Google Cloud Platform, I will recommend you to go through the below articles of this series:


Saturday 19 September 2020

Program to find the HCF of two numbers in C#

In this blog, we will learn How to find the HCF of two numbers in C#. If you are looking for Programs asked in C# Interview, check the below link:


HCF Stands for Highest Common Factor. It is also called the Greatest Common Measure (GCM) and Greatest Common Divisor (GCD). For finding the HCF, we need to find the greatest number which divides two or more numbers.


Check the below C# program, for calculating the HCF of two numbers in C#. I have mentioned comments as well for easy understanding.

int num1, num2, loopCheck, hcf=0;

//Prompt user to add two number for which HCF needs to find

Console.WriteLine("Enter First Number");

num1 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter Second Number");

num2 = Convert.ToInt32(Console.ReadLine());

//set the min value out of the numbers entered by the user

loopCheck = num2 > num1 ? num1 : num2;

//Loop the data from 1 to the loopCheck value

for (int i = 1; i <= loopCheck; i++)

{

    //If Modulus of both number will be Zero than store it in hcf variable

    if (num1 % i == 0 && num2 % i == 0)

    {

        hcf = i;

    }

}

//Show the output to the User

Console.Write("HCF of {0} and {1} is: {2}", num1, num2, hcf);

//Console.ReadLine() t

Output:

I hope this will help you with your interview preparation or exam.
Thanks

Monday 14 September 2020

Program to check a number is Palindrome in C#

In this blog, we will learn How to check a number is Palindrome or not in C#. This Is also one of the most popular interview questions among the interviewers. The basic approach is to reverse the number and then compare it with the number added by the user. 

Sunday 13 September 2020

Program to check a string is Palindrome in C#

In this blog, we will learn How to write a program to check whether a String is a Palindrome or not in C#. A palindrome is a word or phrase or a sequence of characters that reads the same either read from backward or as in forwards e.g. Malayalam, Madam, etc. 

It is also one of the popular and favorite programs asked during the interview/exam. There are multiple ways by which we can check either string is palindrome or not, Out of which two are mentioned here in this blog.
1. Iterate through each character and generate the reverse string
2. Break string to array and reverse the string

1. Iterate through each character and generate reverse string:
In this method, we start reading the character from the last character of the string and store it in another variable as shown in the below image. Once the string is reversed, compare it with the original string to find that string entered by the user is Palindrome or not.
Program in C#:

Console.WriteLine("Enter a string to check either it's Palindrome or not");

string statement = Console.ReadLine();

//variable to hold the reversed statement

string reverseStatement = "";

//Reverse the statement

for (int i=statement.Length-1;i>=0;i--) {

    reverseStatement += statement[i];

}

//Check statement and reverse statement are equal

if (statement.Equals(reverseStatement, StringComparison.OrdinalIgnoreCase))

{

    Console.WriteLine("'{0}' is an example of Palindrome", statement);

}

else {

    Console.WriteLine("'{0}' is not an example of Palindrome", statement);

}

//Console.ReadLine() to hold the screen after the execution of the program

Console.ReadLine();

Output:


2. Break string to array and reverse the string
Another and easiest way to check the palindrome is to convert the string to the char array and then reverse the array with Array.Reverse() method. Once the array is reversed, convert it back to the string as shown in the below example. Once the string is reversed, compare it (ignore case while comparing string) with the original string entered by the user.
Program in C#:

Console.WriteLine("Enter a string to check either it's Palindrome or not");

string statement = Console.ReadLine();

//variable to hold the reversed statement

string reverseStatement = "";

//Convert the string to the Char Array

Char[] charArr = statement.ToCharArray();

//Reverse the Array

Array.Reverse(charArr);

//Convert the character array to string

reverseStatement = new string(charArr);

//Check statement and reverse statement are equal

if (statement.Equals(reverseStatement, StringComparison.OrdinalIgnoreCase))

{

    Console.WriteLine("'{0}' is an example of Palindrome", statement);

}

else

{

    Console.WriteLine("'{0}' is not an example of Palindrome", statement);

}

//Console.ReadLine() to hold the screen after the execution of the program

Console.ReadLine();

Preview:

I hope this program will help you in your interview/exam.
Thanks


Wednesday 9 September 2020

Program to find factorial of a number in C#

In this blog, we are going to learn How to find factorial of a positive number or integer in C#. As we know that we can find the factorial of a number in multiple ways, out of which I am going to share two ways i.e. with and without the use of recursion.

Program to find factorial of a number without using recursion:
In mathematics, factorial is the product of all positive numbers or integers less than or equal to the number.
Program:

int number, factorial;

Console.WriteLine("Enter a number to calculate its Factorial");

//Recieve input from user

number = int.Parse(Console.ReadLine());

//set factorial value as we will start loop from number-1

factorial = number;

//Multiply the factorial value till i becomes 1

for (int i=number-1;i>=1;i--) {

    factorial = factorial * i;

}

//Display the output to the user

Console.WriteLine("Factorial of " + number + " is: " + factorial);

//Console.ReadLine() to hold the screen after the execution of the program

Console.ReadLine();

Output:

Program to find the factorial of a number with the use of recursion:
A recursive function is a function that calls itself inside the function.
Program:

class Program

{

    //CalculateFactorial method

    public int CalculateFactorial(int number)

    {

        //If number becomes it will return 1 and recursion will stop

        if (number == 1)

        {

            return 1;

        }

        else

        {

            //Calling CalculateFactorial method (Recursion)

            return number * CalculateFactorial(number - 1);

        }

    }

   

    static void Main(string[] args)

    {

        int number;

        Console.WriteLine("Enter a number to calculate its Factorial");

        //Recieve input from user

        number = int.Parse(Console.ReadLine());

        if (number > 0)

        {

            Program objProgram = new Program();

            //Calling CalculateFactorial method

            int factorial = objProgram.CalculateFactorial(number);

            //Display the output to the user

            Console.WriteLine("Factorial of " + number + " is: " + factorial);

        }

        else

        {

            Console.WriteLine("Number must be greater than zero");

        }

        //Console.ReadLine() to hold the screen after the execution of the program

        Console.ReadLine();

    }

}

Output:

I hope this blog will help you in cracking your interview/exam.
Thanks. 


Monday 7 September 2020

Program to find the occurrence of the character in a string in C#

In some interviews or exams, a problem is provided to the interviewee or student to find out the occurrence of the character in a string. In this example, I will help you in solving that problem/program with the easiest approach.

Sunday 6 September 2020

Program to Swap two numbers in C#

Write a program to Swap two numbers in C#

In many Interviews, the Interviewer asks the Interviewee to write a program to swap two numbers. There are multiple methods/ways to swap numbers in C#, out of which two popular methodologies are Swapping two numbers with third/temporary variable and another is swapping two numbers without using a third/temporary variable (using + and – arithmetic operator). Let’s see both approaches in detail. 


Swap two numbers by using third/temporary variable:
As you can see in the below image, it’s very simple to swap two numbers with a third temporary variable.
Program to swap two numbers by using third/temporary variable in C# is provided below:

int num1, num2, temp;

//Get two number from the user to swap

Console.WriteLine("Enter first number");

num1 = int.Parse(Console.ReadLine());

Console.WriteLine("Enter second number");

num2 = int.Parse(Console.ReadLine());

Console.WriteLine("Values before swapping: num1=" + num1 + " and num2=" + num2);

temp = num1;

num1 = num2;

num2 = temp;

Console.WriteLine("Values after swapping: num1=" + num1 + " and num2=" + num2);

//Console.ReadLine() to hold the screen after the execution of the program

Console.ReadLine();

Output:

Swap two numbers without using any third/temporary variable:
As you can see in below image it’s very easy to swap the two numbers without using third variable. 
Program to swap two numbers without using third/temporary variable is provided below:

int num1, num2;

//Get two number from the user to swap

Console.WriteLine("Enter first number");

num1 = int.Parse(Console.ReadLine());

Console.WriteLine("Enter second number");

num2 = int.Parse(Console.ReadLine());

Console.WriteLine("Values before swapping: num1=" + num1 + " and num2=" + num2);

num1 = num1 + num2;

num2 = num1 - num2;

num1 = num1 - num2;

Console.WriteLine("Values after swapping: num1=" + num1 + " and num2=" + num2);

//Console.ReadLine() to hold the screen after the execution of the program

Console.ReadLine();

Output:
I hope this article will help you in your interview preparation.
Thanks



Saturday 5 September 2020

Top C# Programs for Interview

As I got several emails regarding the help for the Interview, so, I decided to share the programs that are asked during the interview. These programs also help you in an understanding of the problems/algorithms in the easiest way. I will update the programs every week so stay tuned. You can also write an email (or comment in the comment box) to me for any specific program required.

Top C# Program for Interview:

S.No.C# Interview Programs
1Reverse a Number in C#
2Reverse a string in C#
3FizzBuzz in C#
4Program to find Factor of a number in C#
5Program to Swap two numbers in C#
6Program to find the occurrence of the character in a string in C#
7Program to find factorial of a number in C#
8Program to check a string is Palindrome in C#
9Program to check a number is Palindrome in C#
10Program to find the HCF of two numbers in C#
11Program to generate Floyd’s Triangle in C#
12Program to Count Vowels and Consonants in a string in C#
13Program to check whether the entered year is Leap Year or Not in C#
14Program to remove the duplicate character from the string

I hope these programs will help you in cracking your interview.

Thanks

Program to find Factor of a number in C#

Write a program to find the Factor of a number entered by the user. 

The basic approach to solve this problem is to find the number(s) (Factors) which can divide the number entered by the user with no remainder left i.e. 0. In simple words, a factor divides a number completely without leaving any remainder.

Thursday 20 August 2020

Working up with Google Kubernetes Engine in Google Cloud Platform

In this article, we will learn How to get started with GKE i.e. Google Kubernetes Engine in Google Cloud Platform. GKE provides the easiest and simplest way to set up the Kubernetes cluster. Kubernetes (K8s) is an Open Source system for automating deployment, scaling, and management of the containerized applications.

Wednesday 12 August 2020

Getting Started with Cloud SQL in Google Cloud Platform

In this article, we will learn How to get started with Cloud SQL in Google Cloud Platform. We will start with the creation of a VM Instance. Then we create a MySQL DB in the Cloud SQL and access that DB in the Web application hosted in the VM Instance created in the Google Cloud Platform. 

Sunday 9 August 2020

Tuesday 4 August 2020

Create Virtual Machine instance in Compute Engine in Google Cloud Platform

In this article, we will learn How to create VM Instances with Google Cloud Platform’s Compute Engine. We will start with creating VM Instance with GCP Console and then achieve the same thing with the GCP Command Line utility i.e. GCloud. Then we will install the NGINX web server and host the web page and access it on another VM machine and through the internet.

Saturday 1 August 2020

Setting up LAMP Certified by Bitnami in Google Cloud Platform

In this article, we will set up a LAMP Stack for web applications in the Google Cloud Platform. LAMP is one of the common examples of the Web Service Stack which basically Stands for Linux, Apache, MySQL, PHP. In this article, we will set up LAMP using Bitnami Certified Apps which provide secure, up-to-date, and packaged using industry best practices.

Saturday 30 May 2020

Subscribe us on YouTube

Subscribe Now

Popular Posts

Contact us

Name

Email *

Message *

Like us on Facebook

Blog Archive