Category Archives: Programs

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 »

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(); }

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 »

WAP to show Upper matrix

#include <stdio.h> #include <conio.h> void main() { int a[5][5] = {1,2,3,4,5, 0,2,3,4,5, 0,0,3,4,5, 0,0,0,4,5, 0,0,0,0,5},i,j,k,flag = 0,temp=0; for(i=0;i<5;i++) { for(k=0;k<i;k++) { if(a[i][k]==0) { flag = 0; } else { flag = 1; printf(“\n Matrix is not Upper Triangular “); getch(); exit(0); } } if(flag == 0) { for(j=i;j<5;j++) { if(a[i][j]!=0) { temp = 0; }… Read More »