Posts

Showing posts from June, 2017

pattern with sound

Image
//print pattern with background sound..... keep your mother board speaker connected...... #include<stdio.h> #include<conio.h> #include<dos.h> void main() { int i,j,m,k=1,t=1;//,g; clrscr(); printf("enter the height"); scanf("%d",&m); printf("\n\n"); for(i=0;i<m;i++) { for(j=0;j<m;j++) { textcolor(t); textbackground(t+1); t++; sound(30*(k++)*2); if((i==0 || i==m-1) || (j==0 || j==m-1)) cprintf(" *"); else if(i==j) cprintf(" $"); else cprintf(" #"); delay(100); } printf("\n"); } nosound(); getch(); }

pattern

Image
/*pattern G F E D C B A  F E D C B A   E D C B A    D C B A     C B A      B A       A       */ #include<stdio.h> #include<conio.h> void main() { int p=65,n,m,i,j,t; clrscr(); printf("\nEnter the height of the pattern : "); scanf("%d",&n); printf("\n\n"); for(i=n-1;i>=0;i--) { p=65+i; for(j=0;j<n-i;j++) printf(" "); for(j=0;j<=i;j++) printf("%c ",p--); printf("\n"); } getch(); } I/O :

simple example of calloc

//example of using calloc #include<stdio.h> #include<conio.h> void main() { int *p; int n,i; printf("\nEnter the number of elements : "); scanf("%d",&n); p=(int *)calloc(n,sizeof(int)); printf("\nEnter the values : "); for(i=0;i<n;i++) scanf("%d",(p+i)); printf("\nValues are :"); for(i=0;i<n;i++) printf("%d,",*(p+i)); getch(); } Input / Output : Enter the number of elements : 6 Enter the values : 12 23 34 45 56 67 Values are :12,23,34,45,56,67,