C programming Mid-term Study

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What symbol starts a comment?

/*

What is the value of c from this code segment: float a; float b = 3.641; int c; a = 2.897; c = a + b; printf ("The sum of adding %f and %f is %d\n", a, b, c);

6

What symbol must be at the end of every line in a C program

;

What mathematical symbol means "greater than or equal to"

>=

A void function can't have a return statement

False

When you declare a variable, but don't assign a value, you can assume that the value will be zero

False

You can't declare and initialize a variable at the same time

False

What is the name of your typical first C program

Hello world

What does the statement a *=3 do

It multiples a by 3

C can print the results of calculations to the terminal in formats you choose

True

Each function in C takes zero or more arguments and returns a single value

True

You can only return one value from a function

True

What happens to variables that are passed into functions?

a copy is made for use locally in the function

What is the major difference between a while loop and a do-while loop

a do-while loop will always execute at least once.

What is the main difference between a for and a while loop

a for loop puts all the logic controlling the loop in one place

What happens if you pass a pointer to a function?

any changes made to its value are reflected in the calling routine

What keyword do you use to exit a switch statement early

break

What could happen if you declare and use a pointer without associating a variable with it?

crash the computer

What is the process called when you create a variable

declaration

What case should be always be included in a switch statement.

default

What type of language is C?

function-based

What command do you use to compile your C program

gcc

What is the equivalent statement for i++;

i = i + 1

What mechanism is used for controlling program flow based on testing a condition

if-else

Which of the following statements declare an integer point called ptr_to_a?

int *ptr_to_a;

What are the variables called that are created inside a function?

local

What does printf mean?

print formatted

What does the following statement do: printf ("The value of ptr_to_a is %d\n", ptr_to_a);

prints the address pointed to by ptr_to_a

What does the following statement do: printf ("It stores the value %d\n", *ptr_to_a);

prints the value pointed to by ptr_to_a

Which of these are not a way in which pointers are useful?

switch statements

What is a pointer in the C programming language

the address of a block of memory with a variable in it.

In this statement, what does the keyword "char" signify: int sum_and_diff (float a, float b, char res) {

the type of argument the function expects in the third position.

After a pointer is declared, what does putting an asterisk in front of the name mean?

the variable pointed to by this pointer

In the switch statement, what is the purpose of the case statements?

the variable that is associated with the switch keyword is compared to each of the case statements.

What is an example of a looping statement

while

What symbol designates the start of the case portion of a switch statement

{

What symbol is used to designate code that is the start of a while loop

{

What symbol is used for the Boolean NOT operation

!

What symbol do you use to pass the address of a pointer to a function?

&

What symbol is used to designate the address of a variable?

&

A void function must have a return statement

False

In the C language you can use a variable without creating it first.

False

what is output after this code segment is executed. a = 0 switch (a) { case 0 : printf ("a is equal to 0\n"); case 1 : printf ("a is equal to 1\n"); default : printf ("a is greater than 1\n"); }

a is equal to 0 a is equal to 1 a is greater than 1

What is it called when an asterisk is placed before an already defined pointer?

derefrencing the pointer

What is the machine readable version of a program called

executable

What data type is used for floating point numbers

float

In the statement, printf("The sum of adding %d and %d is %d\n", a, b, c); what is the %d

format specifier for decimal integer

Where are variables stored?

in a block of memory

What data type stores an integer value

int

What does the statement "int b = 3;" do in a C program

it declares and initializes the variable b to be an int and to store an initial value of 3

What does the programming code "#include <stdio.h> do?

it includes the stdio.h library into your program

in the statement, switch (a), what is the variable a?

it is the variable that is tested against the various cases

What happens when this code segment is executed: a = 5; if (a = 1)printf("a is equal to 1\n");

it prints "a is equal to 1"

what does the keyword "break" do in a switch statement

it stops execution of the switch statement and resumes execution after the curly bracket

What function does every C program have to include?

main

What is the name of the function that must be in every C program?

main

What statements can the switch statement effectively replace

nested if statements

in this statement: for (i = 0; i < 10; i++), what is i++ called

the increment

In this statement, what does the keyword "int" signify: int sum_and_diff (float a, float b, char res) {

the return type

What symbol is used for a Boolean OR operation

||


Set pelajaran terkait

Chapter 18: Nursing Management of the Newborn

View Set

TEST A REVOLUTION AND TWO WORLD WARS

View Set

Unit 6 Integration and accumulation of change

View Set

media designConcordant - A concordant relationship occurs when you use only one typeface in a design. This approach will keep the page harmonious and formal, but can sometimes seem dull.

View Set

Hazmat - Will Not Carry - Provisions for Passengers and Crew

View Set

Chapter 10 Muscles Study Questions

View Set

Ch. 55: Management of Patients With Urinary Disorders

View Set