LinuxQuestions.org
Review your favorite Linux distribution.
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


Closed Thread
  Search this Thread
Old 10-10-2010, 06:24 PM   #1
boilers969
Member
 
Registered: Oct 2010
Posts: 55

Rep: Reputation: 0
Supposed to print shapes. Not sure what is wrong. Help me.


Here is my program. I've been working on it for over 20 hours and I'm stuck. It asks the user for input and then prints a shape of a certain length. The errors I get when I compile are:

shape.c: In function âmainâ:
shape.c:22: error: expected identifier or â(â before âintâ
shape.c:58: error: expected expression before âreturnâ
shape.c:59: error: expected expression before â}â token
shape.c:59: error: expected expression before â}â token

Please help! Thank you!


Code:
#include<stdio.h>

int main()
{
while(1>0){
char shape;
char s,h,f;
shape='s';
shape='h';
shape='f';
int row;
printf("Enter shape type (s/h/f):");
scanf("%c",&shape);
printf("Enter shape length: ");
scanf("%d",&row);
if(row<=0)
printf("Shape length cannot be negative. Try again\n");
}
for(int s=1,int h=2,int f=3){
switch(s,h,f)
{
case 1:
{int i,row;
for(i=row;i>=1;i--)
printf("*\n");
break;}
case 2:
{int i,j,k,row,m;
m=row;
for(i=1 ; i<=m; i++)
{
for (j=1 ; j>=row; j--)
printf(" ");
{for(k=1; k<=i; k=k+1)
printf("*");
printf("\n");}}
break;}
case 3:
{int i,j,k,row,m;
m=row;
for(i=0;i<m;i++)
{
printf("\n");
for(k=0;k<row;k++)
printf(" ");
for(j=0;j<=i;j++)
printf(" *");
row--;
}
printf("\n");
break;}
default:
break;
}}
return(0);
}
 
Old 10-10-2010, 06:33 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by boilers969 View Post
Here is my program. I've been working on it for over 20 hours and I'm stuck. It asks the user for input and then prints a shape of a certain length. The errors I get when I compile are:

shape.c: In function âmainâ:
shape.c:22: error: expected identifier or â(â before âintâ
shape.c:58: error: expected expression before âreturnâ
shape.c:59: error: expected expression before â}â token
shape.c:59: error: expected expression before â}â token

Please help! Thank you!


Code:
#include<stdio.h>

int main()
{
while(1>0){
char shape;
char s,h,f;
shape='s';
shape='h';
shape='f';
int row;
printf("Enter shape type (s/h/f):");
scanf("%c",&shape);
printf("Enter shape length: ");
scanf("%d",&row);
if(row<=0)
printf("Shape length cannot be negative. Try again\n");
}
for(int s=1,int h=2,int f=3){
switch(s,h,f)
{
case 1:
{int i,row;
for(i=row;i>=1;i--)
printf("*\n");
break;}
case 2:
{int i,j,k,row,m;
m=row;
for(i=1 ; i<=m; i++)
{
for (j=1 ; j>=row; j--)
printf(" ");
{for(k=1; k<=i; k=k+1)
printf("*");
printf("\n");}}
break;}
case 3:
{int i,j,k,row,m;
m=row;
for(i=0;i<m;i++)
{
printf("\n");
for(k=0;k<row;k++)
printf(" ");
for(j=0;j<=i;j++)
printf(" *");
row--;
}
printf("\n");
break;}
default:
break;
}}
return(0);
}
Isn't this: http://www.linuxquestions.org/questi...errors-837239/ thread describing the same problem ?
 
Old 10-10-2010, 06:35 PM   #3
boilers969
Member
 
Registered: Oct 2010
Posts: 55

Original Poster
Rep: Reputation: 0
Yes I just re-posted it hoping someone else would be able to help.
 
Old 10-10-2010, 06:39 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by boilers969 View Post
Yes I just re-posted it hoping someone else would be able to help.
You are not supposed to do so. I replied in the original thread.
 
Old 10-10-2010, 10:39 PM   #5
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread



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
C program that displays shapes. Keep getting errors. boilers969 Programming 101 10-12-2010 12:56 AM
C program that displays shapes. Keep getting errors. boilers969 Programming 12 10-10-2010 10:36 PM
[SOLVED] What kind of code has shapes in it? theKbStockpiler Programming 2 09-11-2010 01:33 AM
LXer: IntelliJ's Maia shapes up against Eclipse LXer Syndicated Linux News 0 05-29-2009 11:01 PM
prinf: what was it supposed to print kpachopoulos Programming 1 11-28-2007 02:36 AM

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

All times are GMT -5. The time now is 09:22 PM.

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