0% found this document useful (0 votes)
271 views2 pages

Activity 4.1 C Fundamentals

The document provides examples of valid and invalid variable names in programming and examples of declaring different data types like integer, float, character, string, boolean, and constant values in C++. It tests the ability to identify valid variable names based on naming conventions and reserved words. It also tests declaring variables of different data types and assigning values to them from given sets based on the data type.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
271 views2 pages

Activity 4.1 C Fundamentals

The document provides examples of valid and invalid variable names in programming and examples of declaring different data types like integer, float, character, string, boolean, and constant values in C++. It tests the ability to identify valid variable names based on naming conventions and reserved words. It also tests declaring variables of different data types and assigning values to them from given sets based on the data type.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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%

You might also like