CIS 119 C Programming Quiz 1

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Yupeilin
Y
Yupeilin
Community Contributor
Quizzes Created: 7 | Total Attempts: 12,753
Questions: 25 | Attempts: 343

SettingsSettingsSettings
CIS 119 C Programming Quiz 1 - Quiz

This quiz is based on what we have covered so far. It also includes what was discussed on Monday class. Remember that you can take the quiz TWO times at most.


Questions and Answers
  • 1. 

    Number 1 is a legal name for variables in C language.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The statement is false because in C language, variable names cannot start with a number. They must start with a letter or an underscore.

    Rate this question:

  • 2. 

    Evaluate the following code. Which variable will be assigned the value 9? int length=9, width, height;

    • A.

      Length

    • B.

      Width

    • C.

      Height

    • D.

      All of above

    Correct Answer
    A. Length
    Explanation
    The variable "length" will be assigned the value 9. This is because in the given code, the variable "length" is explicitly assigned the value 9, while the variables "width" and "height" are not assigned any values. Therefore, the only variable that will have a value assigned to it is "length", and that value is 9.

    Rate this question:

  • 3. 

    The machine code is the same for computers designed by different manufacturers.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The statement is false because machine code is specific to the hardware architecture of a computer. Different computer manufacturers may use different hardware architectures, which means that the machine code for their computers will be different.

    Rate this question:

  • 4. 

    Which of the following is NOT a strength of C language

    • A.

      Efficiency

    • B.

      Portability

    • C.

      Object Oriented

    • D.

      Flexibility

    Correct Answer
    C. Object Oriented
    Explanation
    The given question asks for a strength of C language that is NOT present. The other options, Efficiency, Portability, and Flexibility, are all strengths of C language. However, Object Oriented is not a strength of C language. C is a procedural programming language and does not support object-oriented programming concepts such as inheritance, polymorphism, and encapsulation. Therefore, Object Oriented is the correct answer as it is not a strength of C language.

    Rate this question:

  • 5. 

    Assembly language has a one-to-one relationship with machine code

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Assembly language is a low-level programming language that is closely related to machine code. It uses mnemonics to represent machine instructions and has a one-to-one correspondence with the machine code instructions that the computer's processor can execute directly. This means that each assembly language instruction corresponds to a specific machine code instruction, making it easier for programmers to understand and write code that directly interacts with the computer's hardware. Therefore, the statement "Assembly language has a one-to-one relationship with machine code" is true.

    Rate this question:

  • 6. 

    A typical high-level-language statement is equivalent to many machine-code instructions.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A typical high-level-language statement is equivalent to many machine-code instructions because high-level languages are designed to be more user-friendly and abstracted from the low-level details of the machine. High-level statements are often more concise and expressive, allowing programmers to achieve complex functionality with fewer lines of code. However, when the high-level code is compiled or interpreted, it is translated into multiple machine-code instructions that the computer can understand and execute. This translation process ensures that the high-level code is converted into the appropriate sequence of low-level instructions that the machine can process.

    Rate this question:

  • 7. 

    What is the size of int in memory

    • A.

      4 bytes

    • B.

      2 bytes

    • C.

      8 bytes

    • D.

      1 bytes

    Correct Answer
    A. 4 bytes
    Explanation
    The size of an int in memory is typically 4 bytes. The int data type is used to store whole numbers, and on most systems, it is represented using 32 bits, which is equivalent to 4 bytes. This allows an int variable to hold values ranging from -2,147,483,648 to 2,147,483,647.

    Rate this question:

  • 8. 

    What is the only function all C programs must contain?

    • A.

      System()

    • B.

      Start()

    • C.

      Main()

    • D.

      Program()

    Correct Answer
    C. Main()
    Explanation
    The correct answer is "main()". In C programming, the main() function is the entry point of the program. It is the function where the program starts its execution and it must be present in every C program. The main() function typically contains the code that performs the desired tasks and logic of the program. Without the main() function, the program would not have a starting point and would not be able to execute any code.

    Rate this question:

  • 9. 

    Which pair of punctuations is used to signal the beginning and end of a function in C?

    • A.

      { and }

    • B.

      < and >

    • C.

      ( and )

    • D.

      # and }

    Correct Answer
    A. { and }
    Explanation
    In C programming, the pair of curly braces { and } is used to signal the beginning and end of a function. These braces enclose the body of the function, which contains the statements and declarations that define the function's behavior. The opening curly brace { indicates the start of the function, while the closing curly brace } marks the end of the function. This pair of punctuations is essential for defining the scope of the function and ensuring that the statements within it are executed together as a unit.

    Rate this question:

  • 10. 

    Which of the following is not a correct variable type?

    • A.

      Float

    • B.

      Real

    • C.

      Int

    • D.

      Char

    Correct Answer
    B. Real
    Explanation
    The variable type "real" is not a correct variable type in most programming languages. The correct variable types in this context are float, int, and char. "Real" is not a commonly used variable type and is not recognized by most programming languages.

    Rate this question:

  • 11. 

    In which standard library file is the function printf() located ?

    • A.

      Stdlib.h

    • B.

      Stdio.h

    • C.

      Stdout.h

    • D.

      Stdoutput.h

    Correct Answer
    B. Stdio.h
    Explanation
    The function printf() is located in the stdio.h standard library file. This file contains the necessary declarations and definitions for input and output operations in C programming language.

    Rate this question:

  • 12. 

    In order to properly use a variable...

    • A.

      The variable must have a valid type.

    • B.

      The variable name can not be a keyword (part of the C syntax).

    • C.

      The variable name must begin with a letter or underscore.

    • D.

      All of the above.

    Correct Answer
    D. All of the above.
    Explanation
    The correct answer is "All of the above." This is because in order to properly use a variable, it must have a valid type, the variable name cannot be a keyword in the C syntax, and the variable name must begin with a letter or underscore. All three statements are necessary for using a variable correctly.

    Rate this question:

  • 13. 

    Which operating system was C developed for?

    • A.

      Windows

    • B.

      Solaris

    • C.

      Linux

    • D.

      Unix

    Correct Answer
    D. Unix
    Explanation
    C was developed for the Unix operating system. Unix was one of the earliest operating systems, developed in the 1960s, and C was created in the early 1970s as a systems programming language specifically for use with Unix. C and Unix were developed in tandem and had a strong influence on each other. The portability and efficiency of C made it a popular choice for programming on Unix systems, and it continues to be widely used for system-level programming and development of operating systems.

    Rate this question:

  • 14. 

    What punctuation must each statement have at the end of the line ?

    • A.

      :

    • B.

      ,

    • C.

      !

    • D.

      ;

    Correct Answer
    D. ;
    Explanation
    Each statement must have a semicolon (;) at the end of the line.

    Rate this question:

  • 15. 

    What is the output of following C program?#include int main () {     int a=6;     int b;     b=a*7/3-4*2;     printf("a=%d, b=%d\n", a, b);     return 0;}   

    • A.

      A=6, b=20

    • B.

      A=6, b=12

    • C.

      A=6, b=16

    • D.

      A=6, b=6

    Correct Answer
    D. A=6, b=6
    Explanation
    The output of the given C program is "a=6, b=6". This is because the program first assigns the value 6 to the variable "a". Then, the expression "a*7/3-4*2" is evaluated. In this expression, the multiplication and division have higher precedence than subtraction. So, first "a*7" is calculated as 6*7=42, then "42/3" is calculated as 14, and finally "14-4*2" is calculated as 14-8=6. Therefore, the value of "b" is 6. Finally, the values of "a" and "b" are printed using the printf function.

    Rate this question:

  • 16. 

    What is the output of the following program?main(){  int a = -5, b = -4;  printf("%d",a/b);}

    • A.

      1.25

    • B.

      -1.25

    • C.

      -1

    • D.

      1

    Correct Answer
    D. 1
    Explanation
    The program is dividing the value of variable a (-5) by the value of variable b (-4) using integer division. Integer division truncates the decimal part of the result, so -5 divided by -4 equals 1. Therefore, the output of the program is 1.

    Rate this question:

  • 17. 

    What is the output of the following program?void main (){int x = 10;printf ("x = %d, y = %d", x, x*2-4);}

    • A.

      X = 10, y = 10

    • B.

      X = 10, y = 9

    • C.

      X = 10, y = 11

    • D.

      X = 10, y = 16

    Correct Answer
    D. X = 10, y = 16
    Explanation
    The program prints "x = 10, y = 16" as the output. This is because the value of x is 10, and the expression x*2-4 evaluates to 16. The printf statement then prints the values of x and y, which are 10 and 16 respectively.

    Rate this question:

  • 18. 

    Which line of the following program will generate error? (The number at the left of each line indicate line number and are not part of the program code)1  #include23  int main () 4  {5      height =4;6      int height;7      printf("The height is %d\n", height);8      return 0;9  }

    • A.

      Line 1 and 3

    • B.

      Ling 5 and 6

    • C.

      Line 7 and 8

    • D.

      Line 4 and 9

    Correct Answer
    B. Ling 5 and 6
    Explanation
    The line 5 and 6 will generate an error because the variable "height" is being used before it is declared. In C programming, variables must be declared before they are used. So, in this case, the program will not be able to recognize the variable "height" when it is assigned a value in line 5.

    Rate this question:

  • 19. 

    Which number is returned at the end of function to indicate that the program executes successfully?

    • A.

      1

    • B.

      0

    • C.

      -1

    • D.

      All of above

    Correct Answer
    B. 0
    Explanation
    The number 0 is returned at the end of the function to indicate that the program executes successfully. This is a common convention in programming, where a return value of 0 typically signifies successful execution.

    Rate this question:

  • 20. 

    Which symbol is used for address of the variable?

    • A.

      *

    • B.

      $

    • C.

      &

    • D.

      @

    Correct Answer
    C. &
    Explanation
    The symbol "&" is used to represent the address of a variable in programming languages. It is commonly used in languages like C and C++ to access the memory address of a variable. By using the "&" symbol, the programmer can manipulate and work with the memory address of a variable, allowing for more advanced operations and functionality within the program.

    Rate this question:

  • 21. 

    In a C program, the first statement that will be executed is:

    • A.

      The first executable statement of the program.

    • B.

      The first executable statement of the main() function.

    • C.

      The first executable statement after the comment /*start here*/

    • D.

      The first executable statement of the end function.

    Correct Answer
    B. The first executable statement of the main() function.
    Explanation
    In a C program, the first statement that will be executed is the first executable statement of the main() function. The main() function is the entry point of a C program, and execution starts from the first statement inside this function. Other parts of the program, such as comments or functions defined after the main() function, will not be executed until they are called or invoked from within the main() function.

    Rate this question:

  • 22. 

     To incldue a file that you created on your onw, single quotation marks are used. For example:   #include 'myfile.h'

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    In C++ programming, to include a file that you created on your own, double quotation marks should be used instead of single quotation marks. Therefore, the correct answer is False.

    Rate this question:

  • 23. 

    Compiler translate the middle-level and high-level language programs into equivalent assembly language programs.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The statement is false because compilers translate high-level language programs into equivalent machine code, not assembly language programs. Assembly language is a low-level programming language that is specific to a particular computer architecture and is usually written by humans, whereas machine code is the binary representation of instructions that can be directly executed by the computer's hardware.

    Rate this question:

  • 24. 

    Which of the following is used to indicate that the function does not return any value?

    • A.

      Void

    • B.

      Null

    • C.

      No

    • D.

      Empty

    Correct Answer
    A. Void
    Explanation
    The keyword "void" is used in programming to indicate that a function does not return any value. It is commonly used in languages like C, C++, and Java to specify that a function is a "void" function, meaning it performs certain operations but does not produce any output or return any result.

    Rate this question:

  • 25. 

    The type of a variable determines the operations the compiler will allow for the variable.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The statement is true because the type of a variable determines the kind of data it can hold and the operations that can be performed on it. For example, if a variable is declared as an integer type, it can only hold integer values and arithmetic operations like addition, subtraction, and multiplication can be performed on it. On the other hand, if a variable is declared as a string type, it can hold text data and operations like concatenation can be performed on it. The compiler uses the variable's type information to enforce type safety and ensure that only valid operations are performed on the variable.

    Rate this question:

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.