DreamsCoder.com

We Code your Dreams
home > c programs

Spinning letters in using C - graphics





Spinning letters in using C - graphics

#include
#include

void main()
{
int j;
char str[40]="SPINNING LETTERS IN C - 
DREAMSCODER.COM";
clrscr();
textcolor(14);
gotoxy(25,6); //pointing to x,y

	for(j=0;j<39;j++)
	{
		gotoxy(25+j,6);
		cprintf("|"); delay(30);
		gotoxy(25+j,6);
		cprintf("/"); delay(30);
		gotoxy(25+j,6);
		cprintf("-"); delay(30);
		gotoxy(25+j,6);
		cprintf("\\"); delay(30);
		gotoxy(25+j,6);
		cprintf("|"); delay(30);
		gotoxy(25+j,6);
		cprintf("%c",str[j]);
		delay(50);
	}//for
getch();
}//void main

Label - c





Pascal triangle program in C language





Pascal triangle program in C language

#include
#include
int fact(int x);
void main()
{
int i,j;
clrscr();
	for(i=0;i<=7;i++)
		{
	for(j=0;j<=i;j++)
		{
	printf("%d ",(fact(i)/(fact(j)*fact(i-j))));
		}
	printf("\n");
	}
	getch();
}

int fact(int x)
{
	if(x>0)
	return(x*fact(x-1));
	else
	return 1;
}

Label - c





What is the difference between ARRAY and STACK?



Label - c





Displaying Matrix in C





Displaying Matrix in C

#include
#include

void main()
{
int i,j,a=4,b=0;
clrscr();

for(i=0;i<5;i++)
{
	for(j=0;j<5;j++)
	{
	if(i>=j)
	printf(" +1");
	if(j>=i)
	printf(" -1");
	if(i==b&&j==a)
	{
	printf(" 0");
	a--;
	b++;
	}
	}//inner for
	printf("\n");
}//outer for
getch();
}           //main

Label - c





Pascal triangle program in C language





Pascal triangle program in C language

#include
 
long factorial(int);
 
main()
{
   int i, n, c;
 
   printf("Enter the number of rows you wish 
to see in pascal
   triangle\n");
   scanf("%d",&n);
 
   for ( i = 0 ; i < n ; i++ )
   {
      for ( c = 0 ; c <= ( n - i - 2 ) ; c++ )
         printf(" ");
 
      for( c = 0 ; c <= i ; c++ )
         printf("%ld ",factorial(i)/(factorial(c)*factorial(i-c)));
 
      printf("\n");
   }
 
   return 0;
}
 
long factorial(int n)
{
   int c;
   long result = 1;
 
   for( c = 1 ; c <= n ; c++ )
         result = result*c;
 
   return ( result );
}

Label - c





next page >






Privacy Policy
Copyright © 2018 by DreamsCoder. All Rights Reserved.
DreamsCoder Google Plus DreamsCoder Facebook



Latest Technology,Tricks and Tips