Switch to full style
Codes, tips and tricks,discussions and solutions related to C#
Post a reply

C program that displays shapes. Keep getting errors.

Sun Oct 10, 2010 11:10 pm

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

Code:
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);
}




Post a reply
  Related Posts  to : C program that displays shapes. Keep getting errors.
 errors in commission program     -  
 C++ DES Encryption Package - Errors?     -  
 BASE64Encoder/ BASE64Decoder & BadPaddingException errors.     -  
 JRadioButtons- Example- displays two JRadioButtons     -  
 HOW TO DO C++ PROGRAM?     -  
 java program     -  
 what is the output of this program and how it be?     -  
 how can i DeployPHP Program     -  
 write a program in c++ for the following...     -  
 run .exe program in matlab     -