C# Program to Print the Sum of all the Multiples of 3 and 5

using System; namespace ConsoleApp2 { class Program { public static void Main() { int number, i, k, count = 1; Console.Write(“Enter number of rows\n”); number = int.Parse(Console.ReadLine()); count = number – 1; for (k = 1; k <= number; k++) { for (i = 1; i <= count; i++) Console.Write(” “); count–; for (i = […]

Read More

C# Program to Display Numbers in the form of Triangle

using System; class Pascal { public static void Main() { int[,] arr = new int[8, 8]; for (int i = 0; i < 8; i++) { for (int k = 7; k > i; k–) { //For loop to print spaces Console.Write(” “); } for (int j = 0; j < i; j++) { if […]

Read More

Count the frequency of each element of an array

In this program, we will count the frequency of each element of an array. Example: Elements in the array [1,8,4,2,8,1,4,8,9,8] Output: 1 occurs 2 times 8 occurs 4 times 4 occurs 2 times 2 occurs 1 times 9 occurs 1 times   using System; namespace ConsoleApp2 { class Program { static void Main(string[] args) { […]

Read More

Fibonacci Series in c#

The Fibonacci Series is a series where the next term is the sum of previous two terms. The first two terms of the Fibonacci Series is 0 followed by 1. The Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21. Example: using System; namespace ConsoleApp1 { class Program { static int FibonacciSeries(int n) […]

Read More

Program to Check Armstrong Number

Here, we will Check Whether the entered number is an Armstrong Number or Not. An Armstrong number is a number such that the sum of its digits raised to the third power is equal to the number itself. For example, 371 is an Armstrong number, since  3**3 + 7**3 + 1**3 = 371. using System; namespace ConsoleApp1 { […]

Read More

Program to check the number is palindrome or not.

A palindromic number or numeral palindrome is a number that remains the same when its digits are reversed. Like 16461, for example, it is “symmetrical”. The term palindromic is derived from palindrome, which refers to a word (such as rotor or racecar) whose spelling is unchanged when its letters are reversed. Example:   class Program […]

Read More

Program to print ASCII characters

ASCII (American Standard Code for Information Interchange) is a character encoding standard (the Internet Assigned Numbers Authority (IANA) prefers the name US-ASCII. ASCII codes represent text in computers, telecommunications equipment, and other devices. Most modern character-encoding schemes are based on ASCII, although they support many additional characters. Exmple:   class Program { static void Main(string[] […]

Read More

Program to Reverse the Number

In below program, I will reverse a number in c#.   class Program { static void Main(string[] args) { int num, rem, sum = 0, rev; Console.WriteLine(“\n /** To Find Reverse Of a Number **/”); Console.Write(“\n Enter a number: “); num = Convert.ToInt32(Console.ReadLine()); while (Convert.ToBoolean(num)) { rem = num % 10; //for getting remainder by […]

Read More

Binary search tree or AVL tree

# Program to insert contents of file in Binary search tree or AVL tree # It calculates total time it took for the insertion of all the elements # It also calcultaes average height of the tree formed and height of any particaluar node # Average height is the average of lenghts of all the […]

Read More

WAP to show saddle point

#include<stdio.h> #include<conio.h> void main() { int a[3][3] = {1,2,3, 4,5,6, 7,8,9},i,j,k,value=0,temp=0,max=0; value = a[0][0]; printf(“\n Matrix Is “); for(i=0;i < 3;i++) { printf(“\n”); for(j=0;j < 3;j++) { printf(“\t%d”,a[i][j]); } } for(i=0; i < 3;i++) { value = a[i][0]; for(k=0;k < 3;k++) { if(value > a[i][k]) { value = a[i][k]; temp = k; } } max […]

Read More

WAP to convert Sparse matrix to original matrix

//Sparse to Original Type -I #include <stdio.h> #include <conio.h> void main() { int a[5][5] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},i,j,k=1,sp[5][3] = {5,5,4, 0,2,5, 2,0,2, 3,4,9, 4,0,3}; for(k=1;k<5;k++) { a[sp[k][0]][sp[k][1]] = sp[k][2]; } printf(“\n Original Matrix “); for(i=0;i<5;i++) { printf(“\n”); for(j=0;j<5;j++) { printf(“\t%d”,a[i][j]); } } getch(); }

Read More

WAP to convert original matrix to Sparse matrix

#include <stdio.h> #include <conio.h> void main() { int a[5][5] = {0,0,5,0,0, 0,0,0,0,0, 2,0,0,0,0, 0,0,0,0,9, 3,0,0,0,0},i,j,sp[5][3],k=1; sp[0][0] = 5; sp[0][1] = 5; sp[0][2] = 4; for(i=0;i<5;i++) { for(j=0;j<5;j++) { if(a[i][j]!=0) { sp[k][0] = i; sp[k][1] = j; sp[k][2] = a[i][j]; k++; } } } printf(“\n Sparce Matrix “); for(i=0;i<5;i++) { printf(“\n”); for(j=0;j<3;j++) { printf(“\t%d”,sp[i][j]); } } […]

Read More

Double Queue in Data Structure

#include <stdio.h> #include <conio.h> void main() { int CQ[10],i,front = -1,rear = -1,ch,x; do { printf(“\n 1:Insert “); printf(“\n 2:Delete”); printf(“\n 3:Display”); printf(“\n 0:Exit”); printf(“\n Enter your Choice “); scanf(“%d”,&ch); switch(ch) { case 1: if(front == 0 &&((rear == 9)||(rear+1 == front))) { printf(“\n Queue is Full”); break; } if(front == -1) front = rear […]

Read More

Stack in C

#include <stdio.h> #include <conio.h> #include <process.h> void main() { int stack[10],top = -1,x,ch,i; do { printf(“\n Press 1: Push “); printf(“\n Press 2: Pop “); printf(“\n Press 3: Display “); printf(“\n Press 0: Exit “); printf(“\n Enter your choice “); scanf(“%d”,&ch); switch (ch) { case 1: { if(top >=9) { printf(“\n Stack is full “); […]

Read More

Pointer to Structure

#include <stdio.h> #include <conio.h> struct Student { char Name[10]; int Roll_NO; float Per; }; void main() { Student s1,*st; printf(“\n Enter the Name “); gets(s1.Name); printf(“\n Enter the Roll Number “); scanf(“%d”,&s1.Roll_NO); printf(“\n Enter Percentage “); scanf(“%f”,&s1.Per); st = &s1; printf(“\n Name \t\t = %s”,st->Name); printf(“\n Roll Number \t = %d”,st->Roll_NO); printf(“\n Percentage \t = […]

Read More