Posts

Showing posts from January, 2016

Program For Printing Digits In Larger Size

Image
In this program it will receive  numbers in digits and print in larger format as shown here: #include<stdio.h> #include<conio.h>  void main()  { int k,j,i,s,n=8; int arr[5]; clrscr(); printf("Enter the lenth of the number"); scanf("%d",&s); printf("Enter the number to print it in large format"); for(i=0;i<s;i++) { scanf("%d",&arr[i]); } for(i=0;i<8;i++) { for(k=0;k<9;k++) { if(arr[k]==0)       { if(i==0||i==n-1) printf(" ""###"" "); else printf("#"" "" "" ""#"); printf(" "); } if(arr[k]==1) { if(i==1) printf("##"); else    if(i==n-1) { printf("###"); } else    printf(" ""#"); printf(" "); } if(arr[k]==2) { if(i==0||i==4||i==7) printf("#####"); else if(i==5||i

Solving Puzzle In C

Image
This program is for solving  puzzle using a c program : In this there are 15 numbered square pieces mounted on a frame. these pieces can be moved horizontally or vertically.a possible arrangement of these pieces is shown below:  here the last block is empty . #include<stdio.h> #include<conio.h> #include<graphics.h> void main() { int a[4][4]={1,4,15,7,8,10,2,11,14,3,6,13,12,9,5};             int ch,i,j,n=0,k,l; i=3; j=3; clrscr(); for(k=0;k<4;k++) { for(l=0;l<4;l++) {       printf("\t"); textcolor(4+BLINK);          /*here the number in textcolor (4)specifies the  red  color                                                                           in c there are seven color and we can use them using                                                                                numbers from 1,2,.....7.*/ textbackground(2); cprintf("%d",a[k][l]); } printf("\n"); } textc

Heap Sort Without using Recursion

#include<stdio.h> #include<stdlib.h> #include<conio.h> void makeheap(int a[],int *); int heapsort(int a[],int *); void main() { int a[8]={23,55,46,35,10,90,84,31},b[8],t=7,i=0; clrscr(); printf("before sorting\n"); makeheap(a,&t); for(i=0;i<=t;i++) { printf("%d\t",a[i]); } printf("\nafter sorting\n"); for(i=0;i<=7;i++) { b[i]=heapsort(a,&t); t--; makeheap(a,&t); } for(i=0;i<=7;i++) { printf("%d\t",b[i]); } getch(); } void makeheap(int a[],int *m) { int i=0,j,k,t; int l; l=(*m)/2 ; for(j=0;j<l;j++) { for(k=0;k<2;i++,k++) { if(a[j]<a[i+1]) { t=a[j]; a[j]=a[i+1]; a[i+1]=t; } if(a[0]<a[j]) { t=a[j]; a[j]=a[0]; a[0]=t; } } } } int  heapsort(int a[],int *p) { int t=0; t=a[*p]; a[*p]=a[0]; a[0]=t; return(a[*p]); }