Can someone teach me? Thx!!!

T

tianyi

I'm the beginner of C programming. And my teacher give a question I don't
know how to do. Can someone teach me? Thx!!

The Question is: To print out four *,and skip one line. The print out
like: ****

****

****

****


If someone can help me?
 
J

Jason Whitehurst

tianyi said:
I'm the beginner of C programming. And my teacher give a question I
don't know how to do. Can someone teach me? Thx!!

Have you tried? Show us what you came up with...
 
T

tianyi

for (i=1; i<=5; i++)
{
for(j=1; j<=i; j++)
{
for(K=1; k<=4; k++)
printf ("*");
printf("\n");
}
printf("\n");
}
 
T

tianyi

for (i=1; i<=5; i++)
{
for(j=1; j<=i; j++)
{
for(K=1; k<=4; k++)
printf ("*");
printf("\n");
}
printf("\n");
}
 
E

E. Robert Tisdale

tianyi said:
for (i=1; i<=5; i++)
{
for(j=1; j<=i; j++)
{
for(K=1; k<=4; k++)
printf ("*");
printf("\n");
}
printf("\n");
}

Great!
Did you try to compile it?
 
M

Mike Wahler

tianyi said:
I'm the beginner of C programming. And my teacher give a question I don't
know how to do. Can someone teach me? Thx!!

The Question is: To print out four *,and skip one line. The print out
like: ****

****

****

****


If someone can help me?

#include <stdio.h>

int main()
{
int i = 0;

putchar('*'); /* print a single asterisk */

putchar('\n'); /* print out a 'newline' character */
/* i.e. a blank line.

printf("\n\n"); /* print two blank lines */

for(i = 0; i < 10; ++i) /* print ten asterisks */
putchar('*');

printf("%s\n", "***"); /* print three astersiks followed */
/* by a 'newline' character */
return 0;
}

The above should be enough information for you to figure
out how to do your assignment.

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,538
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top