nos125 quiz 7 C programming

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What value does a C program return to the OS upon successful program execution?

0 zero

C programs are converted into machine language with the help of a _____?

A compiler

what is makefile?

A makefile describes to the make command how to compile the program. Explanation: A makefile is a file (by default named "Makefile") containing a set of directives used by a make to compile source code

C is what type of programming language?

High level

Which of the following is does NOT describe the C programming language?

It is an interpreted language

How do you compile a program consisting of multiple source files in C?

compile and link the 2 programs bye typing $ gcc prog1.c prog2.c -o program.

When writing a program, a(n) ____________________ structure provides the capability to make a choice between different instructions, depending on the result of some condition.

selection

How do you print the values of variables in C?

the *printf* function is used to print the value of the variable in C. (without the &) eg. printf("Entered: %d\n", number);

How would you write the classic "Hello, world!" program in C?

#include <stdio.h> /star hello.c star/ int main() { printf("hello, world!\n"); return 0; }

What is the purpose of the stdio.h header file in a C program?

#include <stdio.h> this line includes the "standard I/O library" into the program. The standard I/O library is used to read input from the keyboard (called "standard in"), write output to the screen (called "standard out"), process text files stored on the disk and so on.

Which C standard library is required to be able to read user input from the keyboard and display user output to the screen?

#include<stdio.h>

What are the different types of selection statements in C?

-if else, selection statement, if (statement) -do sthing else -print("sthing") -if, else if, else, multipath selection, if (statement) -do sthing else if (stat) -do sthing else -print("sthing")

What is an object file? A binary file? How do the two differ?.

-is a computer file containing object code, that is, machine code output of an assembler or compiler. -typically contain bytes that are intended to be interpreted as something other than text characters -The only difference is that the executable has the necessary linkages and entrypoints making it ready to be executable. The object file is not executable.

How do you obtain user input in a C program? What is the significance of a format specifier, like %d? What role does the "&" play in obtaining user input? What is likely to happen if the & is left off?

-the *scanf* function is used to accept input from keyboard. -the scanf function requires a *format specifier* to indicate the type of data to be entered (char, int, float, or string) and the address of the variable in memory used to store the value of the variable using the address "&" operator. scanf("%d", &number); the program will crash when & is not include

What are the steps to compile a program from source code? What is the purpose of the configure command? The make command? The make install command? The make clean command?

1. create a makefile (filename no extension). -filefunction1.o: filefunction1.c (tab) gcc -c filefunction1.c -filefunction2.o: filefunction2.c (tab) gcc -c filefunction2.c 2. $ make -f make_filename filename 3. execute: ./filename

What is the purpose of a Makefile? What is its relationship to the make command?

A makefile is used with the UNIX make utility to determine which portions of a program to compile. A makefile is basically a script that guides the make utility to choose the appropriate program files that are to be compiled and linked together. -The makefile is read by the make command, which determines the target file or files that are to be made and then compares the dates and times of the source files to decide which rules need to be invoked to construct the target. Often, other intermediate targets have to be created before the final target can be made.

What is OpenGL and why would you want to use it?

is a cross-language (programming language independent), cross-platform (platform independent) set of functions for rendering 2D and 3D graphics (using of polygons to represent image) -consists of hundreds of commands, which begin with a prefix "gl" glColor, glVertex, glTranslate, glRotate.

What is Cymothoa and why might you want to use it?

is a type of marine parasitic crustacean, in computing the analogy is that the Cymothoa program acts as a type of parasitic process to an existing process. is a post-exploitation tool, it can be used to maintain access to an exploited Linux system. Almost all Linux variants can be backdoored with Cymothoa.

What is the purpose of a return value in a C program? What does "return 0;" mean?

return 0; cause the function to return an error code of 0 (means no error) to the shell that started execution. zero = successful, others are failed.

What are the steps in the compilation process?

$ gcc filename.c -o filename (the -o option is used to specify the name of the output file). $ gcc math.c -o math -lm (the -lm option to the end of the gcc command line to force the linker to include the math library). Otherwise the program will not compile.

What is the general command format for compiling a program with gcc?

$ gcc filename.c -o filename.

The scanf function requires the address of a variable in memory to store input. Which character represents the address operator in C?

& ampersand

Who created the C Programming language? When? Where?

-Brian Kernighan and Dennis Ritchie, between 1972 and 1973, at Bell Labs.

What are the different type of looping statements in C?

-infinite loop = loops endlessly => while -do while loop -for loop. eg. while(response != 'n');

What are the steps to compile software from source code starting with downloading the source code itself?

1. download = wget http://source.com/file.tar.gz 2. unzip the file = tar zxvf file.tar.gz 3. change to dir filename 4. readme and install file, read them. 5. command ./configure 6. make 7. make install (installing the sw) 8. make clean (optional)

What is a compiler? What is the most common compiler in Linux

A special program called a *compiler* is to translate human readable text instructions into computer readable format that correspond to the same instructions. (gcc file.c -o file) -GNU C compiler, written by Richard Stallman

What is the purpose of the "make" command? (Select one or more answers.)

It is used to compile multi-source code files together.

You would like to create a instructional cybersecurity game in C. However, you know that C does not natively have any graphics capabilities. What library can you import to display graphics in C?

OpenGL

What is the "gcc" program?

The C compiler used almost universally in the Linux environment.

Which of the following statements concerning the main function in a C program is incorrect?

The main function is identified by the uppercase keyword START.

Choose the incorrect statement regarding the scanf function.

The scanf statement cannot be used to read string values.

What is Logstalgia and why might you want to use it?

also known as Apache Pong, is a website traffic visualization tool. The prog reads the Web server *access.log* and generates a graphic in an Atari pong-like game between the webserver and the specific HTTP page request. Requests appear as colored balls which travel across the screen to arrive at the requested file location. Any "page not found" (404 errors) responses are marked by the ball slipping past the pong paddle.

Which of the following is the correct sequence for producing an executable program?

edit, compile, link

The function scanf is used to ___.

input one or more values

The format identifier %d is also used for _____ data type.

int (integer)

Which of the following is not a data type in C? float, int, char.

real

How do you compile a program that needs to use an advanced math library?

with -lm option to the end of command line $ gcc mathfile.c -o mathfile -lm

What are the different data types in C? Approximately how much memory do they occupy when created?

-char 1 byte, range -128 to 127, format %c -int 4 bytes, range -2,127mi to 2,147m, %d -float 4 bytes, range -2m to 2m, %f.

What is the importance of the main function in a C program?

-declares the "main" function. Every C prog must have a function named main somewhere in the code.

What is the proper order of compiling and installing software from source code?

configure, make, make install, make clean.

The C programming language was developed at _____?

AT&T's Bell Lab

You have just downloaded and extracted the source code for a new cybersecurity software application. What should be your next step after changing into the source code directory?

Read the INSTALL file


Kaugnay na mga set ng pag-aaral

A&P- The Nervous System mastering questions

View Set

Cranial Nerves, Intracranial Pressure

View Set

geometry a - unit 4: triangles and parallelograms lessons 16-19

View Set

U.S. History: Unit 5-World War 1 (At Home and Away)

View Set

2021 NNAAP Nurse Aide Practice Written Exam, CNA - NNAAP Practice Exam - 2017, CNA Practice Questions 2016, 2018 CNA practice test, Certified Nursing Assistant (CNA) Practice Exam (Edition 2019), NNAAP NURSE AIDE PRACTICE WRITTEN EXAM 2020

View Set

Entre Chapter 6: Distribution, Promotion, Selling

View Set

CS 4407 - Data Mining and Machine Learning - Study

View Set

measurements,density, acceleration

View Set

Business of Fashion and Retail Exam Final

View Set