

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
Prepara tus exámenes
Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Prepara tus exámenes con los documentos que comparten otros estudiantes como tú en Docsity
Encuentra los documentos específicos para los exámenes de tu universidad
Estudia con lecciones y exámenes resueltos basados en los programas académicos de las mejores universidades
Responde a preguntas de exámenes reales y pon a prueba tu preparación
Consigue puntos base para descargar
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Comunidad
Pide ayuda a la comunidad y resuelve tus dudas de estudio
Ebooks gratuitos
Descarga nuestras guías gratuitas sobre técnicas de estudio, métodos para controlar la ansiedad y consejos para la tesis preparadas por los tutores de Docsity
Asignatura: Fundamentos de la Programación, Profesor: Juan Falgueras, Carrera: Grado en Ingeniería Informática, Universidad: UMA
Tipo: Ejercicios
1 / 3
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!


−b+
b^2 − 4 ac 2 a
−b−
b^2 − 4 ac 2 a equs.cpp 14/10/14 10:
1 # include < iostream > 2 using namespace std ; 3 4 const tax : 25.0; 5 const HOURLY_PAY = 60. 6 7 int main ()
2
9 double hours , days , total , net ; 10 11 cout << " Enter the number of worked hours : " ; 12 cin << hours ; 13 cout << " Enter the number of worked days : " ; 14 cin >> days ; 15 hours * days * HOURLY_PAY = total ; 16 net = total - TAX ; 17 cout << " The gross amount to be paid is : " ; 18 cout << total << endl ; 19 cout << " The net amount to be paid is : " ; 20 cout << NETO << endl ; 21 22 return 0; 23 }
4 Write a program that allows the input of an integer data type and then it writes it
on the screen. Run this program entering a valid, legal, integer number; run it again
but entering a no valid integer number, any word, for example. Write a comment at
the program source headings explaining the differences between both behaviours.
5 Write a program that display on the screen the size in bytes of every data type
studied in class: int, long, char, etc. Use the operator: sizeof
6 Write a program that reads 4 letters, and then writes those letters but encoded,
writting then, instead of each letter, its next letter in the ASCII table. For example,
if entered SETO, it should print: TFUP.
7 Write a program that reads a natural number, standing for a number of bytes. Then
print the amount of MegaBytes (MB), KiloBytes (KB), and bytes (B) that that
number contains. For example: for the number 26871979, it should print: 25 MB,
642 KB, and 171 B
8 The next program converts an age, entered in years, to days:
1 # include < iostream > 2 using namespace std ; 3 4 int main () 5 { 6 int ageYears ; 7 cout << " Input the age in years : " ; 8 cin >> ageYears ; 9 int ageDays = ageYears * 365; 10 cout << " Days : " << ageDays << endl ; 11 return 0; 12 } 13
Make a program to do the opposite ask for the age in days and display the age in
years (discard the remainded days that not complete a complete year). In order to
ask for a number (or a char or a string... ) we can use in this case:
cin >> age;
In doing so, our program will await there for us to enter a number and that number
will be assigned to the variable age, the only variable we need.
9 A student wants to know their final mark in the subject FP. That mark is built from
the mark in the final exam and the marks in the two tests. The weight of the final
exam mark is wf = 1 − 0. 15 × (m 1 + m 2 )/10. So to obtain the final mark we must
do: mf × wf + (m 1 + m 2 ) × 0 .15.
Ask the user for the final exam, mf , and m 1 and m 2 (all of them over 10), and
display their final mark.