Podcast
Questions and Answers
What is the primary function of a text editor?
What is the primary function of a text editor?
Which statement about the Windows operating system is accurate?
Which statement about the Windows operating system is accurate?
Why is it beneficial to stick with one text editor?
Why is it beneficial to stick with one text editor?
What is GNU an acronym for?
What is GNU an acronym for?
Signup and view all the answers
What is a characteristic of Unix-based operating systems?
What is a characteristic of Unix-based operating systems?
Signup and view all the answers
Which command is used to invoke the GNU compiler?
Which command is used to invoke the GNU compiler?
Signup and view all the answers
Which type of shell is the default for Linux?
Which type of shell is the default for Linux?
Signup and view all the answers
Which command is commonly used to change directories in a shell?
Which command is commonly used to change directories in a shell?
Signup and view all the answers
What must be true about the platform to run compiled code?
What must be true about the platform to run compiled code?
Signup and view all the answers
What is true about the programming language C in relation to Unix?
What is true about the programming language C in relation to Unix?
Signup and view all the answers
What is one primary function of a debugger?
What is one primary function of a debugger?
Signup and view all the answers
What is one function of a shell in an operating system?
What is one function of a shell in an operating system?
Signup and view all the answers
Which of the following is NOT an advantage of using a debugger?
Which of the following is NOT an advantage of using a debugger?
Signup and view all the answers
Which command option in gcc allows you to specify the output file?
Which command option in gcc allows you to specify the output file?
Signup and view all the answers
What command can be used to access the user manual in a Unix shell?
What command can be used to access the user manual in a Unix shell?
Signup and view all the answers
Which of the following is NOT a common shell command?
Which of the following is NOT a common shell command?
Signup and view all the answers
What is the purpose of the #include directive in a C program?
What is the purpose of the #include directive in a C program?
Signup and view all the answers
What character is used to run the gedit editor in the background?
What character is used to run the gedit editor in the background?
Signup and view all the answers
How does the main function in C differ from the main function in JAVA?
How does the main function in C differ from the main function in JAVA?
Signup and view all the answers
What is printed by the C program in the given example?
What is printed by the C program in the given example?
Signup and view all the answers
What data type does the main function in C return?
What data type does the main function in C return?
Signup and view all the answers
Which of the following is NOT a similarity between C and JAVA as indicated in the content?
Which of the following is NOT a similarity between C and JAVA as indicated in the content?
Signup and view all the answers
Which function is used to display output in C programming as shown in the example?
Which function is used to display output in C programming as shown in the example?
Signup and view all the answers
What will happen if you do not use the & symbol when starting gedit from the terminal?
What will happen if you do not use the & symbol when starting gedit from the terminal?
Signup and view all the answers
What command is used to compile a C source file into an executable file?
What command is used to compile a C source file into an executable file?
Signup and view all the answers
How can you run the compiled helloWorld executable from the command line?
How can you run the compiled helloWorld executable from the command line?
Signup and view all the answers
Which of the following is a correct way to print a formatted string in C?
Which of the following is a correct way to print a formatted string in C?
Signup and view all the answers
What does the command 'ls' do in the context of the command line?
What does the command 'ls' do in the context of the command line?
Signup and view all the answers
What is one significant difference between printing in C and Java?
What is one significant difference between printing in C and Java?
Signup and view all the answers
Which command will compile and link the C file helloWorld.c in a single step?
Which command will compile and link the C file helloWorld.c in a single step?
Signup and view all the answers
What is the purpose of using './' before the helloWorld executable?
What is the purpose of using './' before the helloWorld executable?
Signup and view all the answers
In C, which of the following is used for a single line comment?
In C, which of the following is used for a single line comment?
Signup and view all the answers
What does the width parameter in printf specify?
What does the width parameter in printf specify?
Signup and view all the answers
What will the output be for the command printf("%c", 65)?
What will the output be for the command printf("%c", 65)?
Signup and view all the answers
How do the %g and %f format specifiers differ in their output?
How do the %g and %f format specifiers differ in their output?
Signup and view all the answers
What will be the output of printf("%u", -256)?
What will be the output of printf("%u", -256)?
Signup and view all the answers
Which format specifier would you use to output a hexadecimal value?
Which format specifier would you use to output a hexadecimal value?
Signup and view all the answers
What happens if the width parameter specified is too small for the given number?
What happens if the width parameter specified is too small for the given number?
Signup and view all the answers
When using printf with the %f specifier, what does the precision parameter control?
When using printf with the %f specifier, what does the precision parameter control?
Signup and view all the answers
What is the correct way to define a constant value for the number of days in a year in Java?
What is the correct way to define a constant value for the number of days in a year in Java?
Signup and view all the answers
What type does the variable 'sick' represent in the C example?
What type does the variable 'sick' represent in the C example?
Signup and view all the answers
What will the expression '(sick && tired)' return if both 'sick' and 'tired' are set to 1 in C?
What will the expression '(sick && tired)' return if both 'sick' and 'tired' are set to 1 in C?
Signup and view all the answers
In C, how does the programming language interpret a non-zero value when using it in a conditional expression?
In C, how does the programming language interpret a non-zero value when using it in a conditional expression?
Signup and view all the answers
What is the purpose of the 'break' statement in a C switch case?
What is the purpose of the 'break' statement in a C switch case?
Signup and view all the answers
Which of the following is true about the use of the '&&' operator in C?
Which of the following is true about the use of the '&&' operator in C?
Signup and view all the answers
What value does 'NEWLINE' represent in both C and Java?
What value does 'NEWLINE' represent in both C and Java?
Signup and view all the answers
Which of the following statements about defining constants in C is correct?
Which of the following statements about defining constants in C is correct?
Signup and view all the answers
Study Notes
Chapter 1: Systems Programming and C Basics
- Systems Programming is closely linked to the operating system.
- Basic tools for use with the gcc compiler in a Linux Ubuntu environment (using VirtualBox) are explained.
- Introduction to the C programming language, comparing it with Java syntax.
- Simple programs demonstrating display of information, math calculations, handling random numbers, user input, arrays, and function calls are shown.
1.1 Systems Programming and Operating Systems
-
Applications Programming provides services directly to the user, examples include: internet browsers, word processors, games, database access programs, and spreadsheets.
-
Systems Programming provides services for other software or the computer system. It does not typically have a Graphical User Interface (GUI) that interacts with the user.
-
Examples of systems programs: Firmware (e.g., PC BIOS and UEFI), Operating Systems (e.g., Windows, Mac OSX, GNU/Linux, BSD), Game Engines (e.g., Unreal Engine 4, Unity 3D, Torque3D), Assemblers (e.g., GNU AS, NASM, FASM), Macro Processors (e.g., GNU M4), Linkers and Loaders (e.g., GNU Id which is part of GNU binutils), Compilers and Interpreters (e.g., gcc, Python, Java VM), Debuggers (e.g., gdb), Text editors (e.g., vim), Operating system shell (e.g., bash), Device Drivers (e.g., for Bluetooth, network cards).
-
Systems software is at a lower level than application software, often closely tied to the hardware. It uses system calls and provides efficient services to applications.
1.2 Tools for Systems Programming
-
Shells: Command-line user interfaces allowing access to operating system services. Examples include sh (Bourne shell), bash (Bourne-again shell), csh (C shell). Shells provide command-line shortcuts and environment variable settings. Also, shells allow programs to run with command-line arguments, options usually preceded by a dash character.
-
Text Editors: Programs for creating and editing text-based files, commonly used in C programming are vi/vim, emacs, and gedit.
-
Compilers: Software transforming source code into another programming language. In this course, the GNU compiler (GCC) will be used, which is Unix-like in design and free software.
-
Debuggers: Tools for testing and debugging other programs, like gdb, to control code execution, view variables and observe execution flow to find out where the program's going wrong or crashing.
1.3 Writing First C Program
- Writing C programs involves creating .c files (Source Code), compiling using gcc to produce .o files (Object Files), linking with libraries to produce an executable file, and ultimately running the executable file.
- Our First Program, a typical "hello world" C program is shown and explained.
1.4 C vs. Java
-
Similarities in syntax exist between the two, especially in their commenting features and conditional statements.
-
Differences include, C does not need to define the name of a class and the main() function in C returns an integer whereas in JAVA it returns void. Also, the handling of integers, objects, and strings are different, and in C the format string used with the printf function needs explicit flags to be added for each argument.
1.5 Getting User Input
-
C uses the scanf() function to get user input, similarly to Java's Scanner class.
-
To get input in C, pointers to variables are needed to specify locations in memory where input is stored (this is different from JAVA).
1.6 Functions & Procedures in C
- Functions are crucial for modularizing code for easier maintenance and reusability.
- Function parameters can be: Input data required by a function, Output data the function produces, Input/Output data that is both required and produced by the function.
- Functions are declared and defined before they are used, and passing by value or by reference to a function parameters are possible.
1.7 Coding Conventions/Style
- Variable names should begin with lowercase letters, and additional words capitalized, or using underscores.
- Fixed values like PI, DAYS_IN_YEAR, INTEREST_RATE (all in uppercase letters).
- Use descriptive names for variables for clarity.
- Indentation style is important for code readability.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge on the primary functions and characteristics of text editors and operating systems in this engaging quiz. You'll explore concepts related to Unix, GNU, and the use of various shell commands. Perfect for students studying computer science or software engineering!