LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-28-2006, 05:00 AM   #1
knockout
LQ Newbie
 
Registered: Apr 2006
Posts: 2

Rep: Reputation: 0
GCC problem


hey there
iam doing GCC cource ... i have found this problem

i have to output :

1
222
33333
4444444
555555555
using two for loops

i did like this :
#include <stdio.h>
int a,b
int main() {
for(a=1;a<6;a++){
for(b=1;b<=a;b++){
printf("%d\n",b);
}
printf("\n");
}
but i didnt get the output like above



}
 
Old 04-28-2006, 05:33 AM   #2
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
1. you have syntax errors forgot; and to close brankets
2. use the[code] tags like this to make your code readable
Code:
#include <stdio.h>
int main()
{
   printf("I'm main");
}
3. from LQ rules

Quote:
Do not expect LQ members to do your homework - you will learn much more by doing it yourself.
4. Try harder. It's really-really easy.

Last edited by perfect_circle; 04-28-2006 at 05:36 AM.
 
Old 04-28-2006, 06:34 AM   #3
llmmix
Member
 
Registered: Jun 2005
Posts: 73

Rep: Reputation: 15
#include <stdio.h>

int
main(void)
{
int a=0,b=0,c=0;

for(a=1; a<6; a++){
++c;
for()
printf("%d",c);
printf("\n");
}

return 0;
}

;-p

Last edited by llmmix; 04-28-2006 at 06:36 AM.
 
Old 04-28-2006, 06:38 AM   #4
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
[HTML]3. from LQ rules

Quote:
Do not expect LQ members to do your homework - you will learn much more by doing it yourself.

4. Try harder. It's really-really easy.[/HTML]

Hey dont scare a newbie

You can use "splint" [ a tool that will probably be installed in your system] to check for syntax errors in your c file.

The syntax is simple

splint filename.c

Or try gcc with -Wall option

gcc -Wall filename.c

Cheers
Zulfi
 
Old 04-28-2006, 08:57 AM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Just remember that every statement in C needs to be terminated with a semicolon. If a statement is not properly terminated, the compiler normally only spots it when it reaches the next line. What this means is that warning messages often refer to the previous line.

I hope that helps. But if you are still unclear post your modified code and we can help you, we'll not do it but we will help.

cheers,

graeme.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Solved Problem Second GCC-Pass(or gettext sanity check problem) hoes Linux From Scratch 0 09-04-2005 10:20 AM
problem with gcc or me? kahn Programming 6 06-13-2005 03:20 AM
gcc problem krock923 Programming 13 03-15-2005 08:28 AM
GCC problem... I think... eqxro Mandriva 4 08-23-2004 05:38 PM
problem with gcc ptwobrussell Linux - Software 4 09-08-2003 04:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration