

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!


Bachelor in Aerospace Engineering. 2020 - 21
Write a program that prints the integer numbers from 1 to 100. Write a program that prints the integer numbers from 1 to 100 counting by twos (1, 3, 4, 5, …). Write a program that prints the integer numbers from 100 to 1. Write a program that prints the multiples of 5 from 1 to 100 (5, 10, 15, …) (counting by fives)
Modify the last program of the previous exercise to first ask the user how many terms of the series to print, instead of printing until 100. (Example 4 terms: 5, 10, 15 ,20).
Write a program that asks the user for a number and then displays the message "the number you entered is ___". The program must repeat this until the user enters the value 0. Extend the program to count and print the total number of values entered by the user (excluding value 0) and their sum.
Write a program that displays the ASCII table on the screen. To do this, print a table showing the integer values 33 to 255 (%i), their associated ASCII character (%c), and the hexadecimal encoding (%x). This can be done by writing the same number three times, using the appropriate format specifiers, separated by a tab (tabulator \t). fprintf ('%c \t\t %i \t\t %x \n', i, i, i);
Write a program that reads 10 positive numbers from the keyboard and prints the following values:
Write a program that calculates the n-th power of a float value x (being n a positive integer value) using the following two methods: a) use myVar= x^n b) multiplying the number by itself n times (using loop structures).
Bachelor in Aerospace Engineering. 2020 - 21
Write a program that reads positive and/or negative integer numbers from the keyboard until the user enters 10 numbers or the sum of the numbers entered is larger than 100. The program must tell which condition was satisfied (“you entered 10 numbers”/ “sum larger than 100”) or if both were true.
Write a program to print the numbers in the range 1, …, 100 that are divisible by 5 and by 7. Note: You can use the built-in function mod(a,b)that we used in the previous lab session
Write a program that plays the guess the number game. The program asks the user to enter a number between 1 and 100. Next, this number is compared with the secret number, which is defined as a constant. If the user number is different from the secret number, the program must display a hint message indicating if the user value is bigger or smaller than the secret number. If the user number is equal to the secret number, the program prints the number of attempts and a feedback message according to the following:
Modify the previous program to generate the secret number in a random way in the range 1- 100 , using for that the built-in MATLAB function described in the previous lab session.
Extend the previous program to limit the number of attempts to 5. The only feedback to the user will now be if they won or not (if they were able to guess the number in 5 turns or less).
Write a program that prompts the user for positive integer numbers. If the number has 3 or more digits, the program prints Large even or Large odd number, and reads another value. If the number is positive but has less than 3 digits, the program directly asks for another value. If the number is 0 or negative, the program ends.
Write a program that reads a user name and a password value (as strings) and prints the message Log in successful if name is “root” and password is “1234”. After three unsuccessful attempts, the program prints to the screen No more attempts possible.