Assignment C
Assignment C
Q1. Define the term variable in C language? What are the rules of creating variable names in C? Why is it
important to declare variables in C program before using them>
Q3. Last year in informatics Olympiad a student’s C program had variables as follows
void main()
{
int O2;
char o2;
/*Rest of the program*/
}
Do you think that the student made a mistake? How many legal variables are there in this program?
Q4. An alien is trying to make a C program to calculate its planet’s distance from Earth. However its program
seems to be giving errors. The first few lines of its function main are given below. Can you suggest what is
wrong with alien’s program and what are the errors in it?
void main()
{
int distnc#, 10grvity;
char o2, n2, co2
float _speed;
Q5. Take the initials of your name ( i.e. Sunny Jain should take S J, Ramesh Kumar Chauhan should take R C) and
digit 9. How many legal variable names of length three can be created for a C program (only using your
initials and digit 9). Give all legal variable names using the combination. Example S9J is a legal variable name
Q6. Deepa has to choose illegal variable names from the given list. Can you help Deepa by stating in front of each
variable name why it is illegal, if at all?
1. Main 8. Int
2. sunny 9. phone#
3. _super 10. rate_of_interest
4. 8miles 11. volatile
5. my.book 12. break
6. 911call 13. pasta
7. VOID 14. delhi