S
sathyashrayan
I have got a book called "Practical C Programming", ISBN:1-56592-306-5
Publisher: O'Reilly.In that book I am doing some programming exercises.
Below is a one which I have got stuck.
Exercise 4-2: Write a program to print a block E using asterisks (*), where
the E has a height of seven characters and a width of five characters.
The solution which I have tried is
#include<stdio.h>
int main(void)
{
unsigned short i;
for(i=0;i<8;i++)
{
printf("*");
if((i == 1) && (i < 5))
{
printf("*\n");
}
if((i == 5) && (i < 9))
{
printf("*");
}
if(i < 7)
{
printf("*\n");
}
}
return 0;
}
not correct. Can any one give me the logic(*dont give out the solution
or the coding*). Thanks.
Publisher: O'Reilly.In that book I am doing some programming exercises.
Below is a one which I have got stuck.
Exercise 4-2: Write a program to print a block E using asterisks (*), where
the E has a height of seven characters and a width of five characters.
The solution which I have tried is
#include<stdio.h>
int main(void)
{
unsigned short i;
for(i=0;i<8;i++)
{
printf("*");
if((i == 1) && (i < 5))
{
printf("*\n");
}
if((i == 5) && (i < 9))
{
printf("*");
}
if(i < 7)
{
printf("*\n");
}
}
return 0;
}
not correct. Can any one give me the logic(*dont give out the solution
or the coding*). Thanks.