C++ Programming Fundamentals
46 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

Which of the following options is a compiled programming language?

  • Python
  • Bash
  • Fortran (correct)
  • None of the above

Before a function can be called in a program, what must occur in the code?

  • The function's body
  • The function's definition (correct)
  • The function's description
  • The function's declaration

In a function definition, what does the keyword void indicate?

  • The function will empty any arguments that it is called with.
  • The function doesn’t return any value. (correct)
  • The function’s return type is the type named void.
  • The function’s return type isn’t specified.

For two functions to be considered overloaded, what characteristic must they share?

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

Which of the following best describes the following C++ code snippet?

int main() { }

<p>Function Definition (D)</p> Signup and view all the answers

According to the provided information, under what condition is attribution required when using external sources?

<p>When the sources are used, but only with attribution. (C)</p> Signup and view all the answers

Which statement regarding whitespace in a program is most accurate?

<p>Whitespace can be meaningful, such as separating tokens, but is otherwise ignored. (A)</p> Signup and view all the answers

Based on the syllabus, which of the following resources should always be cited when used as a source?

<p>Section 1.2.1 from the required textbook. (D)</p> Signup and view all the answers

Under what condition are parameter names NOT ignored by the compiler in function declarations?

<p>When the function declaration is also a function definition. (C)</p> Signup and view all the answers

According to the Preface of the required textbook, what does Stroustrup mean when he says the book isn’t a layer cake?

<p>The book won’t be focusing on how the language has evolved over time. (B)</p> Signup and view all the answers

Why was the function call print(0,0) in Section 1.3 considered ambiguous?

<p>Because there were only declarations of single parameter overloads of <code>print</code>. (C)</p> Signup and view all the answers

What is the return type for a function that does not return any value?

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

What advice is given in Section 1.3 to reduce errors?

<p>Writing more functions and shorter functions. (A)</p> Signup and view all the answers

Which statement best describes function overloading?

<p>All of the functions are overloaded. (D)</p> Signup and view all the answers

If a student has multiple scores, which factor determines the points from exams that contribute to their point total?

<p>The instructions provided at the start of the exam. (C)</p> Signup and view all the answers

According to the provided exam instructions, on which of the following assessments are students explicitly NOT allowed to collaborate?

<p>The current exam. (D)</p> Signup and view all the answers

What should a student do if they have a question during the exam?

<p>Raise their hand and wait for a proctor. (C)</p> Signup and view all the answers

A student wants to use external resources during the exam. Which of the following is permissible according to the exam instructions?

<p>Consult paper notes, slides, and textbooks. (A)</p> Signup and view all the answers

How many questions must a student answer correctly to achieve a perfect score on the exam?

<p>50 questions. (A)</p> Signup and view all the answers

A student is taking Version A of the exam. What is the significance of the version letter?

<p>It is used for exam administration purposes. (B)</p> Signup and view all the answers

According to the instructions, which of the following items must students present when returning their exam materials?

<p>Their MSU ID (or other photo ID), bubble sheet, and printed exam. (A)</p> Signup and view all the answers

A student brings a smart-watch to the exam. According to the instructions, what should they do with it?

<p>Place it away in their bag. (B)</p> Signup and view all the answers

What is meant by the statement 'the book can be read in many different ways'?

<p>The book can be interpreted with varying perspectives and depths of understanding. (D)</p> Signup and view all the answers

Which namespace contains cout in C++?

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

What is the primary purpose of using the -std=c++20 command-line argument with g++?

<p>To enable the use of C++20 language features in the code. (D)</p> Signup and view all the answers

In the context of this course, what is the C++ interpreter being used?

<p>None of the above (E)</p> Signup and view all the answers

C++ was developed as an extension of which earlier programming language?

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

Function declarations can also be considered what?

<p>Function prototypes. (B)</p> Signup and view all the answers

What does it mean when a function is overloaded in C++?

<p>It has the same name as another function but with different parameters. (E)</p> Signup and view all the answers

What is the name given to a program that converts a source file into an executable program?

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

What is the total possible point value for all exams in the course?

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

Which of the following is a key difference between an interpreter and a compiler?

<p>An interpreter directly executes the code. (F)</p> Signup and view all the answers

According to the course policy, what is true regarding the use of AI tools like GitHub Copilot or ChatGPT?

<p>They can be used, but beware about using them in ways that deter learning. (A)</p> Signup and view all the answers

Which of the following activities permits collaboration among students, according to the course policies?

<p>Lab assignments (synchronous) (D)</p> Signup and view all the answers

Which of the following elements are typically present in a minimal, working C++ program?

<p>Include directives (F)</p> Signup and view all the answers

Given the function declarations below, determine which functions are examples of overloading:

void Jump(); int Jump(); void After(double a); void After(double); int Nice(string); int Nice(int); string Bark(string); string Bark();

<p>(c) and (d) are both true (B)</p> Signup and view all the answers

Consider two functions:

int calculate(int a, double b); double calculate(double a, int b);

What concept do these functions demonstrate?

<p>Function overloading (D)</p> Signup and view all the answers

Which task is typically handled by a compiler rather than an interpreter?

<p>Generating object code (A)</p> Signup and view all the answers

When does the int keyword define a primitive integer data type in C++?

<p>When it is in a function body (C)</p> Signup and view all the answers

If code compiles without errors but generates errors when compiled with the -std=c++20 flag in g++, what is the most likely cause?

<p>That the code is illegal according to the C++20 standard (B)</p> Signup and view all the answers

Which of the following denotes a single-line comment in C++?

<p><code>// Comment</code> (F)</p> Signup and view all the answers

A non-zero value returned by the main function typically indicates which condition?

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

What is the return type of the function hum in the following C++ code snippet: int x {7}; char y = hum(x + 8.9);?

<p>char (F)</p> Signup and view all the answers

Which of the following is NOT a standard component of a C++ program?

<p><code>C++</code> (D)</p> Signup and view all the answers

Which statement accurately describes the purpose of the include directive in C++?

<p>It incorporates external code, such as header files, into the current file. (B)</p> Signup and view all the answers

Which of the following best describes the role of the main function in a C++ program?

<p>It marks the entry point of the program. (C)</p> Signup and view all the answers

Flashcards

Open Note Exam

Converting paper material into digital format for educational purposes.

Exam Question Format

Only one option should be chosen for each question on the exam.

Allowed Materials

Notes, slides, prior exams, assignments and books are all allowed.

Returning Exam

Present your MSU ID (or other photo ID) when returning your bubble sheet and printed exam.

Signup and view all the flashcards

Exam Material Placement

Place all materials on your desk prior to the start of the exam to avoid needing to rummage in your bag during the exam.

Signup and view all the flashcards

Getting Help

Raise your hand and a proctor will attend to you if you have any questions during the exam or when you finish the exam.

Signup and view all the flashcards

Prohibited Electronics

Smart-watches, phones and headphones need to be placed away in your bag.

Signup and view all the flashcards

Exam Start Preparation

Bubble in name, student number and exam VERSION/FORM LETTER (with a #2 pencil) on the front of the printed exam and bubble sheet prior to the exam start.

Signup and view all the flashcards

Function declaration placement

Including all function declarations at the start of the file.

Signup and view all the flashcards

-std=c++20 flag purpose

To indicate to the compiler that C++20 features should be used in code.

Signup and view all the flashcards

C++ Interpreter Name

g++

Signup and view all the flashcards

Language C++ Extends

C

Signup and view all the flashcards

cout's namespace

std

Signup and view all the flashcards

Function overloading

There is another function with the same name.

Signup and view all the flashcards

What is A compiler?

A program that turns a source file into an executable program.

Signup and view all the flashcards

What is an interpreter?

Software that executes high-level code line by line.

Signup and view all the flashcards

Function call requirement?

The function's declaration must occur before the function call.

Signup and view all the flashcards

Meaning of void

It means the function doesn't return any value.

Signup and view all the flashcards

int main() { }

This code is best described as a Program Definition.

Signup and view all the flashcards

What is the Return Type of a function?

The return type is the type of data a function returns after it completes its execution.

Signup and view all the flashcards

Arguments and Parameters?

Arguments or parameters are the values passed to a function when it is called.

Signup and view all the flashcards

Interpreter

A program that directly executes code line by line, without creating a separate executable file.

Signup and view all the flashcards

Compiler

A program that translates source code into machine code to create an executable file.

Signup and view all the flashcards

Include Directives

Directives that tell the compiler to include external libraries or headers.

Signup and view all the flashcards

Variable Declarations

Named storage locations that hold values.

Signup and view all the flashcards

Function Definitions

Blocks of code that perform specific tasks or operations.

Signup and view all the flashcards

CSE 232 AI Policy

Using AI tools may be permitted, but use them in ways that support learning.

Signup and view all the flashcards

Minimal C++ program

Minimum C++ program includes include directives, function definitions

Signup and view all the flashcards

Citation Requirement (Syllabus)

Always cite lectures from Week 06 if used as a source.

Signup and view all the flashcards

Parameter Names in Declarations

Parameter names are NOT ignored when the function declaration is also a function definition.

Signup and view all the flashcards

Stroustrup's 'Layer Cake'

The book isn’t a layer cake means that it won’t be focusing on how the language has evolved over time.

Signup and view all the flashcards

Ambiguous Function Call

The function call is ambiguous because (0,0) could be interpreted as one number or two.

Signup and view all the flashcards

'No Return' Type

The return type for a function that doesn’t return anything is 'void'.

Signup and view all the flashcards

Reducing Errors

To reduce errors, write more functions and shorter functions.

Signup and view all the flashcards

int

A keyword representing integer data type.

Signup and view all the flashcards

#include

A preprocessor directive used to include header files.

Signup and view all the flashcards

main

The entry point of a C++ program.

Signup and view all the flashcards

C++

Programming language extending the C language.

Signup and view all the flashcards

STL

Standard Template Library provides common programming data structures and functions.

Signup and view all the flashcards

Non-zero main return

Indicates the program terminated with an error.

Signup and view all the flashcards

// Comment

Single-line comment.

Signup and view all the flashcards

char hum(int x)

The return type is char

Signup and view all the flashcards

Study Notes

  • CSE 232 is an Introduction to Programming II course.

Exam Instructions

  • Don't start the exam until instructed.
  • Write name, student number, and exam version/form letter on the printed exam and bubble sheet using a #2 pencil before starting.
  • This is Version A, so section doesn't matter.
  • Show MSU ID (or photo ID) when turning in your bubble sheet and printed exam.
  • Choose one option per question and mark it on both the printed exam and bubble sheet.
  • Assume any needed #includes and using std::...; namespace declarations are performed for code samples.
  • Each question is worth the same amount; answer only 50 questions correctly out of 55 for a perfect score.
  • Electronics aren't allowed during the exam; put smart-watches, phones, and headphones in your bag.
  • The exam is open note; any paper material is allowed.
  • Place all materials on your desk before the exam to avoid rummaging through your bag.
  • Bring the required textbook.
  • Raise your hand if you have any questions during the exam, and a proctor will assist.

Exam Questions

  • To calculate the total points from exams, sum the highest scores from Midterm MCQ/Makeup, Midterm Coding/Makeup, Final MCQ, and Final Coding.
  • An interpreter differs from a compiler because it directly executes the code, it doesn't just interpret it.
  • CSE 232's policy on AI tools like GitHub Copilot and ChatGPT states that they can be used, but you must be cautious about using them in ways that deter learning. They can be used but only with attribution
  • Collaboration isn't permitted on exams.
  • The minimal C++ program has no specific traits from the list, thus the answer is that it "has none of the above" traits
  • Functions are overloaded when they share the same name but have different parameters (different arguments). In the provided declarations, Nice and Bark are overloaded.
  • According to the syllabus, always cite peers you collaborated with if you use them as a source.
  • Parameter names are not ignored by the compiler in function declarations when the function declaration is also a function definition.
  • Stroustrup's analogy of the book not being a layer cake means the book can be read in many different ways.
  • cout is contained in the std namespace.
  • The function call print(0,0) in Section 1.3 was ambiguous because (0,0) could be interpreted as one number or two.
  • The return type for a function that doesn't return anything is void.
  • To reduce errors, all function declarations should be included at the start of the file.
  • The -std=c++20 command-line argument for g++ is recommended to allow for C++20 features to be used in the code.
  • The C++ interpreter used in the course is not listed.
  • C++ was created to extend the programming language C.
  • For a function to be called, its declaration must occur prior to the function call in the code.
  • In print_square's definition with void, void means the function doesn't return any value.
  • If a function is overloaded, another function exists with the same name.
  • A program that turns a source file into an executable program is called a compiler.
  • To be overloaded, two functions must have the same name.
  • int main() {} is best described as a program definition.
  • STL is a namespace.
  • If code gives errors with -std=c++20 but works without it, the code is illegal according to the C++20 standard.
  • /* Comment */ is a comment in C++.
  • double other(); could be a function declaration (but isn't a function definition). Note the lack of {}.
  • Whitespace matters when it is in a string literal.
  • In the main function, a non-zero return value indicates failure.
  • With int x {7}; char y = hum(x + 8.9);, the return type of the function named hum is char.
  • Working through sample MCQ exam questions is recommended when studying.
  • The main function must be present in every C++ program.
  • Not using function overloading would eliminate ambiguous function calls.
  • The following program won't compile:
    int twice(int x) {
      return x + x;
    }
    int main() {
      cout << twice("3");
    }
    
  • int * Xyz::Abc(Xyz const &); is an example of a member function.

Studying That Suits You

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

Quiz Team

Related Documents

Description

Test your knowledge of C++ fundamentals. This quiz covers compiled languages, function definitions, overloading, and the importance of source attribution. It also tests understanding of whitespace, compiler behavior, and textbook concepts.

More Like This

Introduction to C++ Programming Quiz
5 questions

Introduction to C++ Programming Quiz

AdorableWatermelonTourmaline avatar
AdorableWatermelonTourmaline
C++ Programming Language Overview
15 questions

C++ Programming Language Overview

AppreciatedConnemara937 avatar
AppreciatedConnemara937
Use Quizgecko on...
Browser
Browser