Basic Data Types in Programming
18 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the reserved word for representing integer numbers in programming?

  • char
  • int (correct)
  • float
  • double

What is the data type used to represent a student's height between 150 cm and 180 cm?

  • float (correct)
  • char
  • double
  • int

Which of the following is an invalid identifier and why?

  • 20thCentury - Invalid because it starts with a number
  • Parit Raja - Invalid because it contains a space
  • BIT1033 - Invalid because it is too long
  • int - Invalid because it is a reserved word (correct)

What is the correct declaration for a variable to represent a student's gender?

<p>char gender; (B)</p> Signup and view all the answers

What is the reserved word for representing floating point numbers in programming?

<p>float (C)</p> Signup and view all the answers

Which of the following is a valid declaration for a variable to represent an ATM pin number?

<p>int pin; (D)</p> Signup and view all the answers

What is a constant in programming?

<p>A fixed value that cannot be modified during execution (C)</p> Signup and view all the answers

Which of the following is a correct declaration of a constant in programming?

<p>const float y = 3.14; (B)</p> Signup and view all the answers

What is the purpose of the #define directive in programming?

<p>To define a constant (B)</p> Signup and view all the answers

What is the difference between a constant and a variable in programming?

<p>A constant is a fixed value, while a variable can be modified during execution (D)</p> Signup and view all the answers

What is the data type of the variable alphabet in the declaration char alphabet;?

<p>Character (A)</p> Signup and view all the answers

What is the purpose of declaring a variable in programming?

<p>To store a data value or input value (A)</p> Signup and view all the answers

What is the purpose of declaring a variable in a program?

<p>To inform the compiler about the type of data to be stored (A)</p> Signup and view all the answers

Which of the following is an example of assigning a value to a variable during declaration?

<p>int number = 10; (B)</p> Signup and view all the answers

What is the operator used to assign a value to a variable in a program?

<p>= (A)</p> Signup and view all the answers

What is the purpose of the scanf function in a program?

<p>To input data from the user (D)</p> Signup and view all the answers

Which of the following data types represents a round number with +/- values?

<p>Integer (B)</p> Signup and view all the answers

What is the purpose of the const keyword in a program?

<p>To declare a constant value (D)</p> Signup and view all the answers
Use Quizgecko on...
Browser
Browser