Programming Language Assignment: Core Concepts and Applications

Verified

Added on  2022/09/09

|7
|889
|19
Homework Assignment
AI Summary
This document provides solutions to a programming language assignment, addressing key concepts such as logical AND operators, debuggers, data types (integer, float, boolean), functions, and parameter passing (pass by value and pass by reference). The solution explains the purpose and usage of the logical AND operator, the functionality of a debugger, and the differences between various data types. It further elaborates on the concept of functions, including their features and types, and demonstrates the use of parameters with examples of pass by value and pass by reference. The assignment also includes references to supporting literature. This assignment is intended to help students understand and apply core programming language principles.
Document Page
Running head: PROGRAMMING LANGUAGE
PROGRAMMING LANGUAGE
Name of the Student
Name of the University
Author Note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1PROGRAMMING LANGUAGE
Q1. The logical AND operator is used for the purpose of setting a condition where both the
operands are TRUE. This returns true value when both the operands are non-zero (Nielson,
Nielson and Hankin 2015). The result data type is Boolean.
Q2. Debugger is a computer program that is used for the purpose of testing and debugging other
programs. This focuses on running the targeted program with the help of proper controlled
conditions (Millard et al. 2018). The features associated with the debugger are as follows:
Execution
Breakpoints
Runtime
Debugging is referred to the process that is used for the purpose of fixing a bug within a
program. The main function is to identify, analyze and remove the errors that can lead to
hampering the program (Spyropoulou et al. 2015). This ensures that the program has been
executed successfully.
Q3. Integer: this is used for the purpose of storing integer values that includes number without
decimal places.
int IntegerNumber =0;
float FloatingPointNumber = 0.0;
IntegerNumber= atoi (“1000”);
FloatingPointNumber= atof (“1000.0”)
Floating: float is used for the purpose of storing number with decimal places
int IntegerNumber =0;
Document Page
2PROGRAMMING LANGUAGE
float FloatingPointNumber = 0.0;
IntegerNumber= atoi (“1000”);
FloatingPointNumber= atof (“1000.0”)
Boolean: this data type is used for determining whether a statement is true of false based on the
operands.
resetTimer(T4);
while ( getTimer(T4, milliseconds) < 100) {
if (getColorGrayscale(colorDetector1) < 20) {
if (getColorGrayscale(colorDetector2) < 20) {
// Both dark
doSomething();
resetTimer(T4);
}
}
}
Q4. Functions are used with the aim of storing a code. This is used for the purpose of performing
repetitive tasks that are used for the purpose of increasing efficiency within a program. Thus with
the help of a function it becomes easy to enhance the ability to execute a program (Hathhorn,
Ellison and Roşu 2015). The features that are offered with functions are reusability of code,
Document Page
3PROGRAMMING LANGUAGE
removes the redundancy within the codes and also ensures that the complexity has been reduced.
There are mainly two types of functions that are the built in functions and the user defined
functions. With the help of functions it becomes simple to use the programs as it offers different
calling functions for arguments.
Q5. Parameters are used for the purpose of passing the variables between the main program and
function with the help of caller functions (Patel and Patt 2019). The two functions that are used
are pass by value and pass by reference.
Pass by value:
void func(int a, int b)
{
a += b;
printf("In func, a = %d b = %d\n", a, b);
}
int main(void)
{
int x = 5, y = 7;
// Passing parameters
func(x, y);
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4PROGRAMMING LANGUAGE
printf("In main, x = %d y = %d\n", x, y);
return 0;
}
In the func, a=12, b=7
In main, x=5, y=7
Pass by reference:
void swapnum(int* i, int* j)
{
int temp = *i;
*i = *j;
*j = temp;
}
int main(void)
{
int a = 10, b = 20;
// passing parameters
Document Page
5PROGRAMMING LANGUAGE
swapnum(&a, &b);
printf("a is %d and b is %d\n", a, b);
return 0;
}
Output: a=20, b= 10
Document Page
6PROGRAMMING LANGUAGE
References
Hathhorn, C., Ellison, C. and Roşu, G., 2015, June. Defining the undefinedness of C. In ACM
SIGPLAN Notices (Vol. 50, No. 6, pp. 336-345). ACM.
Millard, A.G., Redpath, R., Jewers, A., Arndt, C., Joyce, R., Hilder, J.A., McDaid, L.J. and
Halliday, D.M., 2018. ARDebug: an augmented reality tool for analysing and debugging swarm
robotic systems. Frontiers Robotics AI.
Nielson, F., Nielson, H.R. and Hankin, C., 2015. Principles of program analysis. Springer.
Patel, S. and Patt, Y., 2019. Introduction to Computing Systems: from bits & gates to C &
beyond. McGraw-Hill Professional.
Spyropoulou, N., Demopoulou, G., Pierrakeas, C., Koutsonikos, I. and Kameas, A., 2015.
Developing a computer programming MOOC. Procedia Computer Science, 65, pp.182-191.
chevron_up_icon
1 out of 7
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]