Computer Science: Arithmetic, Functions, and Programming Concepts

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/28

flashcard set

Earn XP

Description and Tags

For the first Comp Sci C quiz

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

29 Terms

1
New cards

What are the two types of division mentioned in the notes?

Integer division and floating-point division.

2
New cards

How can you force the computer to perform real number division?

By using a double in the calculation, such as prepending 1.0 to the numerator.

<p>By using a double in the calculation, such as prepending 1.0 to the numerator.</p>
3
New cards

What is the formula for converting Celsius to Fahrenheit?

F = (9/5 * C) + 32.

4
New cards

What is the purpose of the ceiling function in calculations?

To round up to the nearest integer.

5
New cards

What is the significance of the expression 'grade = ((double) x)/y'?

It casts x to a double to ensure real number division.

6
New cards

How do you convert a row and column to a single number?

Row = Loc / 7 and Column = Loc % 7.

7
New cards

What is the range of values that an int can store in C?

Between -2,147,483,648 and 2,147,483,647 (2³¹ -1 and 2^-31)

8
New cards

What is the purpose of the 'rand()' function in C?

To generate a random integer between 0 and 32,767. (2^15 - 1)

9
New cards

What are some common math functions in C?

sin(x), cos(x), tan(x), exp(x), log(x), pow(b, e), abs(x), fabs(x).

hypot(x,y), log10(x)

10
New cards

What is the correct way to read an integer input in C?

Using scanf("%d", &variable);.

11
New cards

What is the different types of variable types?

Int, String, Char, and Double(there are more, like float)

<p>Int, String, Char, and Double(there are more, like float)</p>
12
New cards

What does the expression 'int res = (int) (X + 0.5);' achieve?

It rounds the value of X to the nearest integer.

13
New cards

What is the relationship between degrees and radians?

180 degrees equals π radians.

14
New cards

How do you calculate the maximum spend based on guests and steak?

(x +y)- 1 / y

<pre><code class="language-C">(x +y)- 1 / y</code></pre><p></p>
15
New cards

What is the output of the expression '2 + 3 * 4'?

14, due to the order of operations.

16
New cards

What is the purpose of escape sequences in printf statements?

To format the output, such as using '\n' for a newline.

17
New cards

What is the formula for the cosine law?

c² = a² + b² - 2ab * cos(C).

<p>c² = a² + b² - 2ab * cos(C).</p>
18
New cards

What is the significance of using parentheses in expressions?

They determine the order of operations.

19
New cards

What is the output of the expression '24/(1 + 2%3 + 4/5 +6+ 31%8)'?

The output is 1

20
New cards

How do you declare a variable in C?

By specifying the type followed by the variable name, e.g., 'int miles;'.

<p>By specifying the type followed by the variable name, e.g., 'int miles;'.</p>
21
New cards

What is the output of 'printf("%d", 5);'?

It prints the integer 5.

22
New cards

What does the expression 'double = 1.0 + x' achieve?

It ensures that the addition is performed as a floating-point operation.

23
New cards

What is the escape sequence for doublequote?

\”

24
New cards

For the escape sequence ‘\\’, how many times does it print a backslash? Also does it work with odd backslash amounts’\\\\\’?

It prints a single backslash. However, if there is an odd number of backslashes, it won’t print anything at all(error occurs)

25
New cards

What are the other percent codes?

%lf for double, %c for char, %s for string, and %f for float

26
New cards

Why is & important and should never be forgotten?

It means address of, and it is needed every time you scan for a variable, in order to access the location of said variable to transmit what the user put in into the variable itself.

27
New cards

What is the constant of PI in math?

M_PI

28
New cards

How do you set up the #include for math and for studio?

#include <stdio.h> and #include <math.h>

29
New cards

How to convert from Fahrenheit to Celsius?

C = 5/9( F - 32)