Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Having few errors in the code

$
0
0
 
#include <iostream>
#include <iomanip> 
#include <string> 
#include <stdio.h>

/* kt3 y3_2 */   
/* programm "Aastaaeg" */ 


using namespace std;

int main()
{





int K;  /* Month K  */ 
int A;  /* Season A */
int  jaanuar;
int  veebruar;
int  marts; 
int  aprill;
int  mai; 
int  juuni;
int  juuli;
int  august;
int  september; 
int  oktoober;
int  november;
int  detsember;


cout<<"Sisestage kuu ";               /* Asks for month*/
  cin>> K;                          /* The input K is put in lower cased month name*/
  
  jaanuar = 1;                      /* Giving the value to months to use it to determine season */
  veebruar = 2; 
  marts = 3; 
  aprill = 4; 
  mai = 5; 
  juuni = 6; 
  juuli = 7; 
  august = 8; 
  september = 9; 
  oktoober = 10; 
  november = 11; 
  detsember = 12;
  if ( (K==12) || (K==1) || (K==2));  
  {                  
     cout<<K<<"Aastaaeg on talv.\n"; /*Result when the season is winter*/
  } 
  {
  else if (( K==3 )||(K==4) ||(K==5)); 
  {            // I use else just to show an example 
     cout<<K<<"aastaaeg on kevad.\n";           /*Result when the season is spring*/
  } 
  {
  else if  ((K==6) || (K==7) || (K==8));  
  {            // I use else just to show an example 
     cout<<K<<"aastaaeg on suvi.\n";          /*Result when the season is summer*/
  } 
  {
  else ;
  {
    cout<<K<<"Aastaaeg on sügis.\n";     /*Result when the season is autumn*/
  }
 
}
 
 

getchar(); 
getchar();

} 
}


The errors compiler gives me:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\programs\c\Untitled3.cpp" -o "C:\programs\c\Untitled3.exe" -g3 -I"C:\programs\c\lib\gcc\mingw32\3.4.2\include" -I"C:\programs\c\include\c++\3.4.2\backward" -I"C:\programs\c\include\c++\3.4.2\mingw32" -I"C:\programs\c\include\c++\3.4.2" -I"C:\programs\c\include" -L"C:\programs\c\lib" -g3
C:\programs\c\Untitled3.cpp: In function `int main()':
C:\programs\c\Untitled3.cpp:55: error: expected primary-expression before "else"
C:\programs\c\Untitled3.cpp:55: error: expected `;' before "else"

C:\programs\c\Untitled3.cpp:60: error: expected primary-expression before "else"
C:\programs\c\Untitled3.cpp:60: error: expected `;' before "else"
C:\programs\c\Untitled3.cpp:65: error: expected primary-expression before "else"
C:\programs\c\Untitled3.cpp:65: error: expected `;' before "else"

C:\programs\c\Untitled3.cpp:77: error: expected `}' at end of input
C:\programs\c\Untitled3.cpp:77: error: expected `}' at end of input

Execution terminated
What I have tried?
I tried to find the mistakes and for example try the method of string for hours, but met with no success.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>