much error and i'm newbie..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bagus permadi
    New Member
    • Dec 2011
    • 1

    much error and i'm newbie..

    i have try many ways that i know... but i still don't get it what the problem

    #include<iostre am.h>

    void main() {
    int x;
    cout<<"Masukkan umur Anda: ";
    cin>>x;
    if(x < 5)
    cout<<"Wah, masih balita nih ^_^"<<endl;
    elseif(x >= 5 && x < 12)
    cout<<"Masih anak-anak ya?"<<endl;
    elseif(x >= 12 && x < 17)
    cout<<"Sudah remaja ni yee..."<<endl;
    elseif(x >= 17 && x < 40)
    cout<<"Sudah dewasa ya..."<<endl;
    else
    cout<<"Sudah tua toh..."<<endl;
    }

    that's the script.. and this is the problem

    in line 8 it say : elseif should have a prototype
    in line 9.5 it say : statement missing ;
    in line 11.5 it say : statement missing ;
    in line 13.5 it say : statement missing ;
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It's else if, not elseif.
    Code:
    if (expression)
      {
        Block of statements;
      }
    else if(expression)
      {
        Block of statements;
      }
    else
      {
        Block of statements;
      }

    Comment

    • lspxy
      New Member
      • Nov 2011
      • 12

      #3
      it should be
      Code:
      #include <iostream>
      using namespace std;
      
      void main() 
      {
      	int x;
      
      	cout<<"Masukkan umur Anda: ";
      
      	cin>>x;
      
      	if (x < 5)
      		cout << "Wah, masih balita nih ^_^" << endl;
      	else if (x < 12)
      		cout << "Masih anak-anak ya?" << endl;
      	else if (x < 17)
      		cout << "Sudah remaja ni yee..." << endl;
      	else if (x < 40)
      		cout << "Sudah dewasa ya..." << endl;
      	else
      		cout << "Sudah tua toh..." << endl;
      }

      Comment

      Working...