Csc 425

Submitted by: Submitted by

Views: 10

Words: 385

Pages: 2

Category: Science and Technology

Date Submitted: 10/09/2016 09:58 PM

Report This Essay

NAME : INTAN AZZWEEN NATASHA BINTI AHMAD RAZI

MAT. NO : 2016274804

TUTORIAL

1) List TWO (2) rules for naming an identifier?

* It must be declared, named and can be assigned with a value. It can only hold one value at one time

* It may contain letters, number and only special character underscore ( _). It may not begin with a number.

2) Determine which of the following are valid identifiers?

Identifiers | Answer |

a) r2d2 | Valid |

b) H2O | Valid |

c) secondCousinOnceRemove | Valid |

d) the_Legend-City_of _Malaysia | Valid |

e) _TIME_ | Valid |

f) _12345 | Valid |

g) X(3) | Valid |

h) cost_in_$ | Invalid |

3) State the difference between identifier and keyword.

Identifiers | Keyword |

Consist of letter and digit | Consist only letter |

First character must be letter | All character is letter |

Upper and lower case is used | All lower case |

4) Which of the following is reserved word in C++?

Identifiers | Answer |

a) Integer | No |

b) Long | No |

c) Float | Yes |

d) single | No |

e) double | Yes |

f) char | Yes |

5) What is the difference between variable and constant?

| Variable | Constant |

Definition | A variable is named location, whose value changes during a program run | A constant is a named location, whose value never changes during a program run |

Syntax | data_type variable_name | Const data_type variable_name=value |

6) Write a constant declaration for each of the following:

a) A constant that contains the number of minutes in an hour.

const int minutes = 60

b) A constant that holds the value of PI.

const float PI = 3.1416

7) Give the most appropiate data type for each of the following values:

Identifiers | Answer |

a) 23 | integer |

b) ā€˜cā€™ | character |

c) 8.52 | float |

d) 9537 | integer |

e) 20125.12345 | long |

f) True | bool |

8) Variable name and the appropriate data type :

Descriptions |...