"Error - Expected initializer before 'int'

I can't figure out what I'm missing or what I did wrong, but I'm new to this and not very good at all so if it's completely wrong, just tell me and I'll work on it some more. The formatting with the "if else" statements is probably pretty sloppy. Error code is in line 9.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

    int m, d, year, choice, i, passed, orig, yy; 
    char more = 'y';
    int  days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int leap(int x)
int main()
{ 
{
  while (more == 'y' || more == 'Y') {
  	printf ("\n\tThis program will find days passed or date in the year");
  	printf ("\n\t\t\t1)  Input date (mm/dd/yyyy) to find dates passed");
  	printf ("\n\t\t\t2)  Input passed days to find date in the year");
  	printf ("\n\n\t\tYour choice (1/2): ");
  	scanf  ("%d",&choice);	}
  }
  		char letter (int c)
  		{
  		if (c == 1);{
  	
    int daysInMonth = 0;
    int daysPassed = 0;
    int leapyear = 0;     
    printf("\n\n\n\t\tPlease input date (mm-dd-yyyy): ");
    scanf ("%d/%d/%d", &m, &d, &year);
    if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
            leapyear=1;  
      switch(m-1)  {
        case 12:
          daysInMonth=31;
          daysPassed += daysInMonth;             
        case 11:
          daysInMonth=30;
          daysPassed += daysInMonth;
        case 10:
          daysInMonth=31;
          daysPassed += daysInMonth;
        case 9:
          daysInMonth=30;
          daysPassed += daysInMonth;
        case 8:
          daysInMonth=31;
          daysPassed += daysInMonth;
        case 7:
          daysInMonth=31;
          daysPassed += daysInMonth;
        case 6:
          daysInMonth=30;
          daysPassed += daysInMonth;
        case 5:
          daysInMonth=31;
          daysPassed += daysInMonth;
        case 4:
          daysInMonth=30;
          daysPassed += daysInMonth;
        case 3:
          daysInMonth=31;
          daysPassed += daysInMonth;
        case 2:
          if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
            leapyear=1;
            daysInMonth=29;
            daysPassed += daysInMonth;
          }  
          else{
            daysInMonth=28;
            daysPassed += daysInMonth;
          }    
        case 1:
          daysInMonth=31;
          daysPassed += daysInMonth;
        case 0:  
          if(m <=7 && m % 2 != 0 && d <= 31 || m >= 8 && m % 2 == 0 && d <= 31)   
            daysPassed += d;
          else 
            if(m == 2 && leapyear == 1 && d <= 29 || m == 2 && leapyear == 0 && d <= 28)
              daysPassed += d;
            else
             if(m <=6 && m % 2 == 0 && d <= 30 && m != 2|| m >= 9 && m % 2 != 0 && d <= 30)
               daysPassed += d;
             else{
               printf("\n\t\t\tYour input mm/dd/yyyy is wrong!");     
               break;        
             }           
        printf("\n\n\t\t\tThere are %d days past in the year", daysPassed);          
        break;   
        default: printf("\n\t\t\tYour input mm/dd/yyyy is wrong!");
    	}
    }
	 	if (c == 2)
{
	{
    if (x % 4 == 0 && x % 100 != 0 || x % 400 == 0)
        return 1;
    else
        return 0;
}


    
    do   {
        printf ("\n\t\tInput days: ");
        scanf  ("%d", &passed);
        printf ("\n\t\t      Year: ");
        scanf  ("%d", &yy);
        
        if (leap(yy))
            days[1] = 29;
        else
            days[1] = 28;
        
        orig = passed;
        
        for (i = 0; passed > 0; i++)
            passed = passed - days [i];
        passed = passed + days [i - 1]; 
        
        printf ("\n\t\tThe date is %d-%d-%d",
                                            i, passed, yy, orig);
		}
        printf ("\n\n\t\tDo more (Y/N)? ");
        scanf  ("%s", &more);		}
       }while (more == 'y'  ||  more == 'Y');
   
  return 0; 
}
Last edited on
Please put code tags around your code and paste it again with intact indentation. Also tell us which line the error is.
what does "leap" do? line 8 needs to end with a semicolon or more code.
You have double brackets in this part:
1
2
3
int main()
{ 
{


Simply remove the second bracket and it should work.
1
2
3
int main(){
...
}
Topic archived. No new replies allowed.