423,516 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,516 IT Pros & Developers. It's quick & easy.

Parse Error

P: 1
I'm trying to compile my program using "gcc" and keep getting a parse error at end of input. Can anyone help me?
Attached Files
File Type: txt rose_curve2.txt (918 Bytes, 207 views)
Nov 28 '08 #1
Share this Question
Share on Google+
2 Replies


gpraghuram
Expert 100+
P: 1,275
You were missing a couple of braces.
Check the following code
Expand|Select|Wrap|Line Numbers
  1. /* Program #25 -- file prgm25.c rev. 11/26/08
  2. This program will give you points on a graph
  3. in a file called "rosecurve.txt". These points
  4. will create a rose curve. */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <math.h>
  9.  
  10. float polar_to_x(float, float);
  11. float polar_to_y(float, float);
  12.  
  13. int main()
  14. {
  15.     float thata,temp,n,x,y,p,j,r=5,s=3;
  16.     int a,b;
  17.     FILE *output;
  18.  
  19.     output=fopen("rosecurve2.txt","wt");
  20.  
  21.     for(j=0;j<6.28;j+=0.01)
  22.     {
  23.         n=r/s;
  24.         temp=r*s;
  25.         for(a=1;a<31;a+=2)
  26.         if(temp==a)
  27.         {
  28.             thata=3.14159*s*1;
  29.             break;
  30.         }
  31.         for(b=0;b<32;b+=2)
  32.         if(temp==b)
  33.         {
  34.             thata=3.14159*s*2;
  35.             break;
  36.             {
  37.             x=polar_to_x(n,thata);
  38.             y=polar_to_y(n,thata);
  39.             fprintf(output,"%f %f\n",x,y);
  40.             }
  41.         }
  42.     }
  43.     fclose(output);
  44. }
  45.  
  46.  
  47. float polar_to_x(float n,float thata)
  48. {
  49.     float x;
  50.  
  51.     x=n*cos(thata);
  52.     return x;
  53. }
  54.  
  55. float polar_to_y(float n,float thata)
  56. {
  57. float y;
  58.  
  59. y=n*sin(thata);
  60. return y;
  61. }
  62.  
  63.  
Raghu
Nov 28 '08 #2

Banfa
Expert Mod 5K+
P: 8,916
You have a brace on your second if statement the wrong way round
Nov 28 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.