del Mundo, Harvey Jay U.
CE 3-6
1. Which of the following are invalid variable names and why? Determine which of the following
are valid identifiers. If invalid, explain why. (2pts. each)
● record1 - Valid
● $tax - Invalid, should start with letters only
● Name-and-address - Invalid, illegal characters ( - )
● lrecorde - Invalid, illegal characters ( blank space )
● file–3 - Invalid, illegal characters ( blank space )
● name and address - Invalid, illegal characters ( blank space )
● 123-45 -6789 - Invalid, illegal characters ( blank space and - )
● Return - Valid
● If - Invalid, resesrved word
● float - Invalid, function names
2. Write appropriate declaration for each group of variables given and assign the values from
the given set. (2pts. each)
● Integer variable : num, b, first - int a=7, b=b, c=first;
● Floating point : area, volume, num - float a=69ft 2 , b=108m3 , c=13;
● Character : coin, reg_no - char d=dollar, e=1900903;
● Short integer variable : tree - short int tree;
● Long integer variable : pen - long int pen;
● Double precision variable : book - double book;
● String: name, address - str name=Rico, address=Lemery;
● Boolean: correct, wrong - bool correct=true, wrong=false;
● Constant value: pi = 3.1416 - cons int pi=3.1416;
● Floating point: salary, tax - float salary=20$, tax=2%