Pages

Of Computers, troubles and my Experiments with programming as a beginner.

Wednesday, May 14, 2008

004: Book1,Chapter 1,Program 4

Problem Statement:
1.4 Write a program that will print the following figure using suitable characters
---- ----
>>-------->
---- ----

Solution:
Yet another trick where you have to know to align characters. That's all. I'll be honest and tell you that, I achieved it using trial and error. I mean, no matter how well you count, the alignment screws up on it's own. :) Nothing better than running the program.

Program:
/*Program 1.1.4 */
#include stdio.h
/*This is a header file.*/
#include conio.h
/*This is another header file that we require for using getch()*/

int main()
{
printf("\n ---- ---- ");
printf("\n >>--------> ");
printf("\n ---- ---- ");
getch();
return 0;
}

Output:
---- ----
>>-------->
---- ----

Description:
Quite Simple again. Not much to explain. Do read up on 001 through 003 to get to know the previous programs.

printf()

No comments: