C Programming Basics Quiz

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What is the extension for a C source file?

  • .c (correct)
  • .java
  • .cpp
  • .txt

Which keyword is used to define a constant in C?

  • define
  • const (correct)
  • var
  • constant

What is the output of the expression 5 / 2 in C?

  • 2.0 (correct)
  • 2.5
  • 2.25
  • 2 (correct)

What is the purpose of the 'break' statement in C programming?

<p>To terminate the current loop or switch case and transfer control to the next statement after the loop or switch case (A)</p>
Signup and view all the answers

What is the purpose of the 'static' keyword in C programming?

<p>To declare a variable with a lifespan throughout the program's execution (B)</p>
Signup and view all the answers

What is the purpose of the 'sizeof' operator in C programming?

<p>To determine the size in bytes of a data type or a variable (A)</p>
Signup and view all the answers

What is the purpose of the '&&' operator in C programming?

<p>It is the logical AND operator, it returns true if both operands are true (B)</p>
Signup and view all the answers

Which statement is true about the 'for' loop in C programming?

<p>The 'for' loop is a pre-tested loop, the condition is checked before executing the loop body (B)</p>
Signup and view all the answers

What does the 'switch' statement in C programming primarily provide an alternative to?

<p>Nested 'if' statements (A)</p>
Signup and view all the answers

Flashcards are hidden until you start studying

Study Notes

C Programming Basics

  • A C source file has a .c extension.

Constants and Operators

  • The const keyword is used to define a constant in C.
  • The / operator performs integer division, so the expression 5 / 2 evaluates to 2.
  • The &amp;&amp; operator is a logical AND operator, which returns 1 if both conditions are true, and 0 otherwise.

Control Statements

  • The break statement is used to exit a loop or switch statement.
  • The static keyword has multiple purposes, including declaring static variables and functions, and specifying that a variable is initialized only once.

Operators and Functions

  • The sizeof operator returns the size of a variable or data type in bytes.

Loops and Conditional Statements

  • A for loop can be used with or without initialization and increment/decrement statements.
  • The switch statement provides an alternative to using long chains of if-else statements.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Like This

Java Programming Basics
15 questions

Java Programming Basics

CongratulatoryIndianapolis avatar
CongratulatoryIndianapolis
C++ Loops and Operators Quiz
45 questions

C++ Loops and Operators Quiz

StrikingTimpani8615 avatar
StrikingTimpani8615
Use Quizgecko on...
Browser
Browser