Tag: science & technology

Questions Related to science & technology

Multiple choice general knowledge science & technology
  1. George Washington

  2. Dwight D. Eisenhower

  3. Franklin D. Roosevelt

  4. Abraham Lincoln

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Franklin D. Roosevelt served as President for 12 years (1933-1945), the longest in US history. He was elected to four terms and died in office early in his fourth term. George Washington served 8 years, Eisenhower served 8 years, and Lincoln served 4 years before his assassination.

Multiple choice general knowledge science & technology
  1. include the function's prototype.

  2. include the proper header file.

  3. include the function's definition.

  4. specify the length of the library function.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

When using built-in functions in C/C++, you must include the proper header file that contains the function's prototype. Header files like , , or declare the functions so the compiler can validate their usage. The function's actual definition is in the library, which is linked during compilation. You don't need to redefine the function or specify its length.

Multiple choice general knowledge science & technology
  1. <ctype.h>

  2. <math.h>

  3. <time.h>

  4. <stdlib.h>

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The library function isalpha() requires the header file . This header file contains function prototypes for character testing functions like isalpha(), isdigit(), isalnum(), etc. The header is for mathematical functions, for time-related functions, and for general utility functions.

Multiple choice general knowledge science & technology
  1. one of "all" numbers available from the keyboard.

  2. an alphabet character.

  3. an ASCII character.

  4. an alphanumeric.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The built-in library function isalnum() tests whether its argument is an alphanumeric character (either a letter A-Z or a digit 0-9). It returns true if the character is either alphabetic or numeric. This is different from isalpha() which only checks for alphabetic characters, or isdigit() which only checks for numeric characters.

Multiple choice general knowledge science & technology
  1. you must convert the apstring to a standard string by using .c_str( ).

  2. all numbers within the string will be converted to integers.

  3. all characters within the string will be converted to ASCII equivalents.

  4. all alphabetic characters within the string will be counted.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

When using atoi() with an apstring variable (a string class commonly used in some programming courses), you must convert the apstring to a standard C-style string using the .c_str() method. The atoi() function expects a null-terminated C-string (const char*), not a C++ string object. This conversion is necessary for the function to work correctly.

Multiple choice general knowledge science & technology
  1. the exponent symbol ^.

  2. the built-in library function pow(x,y).

  3. the built-in library function pow10(x).

  4. concatenation.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The pow(x, y) function from math.h calculates x raised to the power y. In C, the ^ symbol is bitwise XOR, not exponentiation. The pow10() function exists only for powers of 10.

Multiple choice general knowledge science & technology
  1. a variable used to hold a number from the computer's internal clock.

  2. a data type

  3. a built-in library function which will return a value from the internal clock.

  4. a header file.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

time_t is a data type (typically a typedef for a long integer) used to store time values. It's not a variable, function, or header file. The time() function returns a value of type time_t.

Multiple choice general knowledge science & technology
  1. is a true random number generator.

  2. returns positive double values.

  3. is a pseudo-random number generator.

  4. returns a different sequence of values each time it is run.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

rand() is a pseudo-random number generator - it uses an algorithm to produce seemingly random numbers from a seed value. It produces the same sequence unless seeded with srand(). True randomness requires hardware entropy sources.