Reporte - Project 1 Programming
Reporte - Project 1 Programming
Engineering Programming
Project 1 Unit 1
Professor:
Student:
Manuel Arturo Ruz Azcorra
Index
Cover page.....................................................................................................1
Index..............................................................................................................2
Introduction...................................................................................................3
Struture control..............................................................................................3
Evidence........................................................................................................3
Logic operators..............................................................................................4
Conclusion.....................................................................................................4
3
Introduction
In the following report I will explain the elements used in the project, as well as the
control structure used (if, do while, nested structure and for), the codes made for each
exercise and the table of logical operators used such as ++, OR, % among others, with
their respective function.
Structure Control
The control structures used were for, do while, if, and nested to construct the codes
of the project.
For: The for loop is a control structure that allows a condition to be executed a certain
number of times. It consists of three parts: an initialization statement, a condition, and
an update statement. The loop ends when the condition is met.
Do while: Is a loop that executes at least once and then continues to execute as long as
the specified condition is met. unlike while, it first performs the action and then
checks it.
If: Is a condition that allows to fulfill a function if it is correct if it is not, the else can
be used to execute the opposite of the original function (depending on what is
required).
Nested: Nested control structures are structures that imply other structures within
themselves in order to generate more complex and specific decisions.
do{
printf("Enter a number between 1 to 10. \
n"); scanf("%d", &number);
} while (number<1 || number >10); //con el do while comprobamos si
el numero realmente es del 1 al 10//
if (number>=1 || number <=10){ //|| se refiere a la operacion
OR la cual indica si es un u otro ejemplo: 5>4|| 3>3 = 1 ó verdadero
for(i=1; i<= number; i++)
{ printf( "%d ", i
);}
if(number%2==0) // para comprobar si es par el numero ingresado//
n"); return 0;
4
Excersice 2.-
#include
Logic Operators
<stdio.h> int
Operator
main() { Function
= int num; equal
< printf("Introduce a positive number:Less than
> "); scanf("%d", &num); Greater than
<= Less than or equal to
if (num > 0) {// primera condicion para la estructura
>= Greater than or equal to
anidada// if (num % 2 == 0)
++ Increment
printf("The number is positive and even.\
% n"); else
Rest of
|| OR and odd.\n");
printf("The number is positive
} else if (num < 0) {// si no se cumple la primera condicion
evalua los numeros pares e impares//
Conclusion if (num % 2 == 0)
printf("The number is negative and even.\n");
By analyzing and describing various control structures such as conditionals and loops,
else //cumple la funcion de un sino, ejecuta la otra
as well as the use of logical operators, we can solve problems using these programming
funcion// printf("The number is negative an odd.\n");
tools. The understanding of these control structures allows us to make decisions for
}
more specific conditions which allows us to maintain better control of the program by
adapting to each specific situation. In summary, we can generate a better program
using return
logical operators
0; and control structures for the code.