For example, I know that I can write
int a, b, c, d;
to define a, b, c, and d as integers. And I know that I can assign numbers to these letters while making them integers.
int a = 0;
However, can I do both at the same time?
int a = 0, b = 0, c = 1, d = 1;
Or do I have to do each one in a separate line?In C Programming, can I assign values to variables in the same line while making them integers?
Yes you can assign variables at the point of definition.
Yes, you may put more than one variable definition on a line. How many variables to define on one line is personal choice.
Your example
int a = 0, b = 0, c = 1, d = 1;
is legal and correct.In C Programming, can I assign values to variables in the same line while making them integers?
int a = 0, b = 0, c = 1, d = 1; is fine.
Yes, you can
I think trying will be more beneficial then asking!
Subscribe to:
Post Comments (Atom)
c language example codes for program writers
ReplyDeletec example getting the disk status