Program to print digits triangle in C

c-techaravind


                                              To compile and execute the program, copy the code into a text file. Save the text file with the extinction .c (ex. program.c). Save your file in turboc2 or borland (it may your othe c-compiler). Now open you IDE (tc.exe) , goto file->pick file. Your source file will be loaded into IDE. Now you can compile and run the file easily.








#include<stdio.h>
#include<conio.h>
void main()
{
int p,q,m,n;
clrscr();
gotoxy(31,1);
printf("Digits triangle");
gotoxy(26,3);
printf("www.techaravind.blogspot.com");
gotoxy(1,5);
printf("Enter no.of lines:");
scanf("%d",&n);
 for(p=1;p<=n+1;p++)
{
 for(q=1;q<=n+1-p;q++)
 printf(" ");
m=1;
for(q=1;q<p;q++)
printf("%d",m++);
m=m-1;
for(q=2;q<p;q++)
printf("%d",--m);
printf("\n");
}
     getch();
}

0 comments:

Post a Comment

 
Etutos © 2010-2011