Top C# Programs with solutions for beginners to practice. Fibonacci Series, Prime, Palindrome, Armstrong, loops, Swap, Pyramids , Triangles, and many more
- C# Program to Check Whether a Number is Prime or Not
In this C# program, we will take input from the user and check whether the number is prime or not. A prime number is a positive integer that is divisible only by 1 and itself.
- C# Program to Calculate Sum of first N natural numbers
In this C# program, we will take input from the user and generate the sum of first N natural Numbers. The sum of natural numbers up to 10 is: 1+2+3+4+5+6+7+8+9+10=55
- C# Program to swap two numbers without using the third variable
In this C# program, we will swap two numbers without using the third variable. We will use two methods to swap numbers 1) By using Addition and Subtraction 2) By using Multiplication and Division
- C# Program to print prime numbers from 1 to N
In this C# program, we will take input from the user and print prime numbers between 1 and the number input by the user. A prime number is a positive integer that is divisible only by 1 and itself.
- C# Program to print perfect numbers from 1 to N
In this C# program, we will take input from the user and print perfect numbers between 1 and the number input by the user. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance, 6 has divisors 1, 2 and 3, and 1 + 2 + 3 = 6, so 6 is a perfect number.
- C# Program to print even numbers from 1 to N
In this C# program, we will take input from the user and print even numbers between 1 and the number input by the user. A even number is a positive integer that is exactly divisible by 2.
- C# Program to print odd numbers from 1 to N
In this C# program, we will take input from the user and print odd numbers between 1 and the number input by the user. An odd number is a positive integer that is not divisible by 2.
- C# Program to Check Whether a Number is Even or Odd
In this C# program, we will take input from the user and check whether a number is even or odd. An Even number is a positive integer that is divisible by 2 and An odd number is a positive integer that is not divisible by 2.
- C# Program to Check Whether a Number is Positive or Negative
In this C# program, we will take input from the user and check whether a number is Positive or Negative. A Positive number is a number that is greater than 0 and a Negative number is a number that is lesser than 0.
- C# Program to generate a sum of digits
In this C# program, we will take input from the user and generate a sum of digits. For example, if the user input 88 then result is 16.
- C# Program to Generate a Multiplication Table of a given integer
In this C# program, we will take input from the user and generate a multiplication table.
- C# Program to Calculate the Area of a Circle
In this C# program, we will take input (radius) from the user and calculate the area of a circle. Formula to calculate area of circle is A= π*r*r.
- C# Program to Calculate the Area of a Square
In this C# program, we will take input (side) from the user and calculate the area of a square. Formula to calculate area of Square is A= (side of square*side of square).
- C# Program to Calculate the Area of a Rectangle
In this C# program, we will take input (Length and Width) from the user and calculate the area of a Rectangle. Formula to calculate area of Rectangle is A= Length*Width.
- C# Program to Calculate the Area of a Triangle
In this C# program, we will take input (Base and Height) from the user and calculate the area of a Triangle. Formula to calculate area of Triangle is A= (base*height/2).
- C# Program to Check Whether a Number is Palindrome or Not
In this C# program, we will take input from the user and Check Whether a Number is Palindrome or Not. A number is a palindrome if the reverse of that number is equal to the original number.
- C# Program to Check Whether a String is Palindrome or Not
In this C# program, we will take input from the user and Check Whether a String is Palindrome or Not. A String is a palindrome if the reverse of that String is equal to the original
- C# Program to Print Fibonacci Series
The Fibonacci sequence is a sequence where the next number is the sum of the previous two numbers. The first two numbers of fibonacci series are 0 and 1.
- C# Program to Find Factorial of a Number
In this C# program, we will take input from the user and Find the Factorial of a Number using 3 different ways using 1) For loop 2) Recursion 3) While loop. The factorial of a positive number n is given by n!. 5!=5*4*3*2*1=120
- C# Program to print Alphabet Triangle
In this C# program, we will take input (Number of rows) from the user and print the alphabet triangle based on the number of rows input by the user.
- C# Program to print Number Triangle
In this C# program, we will take input (Number of rows) from the user and print the Number triangle based on the number of rows input by the user.
- C# Program to print Star Triangle
In this C# program, we will take input (Number of rows) from the user and print the Star (*) triangle based on the Number of rows input by the user.
- C# Program to print Diamond Shape
In this C# program, we will take input (Number of rows) from the user and print the diamond shape based on the Number of rows input by the user.
- C# program to change case of a string
In this C# program, we will take the input string from the user and change it to 1)Upper Case 2)Lower Case 3)Title Case.
- C# program to add and subtract days from the date
In this C# program, we will add and subtract days from the date.
- C# Program to Check Leap Year
In this C# program, we will take the input from the user and check whether the input year is a Leap Year or not. Leap year is a year which is divisible by 4.
- C# program to compare two dates
In this C# program, we will compare two dates and print the result.
- C# program to convert days into years, weeks and days
In this C# program, we will take the input (days) from the user and Convert days into years, weeks and days.
- C# Program to Print Day Name of Week
In this C# program, we will take the input from the user and print day name of week.
- C# Program to convert Celsius into Fahrenheit
In this C# program, we will take the input Celsius from the user and change it to Fahrenheit.
- C# Program to Convert Number into Words
In this C# program, we will take the input number from the user and change it to Words. E.g. 1024 will be converted to One Thousand Twenty Four only.
- C# Program to Convert Meters To Kilometers
In this C# program, we will take the input meters from the user and change it Kilometers.
- C# program to calculate Simple Interest
In this C# program, we will take the input "Principal Amount", "Interest Rate" and "Time" from the user and calculate the simple interest.
- C# program to calculate Compound Interest
In this C# program, we will take the input "Principal Amount", "Interest Rate", "Interest Compound Frequency" and "Time" from the user and calculate the simple interest.
- C# Program to Find GCD of two Numbers
In this C# program, we will take the input from the user and find GCD of two numbers.
- C# Program to Find LCM of two Numbers
In this C# program, we will take the input from the user and find LCM of two numbers.
- C# Program to Find HCF of two Numbers
In this C# program, we will take the input from the user and find HCF of two numbers.
- C# program to reverse an array elements
In this C# program, we will reverse an array without using Array.Revers() Method.
- C# Program to concatenate two strings
In this C# program, we will take the input strings from the user and print the concatenated string.
- C# Program to read the content of a file
In this C# program, we will read the content of the Text file and print the content of the file.
- C# Program to Check Whether a Character is a Vowel or Consonant
In this C# program, we will take the input from the user and Check Whether a Character is a Vowel or Consonant.
- C# switch example
In this C# program, we will learn how to implement a switch case in C#. We will use a switch statement to display the name of the day based on the input entered by the user.
- C# For Loop with examples
In this C# program, we will see For Loop with examples.
- C# While Loop with examples
In this C# program, we will see While Loop with examples.
- C# Do While Loop with examples
In this C# program, we will see Do While Loop with examples.
- C# Remove last specific character in a string
In this C# program, we will see how to Remove last specific character in a string. In this example we will remove last , from the string.
- C# Program to Convert a List to a comma separated string
In this C# program, we will see how to Convert a List to a comma separated string.