Anybody of you who wanted to help? I was totally glued to this problem. Its a program using for loop. I already figured out how to get the squares but I was totally cracked out in the format. My teacher told me that I should use gotoxy, to achieve this format. But I can't seem to figure this out.
NUMBERS SQUARES
1 1
2 4
3 6
4 16
5 25
Thank you in advance...
You have really helped a poor soul...
PS. OKay...I think i need to clarify this...Under NUMBERS is number 1-5, and under SQUARES are the squares of NUMBERS...I have edited this a lot of times but it doesn't go with me...^-^
Turbo C squares for loop?
Never used gotoxy before, but I think this should work...
#include %26lt;conio.h%26gt;
#include %26lt;stdio.h%26gt;
int main(void)
{
int i;
gotoxy(0,0);
printf("NUMBERS");
gotoxy(10,0);
printf("SQUARES");
for(i=1; i%26lt;=5; i++) {
gotoxy(0,10*i);
printf("%d",i);
gotoxy(10,10*i);
printf("%d",(i*i))
}
return 0;
}
Reply:1. If you're trying to use that gotoxy, first you map your intended output in coordinates. Then move cursor using gotoxy. Print there.
2. Try to use escape character \t (tab) to align the output.
3. If you're using stdio that's even easier because you just put the placeholder in the right position.
peony
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment