Very basic question please help !

#include <iostream>

using namespace std;

int main()
{
int poeni;
cout << "Points: ";
cin >> poeni;
switch(poeni)
{
case:poeni<20
case:poeni>40
cout << "Your grade is A";
break;
}
}


This is the code i wrote for a school assignment, however i get some errors. What am I doing wrong ?

expected primary-expression before ':' token Line 12

expected ';' before 'case' Line 12
A switch will only let you check if your argument is equal to constants of basic types. No intelligent conditions can work with them. You'll have to use an if. See http://cplusplus.com/doc/tutorial/control/ for information on both.
Put ';' after case statement ()ends. Also give case label before ':'. Case label is a value of 'poeni'.
Code:
if(poeni<20) count=1;
if(poeni>40)count=0;
switch(count)
{
case 1:cout<<"Fail";break;
case 2:cout<<"Grade A";break;
}
Try this appropriately
Topic archived. No new replies allowed.