Docsity

Programming I Exercises: C Language Fundamentals, Ejercicios de Programación C

Toggle sidebar
bg1
DEPARTMENT OF COMPUTER SCIENCE AND INFORMATION TECHNOLOGIES
PROGRAMMING I - Course 2019/2020
Item 3 exercises
1. Design and implement a subroutine in C language to write N blank lines on the
screen. In addition to the subprogram, implement a program to test it.
2. Design and implement a subroutine in C language that from the initial day of
the week (M, T, W, X, F, S, Y) entered through the keyboard, return and display
on screen the name of the day. In addition to the subprogram, implement the
appropriate program to test it.
3. Write a program using user functions, which prompted an integer and display
on screen the largest integer that divides it except himself.
4. Design and implement a subroutine in C language to resolve a quadratic
equation Ax2 + Bx + C = 0 from the coefficients A, B and C. In addition to the
subprogram, implement the appropriate program to test it.
5. Design and implement a subroutine in C language to display on screen the
Floyd’s triangle up to an integer number entered by keyboard. In addition to the
subprogram, implement the appropriate program to test it.
6. Design and implement a subroutine in C language to display on screen N rows
of Floyd’s triangle. Include user function to obtain correct number of rows (N>
0). In addition to the subprogram, implement the appropriate program to test it.
pf3
pf4
pf5

Vista previa parcial del texto

¡Descarga Programming I Exercises: C Language Fundamentals y más Ejercicios en PDF de Programación C solo en Docsity!

DEPARTMENT OF COMPUTER SCIENCE AND INFORMATION TECHNOLOGIES PROGRAMMING I - Course 2019/

Item 3 exercises

  1. Design and implement a subroutine in C language to write N blank lines on the screen. In addition to the subprogram, implement a program to test it.
  2. Design and implement a subroutine in C language that from the initial day of the week (M, T, W, X, F, S, Y) entered through the keyboard, return and display on screen the name of the day. In addition to the subprogram, implement the appropriate program to test it.
  3. Write a program using user functions, which prompted an integer and display on screen the largest integer that divides it except himself.
  4. Design and implement a subroutine in C language to resolve a quadratic equation Ax^2 + Bx + C = 0 from the coefficients A, B and C. In addition to the subprogram, implement the appropriate program to test it.
  5. Design and implement a subroutine in C language to display on screen the Floyd ’s triangle up to an integer number entered by keyboard. In addition to the subprogram, implement the appropriate program to test it.
  6. Design and implement a subroutine in C language to display on screen N rows of Floyd ’s triangle. Include user function to obtain correct number of rows (N> 0). In addition to the subprogram, implement the appropriate program to test it.
  1. Design and implement a C language program through a series of subroutines determine whether a date entered by keyboard is not correct, taking into account leap years for it.
  2. Design and implement a function in C language that receives a value representing a month and return the following month, using the following interface: NextMonth(month:integer):integer;

NOTE: Note that the following month for 12 is 1.

  1. Design and implement a function in C language that receive a value representing a month and return the following month, using the following interface:

NextMonth(month:MSDs):MSDs;

  1. Design and implement a function in C language having an integer argument and returns the letter P if the number is positive or N if the number is negative. In addition to the subprogram, implement the appropriate program to test it.
  2. Design and implement a function in C language to read an integer within a range whose lower and upper limits are provided by the user from the keyboard. In addition to the subprogram, implement the appropriate program to test it.

EXAMPLE

Enter a date: 29/02/ The date entered is incorrect

Enter a date: 31/04/ The date entered is incorrect

  1. Design and implement a C language function that returns the factorial of a number n (n!). In addition to the subprogram, implement the appropriate program to test it.
  2. Design and implement a subroutine in C language to calculate the N-terminus of the Fibonacci sequence. In addition to the subprogram, implement the appropriate program to test it.
  3. Design and implement a subroutine in C language to indicate if an integer is a prime number. In addition to the subprogram, implement the appropriate program to test it.
  4. Design and implement a C language program to calculate the average of four scores of a student from a computer course (represented by four integers between 0 and 100) introduced by keyboard. It must necessarily include the following:
    • AskScore procedure: requests an integer from the keyboard between 0 and 100, if not, keeps asking until it is.
    • CalculateLevel function: get a real number and returns the average score according to the following table. Rating

[90, 100] A [80, 90] B [70, 80] C [60, 70] D [0, 60] E

  • Procedure prompts the user four notes (using AskScore ) and calculates the arithmetic mean of the same, plus call CalculateLevel for the letter of the score then be displayed on the screen.
  1. Design and implement a recursive function in C language to calculate the factorial of an integer. In addition to the subprogram, implement the appropriate program to test it.
  2. Design and implement a recursive function in C language to calculate the Nth power of an integer. In addition to the subprogram, implement the appropriate program to test it.
  1. Design and implement a recursive function in C language that sums the positive integers, up to a given integer. In addition to the subprogram, implement the appropriate program to test it.
  2. Design and implement a recursive function in C language to invert an integer. In addition to the subprogram, implement the appropriate program to test it.
  3. Design and implement a recursive function in C language that calculates and displays the multiplication table of an integer from this number and the maximum multiplier. In addition to the function, implement the appropriate program to test its operation.
  4. Design and implement a recursive function in C language to determine if a natural number is palindromic. In addition to the subprogram, implement the appropriate program to test it.
  5. Design and implement a recursive function that returns the sum of the digits of an integer > 0. Number For example, if the number is 721, it returns 10. In addition to the subprogram, implement the appropriate program to test it.
  6. Design and implement a recursive function in C language to solve the problem of Towers of Hanoi. In addition to the subprogram, implement the appropriate program to test it.
  7. Design and implement a recursive function in C language to determine the N terminus of the Fibonacci sequence. In addition to the subprogram, implement the appropriate program to test it.

Example

Enter an integer: 12 Enter the maximum multiplier: 7

12 x 1 = 12 12 x 2 = 24 12 x 3 = 36 12 x 4 = 48 12 x 5 = 60 12 x 6 = 72 12 x 7 = 84

  1. Design and implement, using functions and methods, a C program run that uses a menu where the user can choose from four options for the following operations:
    • Exit the program
    • Three options among the following:
      • Knowing the number of existing unaccented vowels in a text that the user types while not the * character appears.
      • Calculate the power of ab^ without using operators exponentiation.
      • Show on screen the factorial of the minimum between two positive integers introduced by the keyboard.
      • Display a table of squares and cubes of numbers contained into an integer range indicated by the user.
      • Draw a square, approximately centered on the character screen and side length specified by the user.
      • Show the area and perimeter of the rectangle with the smaller area. The user must indicate the lengths of the sides for two rectangles.
      • Display a table of numbers, squares and square roots of those numbers in a range of integers indicated by the user.
      • Calculate the maximum, minimum and average of a series of integers that the user enters by keyboard. Ends the series when the number entered is a multiple of 10.
      • Show on screen the dividers of an integer that indicates the user.
      • Draw an equilateral triangle, approximately centered on the character screen and side length specified by the user.
  2. Implement a C language program to work with complex numbers. The options that should have are:

1 - Insert two complex numbers as binomial form 2 - Introduce two complex numbers using module-argument form 3 - Add two complex numbers 4 - Subtract two complex numbers 5 - Multiply two complex numbers 0 - Exit