Sunday, November 1, 2020

FUNCTIONS IN C PROGRAMMING (Activities)

Do the exercises based on the text

Functions in C Programming with examples

We will  learn functions in C programming.

A function is a block of statements that perform a same task. If you are writing a C program and you need to perform a same task in that program more than once, you have two options:

a) Use the same set of statements every time you want to perform the task
b) Create a function to perform that task, and just call it every time you need to perform that task.

Using option (b) is a good practice and a good programmer always uses functions while writing code in C.

Why we need functions in C

Functions are used because of following reasons:
a) To improve the readability of code.
b) Improving the reusability of the code the same function can be used in any program rather than writing the same code from scratch.
c) Debugging of the code would be easier if you use functions because errors are easy to be traced.
d) It reduces the size of the code, duplicated set of statements are replaced by function calls.

Available on https://beginnersbook.com Acceso el 1 de noviembre, 2020.
A- Diga si las afirmaciones son verdaderas o falsas. Justifique las falsas.
1. Aprenderemos las funciones de la programación en C.
2. Una función es un bloqueo de declaraciones.
3. Una función realiza diferentes tareas.

B- Complete en español.
1. Use the same ...
2. Create a function ...
3. Using option (b) is ...

C- Conteste las siguientes preguntas:
1. ¿ Qué mejora las funciones de C?
2. ¿ Qué se puede usar para no escribir el mismo código desde cero?
3. ¿ Qué sería más fácil si se usa si se usan las funciones?



Modular Programming CONTEXTUAL REFERENCES

Modular Programming

by Kenneth Leroy Busbee and Dave Braunschweig

Overview 

Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

Concept of Modularization

One of the most important concepts of programming is the ability to group some lines of code into a unit that can be included in our program. The original word for this was a sub-program. Other names include: macro, sub-routine, procedure, module and function. Functions are important because they allow us to take large complicated programs and to divide them into smaller manageable pieces. Because the function is a smaller piece of the overall program, we can concentrate on what we want it to do and test it to make sure it works properly. Generally, functions fall into two categories:

  1. Program Control – Functions used to simply sub-divide and control the program. These functions are unique to the program being written. Other programs may use similar functions, maybe even functions with the same name, but the content of the functions are almost always very different.
  2. Specific Task – Functions designed to be used with several programs. These functions perform a specific task and thus are usable in many different programs because the other programs also need to do the specific task. Specific task functions are sometimes referred to as building blocks. Because they are already coded and tested, we can use them with confidence to more efficiently write a large program.
  3. The main program must establish the existence of functions used in that program. Depending on the programming language, there is a formal way to:

    1. define a function (its definition or the code it will execute)
    2. call a function
    3. declare a function (a prototype is a declaration to a compiler)
Available at https://press.rebus.community/programmingfundamentals/chapter/modular-programming/. Acceso el 1 de noviembre, 2020.

Monday, October 26, 2020

Formal Syntax and Semantics of Programming Languages

REALICE LAS ACTIVIDADES QUE SE ENCUENTRAN AL FINAL DEL TEXTO  

Chapter 1 

SPECIFYING SYNTAX

Language provides a means of communication by sound and written symbols. Human beings learn language as a consequence of their life experiences, but in linguistics—the science of languages—the forms and meanings of languages are subjected to a more rigorous examination. This science can also be applied to the subject of this text, programming languages. In contrast to the natural languages, with which we communicate our thoughts and feelings, programming languages can be viewed as artificial languages defined by men and women initially for the purpose of communicating with computers but, as importantly, for communicating algorithms among people. 

Many of the methods and much of the terminology of linguistics apply to programming languages. For example, language definitions consist of three components: 

1. Syntax refers to the ways symbols may be combined to create well-formed sentences (or programs) in the language. Syntax defines the formal relations between the constituents of a language, thereby providing a structural description of the various expressions that make up legal strings in the language. Syntax deals solely with the form and structure of symbols in a language without any consideration given to their meaning. 

2. Semantics reveals the meaning of syntactically valid strings in a language. For natural languages, this means correlating sentences and phrases with the objects, thoughts, and feelings of our experiences. For programming languages, semantics describes the behavior that a computer follows when executing a program in the language. We might disclose this behavior by describing the relationship between the input and output of a program or by a step-by-step explanation of how a program will execute on a real or an abstract machine. 

3. Pragmatics alludes to those aspects of language that involve the users of the language, namely psychological and sociological phenomena such as utility, scope of application, and effects on the users. For programming languages, pragmatics includes issues such as ease of implementation, efficiency in application, and programming methodology.

Syntax must be specified prior to semantics since meaning can be given only to correctly formed expressions in a language. Similarly, semantics needs to be formulated before considering the issues of pragmatics, since interaction with human users can be considered only for expressions whose meaning is understood. In the current text, we are primarily concerned with syntax and semantics, leaving the subject of pragmatics to those who design and implement programming languages, chiefly compiler writers. Our paramount goal is to explain methods for furnishing a precise definition of the syntax and semantics of a programming language. We begin by describing a metalanguage for syntax specification called BNF. We then use it to define the syntax of the main programming language employed in this text, a small imperative language called Wren. After a brief look at variants of BNF, the chapter concludes with a discussion of the abstract syntax of a programming language. At the simplest level, languages are sets of sentences, each consisting of a finite sequence of symbols from some finite alphabet. Any really interesting language has an infinite number of sentences. This does not mean that it has an infinitely long sentence but that there is no maximum length for all the finite length sentences. The initial concern in describing languages is how to specify an infinite set with notation that is finite. We will see that a BNF grammar is a finite specification of a language that may be infinite.

Available at https://www.mobt3ath.net/uplode/book/book-26246.pdf. Acceso el 26 de octubre, 2020.


What is Object Oriented Programming (OOPS)? (Link to YOUTUBE)

 LEA EN ESPAÑOL LAS DIAPOSITIVAS DEL VIDEO

PRESS HERE

Programming Logic and Languages: Syntax and semantics | | UPV(Link to YOUTUBE)

ABRA EL LINK Y LEA EN ESPAÑOL LAS DIAPOSITIVAS DEL VIDEO 


PRESS HERE and you will be redirect to the webpage.