Question

In: Computer Science

1. Provide brief answers to the following questions: a) What is preprocessing in C programming language?...

1. Provide brief answers to the following questions:
a) What is preprocessing in C programming language? Cite 3 examples of preprocessor directives in C.
b) What is the main difference between Heap and Stack memory regions?
c) What is the difference between Stack and Queue?
d) What is the purpose of a compiler? Name the C compiler that you used for this course?
e) What is a pointer variable in C?

2. int var;
Use this variable to write a single line code in C to read input using scanf library function call.

Solutions

Expert Solution

No.1)

a) Preprocessing is the task of taking input data and produces output that is to be actually compiled. For example, in C language, there are certain '#' sybmol followed by the name which has to be processed for subsequent stage. These are called preprocessor directives. Some examples are #define, #include, #ifdef and #endif.

b) In stack, the allocation and deallocation of memory is done automatically which happens due to predefined routes during compilation, whereas in Heap, the allocation of memory is done while execution of program written by the user. In stack, the memory once allocated can't be changed, whereas in Heap, the memory allocated can be altered.

c) Stack follows LIFO(Last In First Out) principle whereas a queue follows FIFO(First In First Out) principle. In stack, insertion and deletion takes place from on end only, but for queue, insertion and deletion takes place from opposite end.

d) A compiler takes the code of a program written in HLL(High Level Language) and converts it into machine readable form. The C compiler used is GCC(GNU Compiler Collection).

e) A pointer is a variable that stores address of another variable or a memory location.

No.2)

#include<stdio.h>

void main(){
        int var;
        scanf("%d", &var);
        return 0;
}

Related Solutions

Provide brief answers to the following questions. Use specific situations and examples where applicable ( In...
Provide brief answers to the following questions. Use specific situations and examples where applicable ( In Your Own Words) State and explain any two (2) sampling techniques / method in auditing  
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing chess himself to practice his abilities. The chess that Jojo played was N × N. When Jojo was practicing, Jojo suddenly saw a position on his chessboard that was so interesting that Jojo tried to put the pieces of Rook, Bishop and Knight in that position. Every time he put a piece, Jojo counts how many other pieces on the chessboard can be captured...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if (M <= N + 3 && (C == ‘N’ || C == ‘n’)) C = ‘0’; else C = ‘1’; Assume that M and N are 32-bit signed integer variables, and C is an 8-bit ASCII character variable. All variables are stored in memory, and all general-purpose registers are available for use.
Provide brief, but complete, answers to the following questions.(i)Why would one want to model some phenomenon...
Provide brief, but complete, answers to the following questions.(i)Why would one want to model some phenomenon as random but not others? For instance, an outcome of a coin toss is modeled as random but not the path of a projectile tossed into the air.(ii)What information completely characterizes, probabilistically speaking, a random variable? That is, having this information, one knows all one can possibly know about the nature of randomness.(iii)What would one want the relationship between population and sample moments to...
Part II: Programming Questions NOTE: CODING LANGUAGE IS C# PQ1. How would you declare the following...
Part II: Programming Questions NOTE: CODING LANGUAGE IS C# PQ1. How would you declare the following scalar and non-scalar (vector) variables? counter, an integer sum, a decimal number average, a decimal number grades, an array of 32 decimal numbers PQ2. How would you initialize the array above with numbers between 0.0 and 4.0 representing the grades of all courses a senior has received in the four years of college? Instead of initializing the array above, how would you, in a...
Complete the following assignment in C programming language. 1. Declare the following float variables: -Maximum exam...
Complete the following assignment in C programming language. 1. Declare the following float variables: -Maximum exam score, user's exam score, and percentage. 2. Ask the user to input data into your variables, such as: -"What is the max score of your exam:" -"What was your score:" 3. Use if statements to validate user inputs. For example, score received should not be more than maximum possible score. -Display an error message when the user enters invalid data. -You can restart the...
Instructions: 1. Please use only C as the language of programming. 2. Please submit the following:...
Instructions: 1. Please use only C as the language of programming. 2. Please submit the following: (1) the client and the server source files each (2) a brief Readme le that shows the usage of the program. 3. Please appropriately comment your program and name all the identifiers suitable, to enable enhanced readability of the code. Problem: Write an ftp client and an ftp server such that the client sends a request to ftp server for downloading a file. The...
The following is for C programming language: I want to scan for initials in a line...
The following is for C programming language: I want to scan for initials in a line of text. my line of text is as follows: 12345 3.5000 a j 12346 4.1000 s p The first number represents the student ID, the second number represents the gpa, the third character represents the first initial and the fourth character represents the last initial of the student. My text file contains these values. The following is my code: fscanf(fp, "%d %c %c", &studentID,...
The following question must be answered in the C programming language and may not be written...
The following question must be answered in the C programming language and may not be written in C++ or any other variation. Problem 5 This problem is designed to make sure you can write a program that swaps data passed into it such that the caller's data has been swapped. This is something that is done very frequently in manipulating Data Structures. The Solution / Test Requirements I want your program to demonstrate that you understand how to swap information...
Write brief but complete answers to the following questions a) Write Schrodinger's time-independent,1-D equation b) What...
Write brief but complete answers to the following questions a) Write Schrodinger's time-independent,1-D equation b) What does this equation represent? c) What requirements must the wave equation satisfy? d) What are the conditions for an acceptable solution to this equation?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT