Shared Flashcard Set

Details

C++ Basics: Math
C++ Math Practices
10
Computer Science
Undergraduate 1
04/04/2013

Additional Computer Science Flashcards

 


 

Cards

Term

 

How do you use the exponent function?

Definition

double base = 4;

double exponent = 2;

 

pow(base, exponent);

 

The exponent function will output (4^2).

 

 

Term
How do you use the square root function?
Definition

double number = 100;

 

sqrt(number);

 

The square root function will output the square root of 100.

Term

 

How do you use the absolute value function?

Definition

 

int number = -25;

cout << abs(number);

 

 

Term
How do you use the absolute value for float data type?
Definition

float number = 744.34;

cout << fabs(number);

Term

What is the value of num3? 

 

int num1 = 75;

int num2 = 50;

int num3;

 

num3 = num1 + num2;

Definition

num3 = num1 + num2;

num3 = 75 + 50;

num3 = 125;

Term
What is the increment operator?
Definition

++

int num1 = 5;

num1++;    <-------num1 is now assigned 6;

 

 

Term
What is the decrement operator?
Definition

--

 

int num1 = 5;

num1--;            <-------num1 is now assigned 4;

Term

What is the output for the following?

 

int num1 = 5 / 6 + 4 % 3;

 

cout << num1;

Definition

 

4

Term

What is the following operator?

 

'%'

 

Example: 353 % 35;

Definition

The Modulus operator. it receives the remainder.

Term

What will the following code output?

 

int num1 = 6;

int num2 = 5;

int num3;

 

num1 = num2++;

num3 = num1;

 

cout << num1 << endl << num2 << endl << num3;

Definition

6

6

6

Supporting users have an ad free experience!