Tuesday, July 14, 2009

How to write this programe in Turbo C language?

Plz use Turbo C language instead of C++.And have to use for loops etc in this program.use stdio.h n conio.h only n use


printf() etc.................





........1


......121


....12321


..1234321


123454321


..1234321


....12321


......121


........1

How to write this programe in Turbo C language?
#include %26lt;stdio.h%26gt;





int main(void)


{


int i, w = 5, dx = 1;





for (i = 1; i %26gt;= 1; i += dx)


{


int pad;


if (i == w) dx = -1;


for (pad = w; pad %26gt; i; --pad)


putchar(' ');


for (pad = 1; pad %26lt;= i; ++pad)


putchar('0' + pad); /* This line prints eg: 1234 */


for (pad = i - 1; pad %26gt;= 1; --pad)


putchar('0' + pad); /* This line prints eg: 321 */


putchar('\n');


}


return 0;


}


No comments:

Post a Comment