CIS 119 C Programming Quiz 1

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Yupeilin
Y
Yupeilin
Community Contributor
Quizzes Created: 7 | Total Attempts: 13,237
| Attempts: 349 | Questions: 25
Please wait...
Question 1 / 25
0 %
0/100
Score 0/100
1. What is the only function all C programs must contain?

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.

Submit
Please wait...
About This Quiz
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... see moretimes at most. see less

2. Which of the following is not a correct variable type?

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.

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

Explanation

Each statement must have a semicolon (;) at the end of the line.

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

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.

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

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.

Submit
6. What is the output of the following program?

void main ()
{
int x = 10;
printf ("x = %d, y = %d", x, x*2-4);
}

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.

Submit
7. Evaluate the following code. Which variable will be assigned the value 9? 

int length=9, width, height;

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.

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

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.

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

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.

Submit
10. Which symbol is used for address of the variable?

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.

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

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.

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

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.

Submit
13. In order to properly use a variable...

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.

Submit
14. Which of the following is NOT a strength of C language

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.

Submit
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;
}   

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.

Submit
16. Assembly language has a one-to-one relationship with machine code

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.

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

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.

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

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.

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

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.

Submit
20. 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  #include
2
3  int main ()
4  {
5      height =4;
6      int height;
7      printf("The height is %d\n", height);
8      return 0;
9  }

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.

Submit
21. Which operating system was C developed for?

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.

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

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.

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

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.

Submit
24. What is the size of int in memory

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.

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

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.

Submit
View My Results

Quiz Review Timeline (Updated): Feb 20, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Feb 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 15, 2009
    Quiz Created by
    Yupeilin
Cancel
  • All
    All (25)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is the only function all C programs must contain?
Which of the following is not a correct variable type?
What punctuation must each statement have at the end of the line ?
Which pair of punctuations is used to signal the beginning...
In which standard library file is the function printf() located ?
What is the output of the following program?void main (){int x =...
Evaluate the following code. Which variable will be assigned...
The type of a variable determines the operations the compiler will...
Number 1 is a legal name for variables in C language.
Which symbol is used for address of the variable?
Which of the following is used to indicate that the function does not...
In a C program, the first statement that will be executed is:
In order to properly use a variable...
Which of the following is NOT a strength of C language
What is the output of following C program?#include int main ()...
Assembly language has a one-to-one relationship with machine code
Which number is returned at the end of function to indicate...
A typical high-level-language statement is equivalent to many...
 To incldue a file that you created on your onw, single...
Which line of the following program will generate error? (The number...
Which operating system was C developed for?
What is the output of the following program?main(){  int a = -5,...
The machine code is the same for computers designed by different...
What is the size of int in memory
Compiler translate the middle-level and high-level language programs...
Alert!

Advertisement