This is the continuation of Getting Started with MongoDB Atlas - Part 1. Our Dataset is ready. Now let’s create a .Net Core Console App through which we will try to access one of the collections in the MongoDB Atlas cluster.
Friday 11 December 2020
Getting Started with MongoDB Atlas - Part 2
Getting Started with MongoDB Atlas - Part 1
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.
//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:
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:
Setting Up LAMP Certified by Bitnami In Google Cloud Platform
Create Virtual Machine Instance in Compute Engine in The Google Cloud Platform
Create a storage bucket in Google Cloud Platform
Getting Started with Cloud SQL in Google Cloud Platform
Working Up With Google Kubernetes Engine In Google Cloud Platform
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:
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:
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.
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(); |
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(); |
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.
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:
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:
Monday 7 September 2020
Program to find the occurrence of the character in a string in C#
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.
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(); |
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(); |
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:
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.