Let us C (C Language) Chapter 01 Exercise

M Hussain
2 min readJan 10, 2023

--

Chapter No: 02

[A] Which of the following are invalid variable names and why?

BASICSALARY _basic basic-hra
#MEAN group. 422
population in 2006 over time mindovermatter
FLOAT hELLO queue.
team’svictory Plot # 3 2015_DDay

BASICSALARY Valid
_basic Valid
basic-hra ( — not allowed)
#MEAN ( # not allowed)
group. ( . not allowed)
422 ( only digits not allowed)
population in 2006 ( spaces not allowed)
over time ( spaces not allowed)
mindovermatter Valid
queue. ( . not allowed)
team’svictory ( ‘ not allowed)
Plot # 3 ( spaces and # not allowed)
2015_DDay ( starting with digits not allowed)

[B] Point out the errors, if any, in the following C statements:

a) int = 314.562 * 150 ;

(b) name = ‘Ajay’ ;

© varchar = ‘3’ ;

(d) 3.14 * r * r * h = vol_of_cyl ;

(e) k = ( a * b ) ( c + ( 2.5a + b ) ( d + e ) ;

(f) m_inst = rate of interest * amount in rs ;

(a) int = 314.562 * 150 ;
C keyword is used as variable name.

(b) name = ‘Ajay’ ;
Char can only store 1 character.Also only single sided single quotes are used to enclose char.

© varchar = ‘3’ ;
only single sided single quotes are used to enclose char.

varchar = ‘3’ ; is correct

Read more: https://www.wwdailynews.online/2023/01/Let-us-C-Chapter-01-Exercise.html

--

--