Solved Questions/Answers
Introduction to Programming (Chapter #: 1)
Qno1: Why do we need a programming environment?
Answer:
Programming Environment:
In order to correctly perform any task we need to have proper tools. Collection of all necessary tools for programming makes up a programming environment. It is essential to set up programming environment before we start writing programs. It works as a basic platform for us to write an execute programs.
Qno2: Write the steps to create a c program file in the IDE of your lab computer?
Qno3: Describe the purpose of compiler.
Answer:
Purpose of Compiler:
Computer only understands and works in machine language consisting of 0’s and 1’s. A compiler is software that is responsible to conversion of a computer program written in some high level programming language to machine language code.
Qno4: List down five reserve words in c programming language.
Answer:
Reserve words:
- Auto 2. Else 3. Int 4. Char 5. for
Qno5: Discuss the mean parts of the structure of the C program.
Qno6: Why do we use comments in programming?
Answer:
Comments are the statements in a program that are ignored by the compiler and do not get executed.
Purpose:
- They facilitate other programmers to understand our code.
- They help us to understand our own code even after years of writing it.
Qno7: Differentiate between constant and variables.
Answer:
Variables:
- Available is a name given to memory location as the data is physically stored inside the computer’s memory.
- Each variable has a unique name called identifier and has a data type.
- The value of a variable can be changed during program execution.
Constant:
- Constants are the values that cannot be changed during program execution.
- There are three types of constants integer constants, real constants, and character constants.
Qno8: Write down the rules for naming a variable.
Answer:
Rules for naming a variable:
- Available name can only contain alphabets (uppercase or lowercase) digits and underscore.
- Variable name must begin with a letter or an underscore; it cannot begin with the digit.
- Reserved words cannot be used as a variable name.
- There is no strict rule on how long available name should be, but we should choose a concise length for the variable name to follow good design practice.
Qno9: Differentiate between char and int.
Qno10: How can you declare and initialize variable?