Important Introduction to Programming Short Questions
Chapter: 3
Question 1:
What happens when you write X = X + 1 in C?
Answer:
The expression X = X + 1 increases the value of X by 1, commonly used for incrementing variables.
Chapter: 3
Question 2:
What are the basic data types available in C?
Answer:
The basic data types in C include int for integers, float for floating-point numbers, double for larger floating-point numbers, and char for characters.
Chapter: 3
Question 3:
How do you declare an integer variable in C?
Answer:
An integer variable is declared using the int keyword, e.g., int i;.
Chapter: 3
Question 4:
What is the size of an int in C on most systems?
Answer:
An int typically occupies 4 bytes (32 bits) in memory.
Chapter: 3
Question 5:
How does the short data type differ from int?
Answer:
The short data type is used for smaller integers and usually occupies 2 bytes, with a range of -32768 to 32767.
Chapter: 3
Question 6:
What is the use of the long data type in C?
Answer:
The long data type is used for storing larger whole numbers that cannot fit in an int.
Chapter: 3
Question 7:
What is a float data type in C?
Answer:
The float data type is used to store real numbers with decimal points, typically occupying 4 bytes.
Chapter: 3
Question 8:
When would you use a double instead of a float in C?
Answer:
A double is used when you need to store larger real numbers than what a float can handle, typically taking up 8 bytes.
Chapter: 3
Question 9:
How do you store characters in C?
Answer:
Characters are stored using the char data type, and they are enclosed in single quotes, like 'a'.
Chapter: 3
Question 10:
What are the arithmetic operators available in C?
Answer:
The arithmetic operators in C include + for addition, - for subtraction, * for multiplication, / for division, and % for modulus.