Write a set of statements to perform the following steps Whe
Write a set of statements to perform the following steps: When the variable car contains the character uppercase F, increase the value in the integer variable fiat by one. When car contains the character uppercase T, increase the value in the integer variable toyota by one. When car contains anything else, increase the value of the integer variable others by one.
Solution
Statements:
INTEGER :: fiat
INTEGER :: toyota
INTEGER :: others
CHARACTER(LEN=1) :: car
IF (car == \'F\') THEN
fiat = fiat + 1
ELSE IF (car == \'T\') THEN
toyota = toyota + 1
ELSE
others = others + 1
END IF
C / C++ / Java Statements:
char car;
int toyota = 0, fiat = 0, others = 0;
if(car == \'F\')
{
fiat = fiat + 1;
}
else if(car == \'T\')
{
toyota = toyota + 1;
}
else
{
others = others + 1;
}
