Skip to content

SENAC - CS - ALGORITHMS AND PROGRAMMING I - In this repository i will reflect what I learned for this subject.

License

Notifications You must be signed in to change notification settings

nikiene/senac-cs-algorithms-and-programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SENAC - CS - ALGORITHMS AND PROGRAMMING I

In this repository i will reflect what I learned for this subject.
In total there are 9 exercise lists with increased complexity.

List I

  1. Write a program that asks the user to type two integers and prints the sum of these integers.

  2. Write a program that asks the user to type two integers and prints the quotient and the remainder of the integer division of these integers.

    The program should print both answers in a single printf. You can assume that the user will not try to divide by zero.

  3. Write a program that asks the user to enter an integer and prints the square of that integer.

  4. Write a program that asks the user to type the two dimensions of a rectangle and prints the perimeter and the area of that rectangle.

    The program should print both answers in a single printf.

  5. Write a program that asks the user to enter an integer and prints its inverse.

  6. Write a program that asks the user to enter an integer and prints only one number: 0 or 1.

  7. Write a program that converts temperatures from Celsius to Fahrenheit.

  8. Write a program that requests the weight and height values of a person, calculates and displays their BMI (Body Mass Index)

List II

  1. Write an algorithm that receives a number and shows a message if this number is greater than 10.

  2. Write a program that asks the user to enter two integers and prints them in ascending order.

  3. Write a program that asks the user to enter a number. Then inform if this number is even or odd.

  4. Write a program that receives an integer and informs if this number is a multiple of 10.

  5. Write an algorithm that reads two distinct integer values and informs which one is greater.

  6. Change the previous exercise so that it also tells you whether the numbers are the same.

List III

  1. Write a program that asks the user for an integer. Display an error message if the number is between 15 and 25 or between 45 and 50 (inclusive).

    Write a program that asks for a number that displays the message "SENAC" if this number is 13, 26, 42 or 70.

  2. Write a program that asks the user for a number and displays a message if this number is greater than 80, less than 25 or equal to 40.

  3. Write an algorithm that reads three integer values and checks if they can be the measures of the sides of a triangle.

    Property: the length of each side of a triangle is less than the sum of the lengths of the other two sides.

  4. Increment the previous exercise, in case the measures form a valid triangle, inform which type of triangle they form: equilateral, isosceles or scalene.

  5. Increment the previous exercise, now informing if this is also a right triangle.

List IV

  1. Write a program that draws a number from 1 to 10 and gives the user two chances to get it right.

    Write a program that draws a number from 1 to 10, gives the user two chances to get it right, but informs if the drawn number is greater or less than the first guess.

    Do the same previous program, now with 3 guesses.

  2. Write a program that draws two numbers from 1 to 5 and asks the user to get both numbers, not necessarily in the same order.

  3. Write a program that draws two numbers from 1 to 10. Inform how many of these numbers are between 3 and 7 (inclusive).

  4. Write a program that plays even or odd with the user.

List V

  1. Write a program that displays any complete multiplication table.

    The program should ask the user which multiplication table he wants to view, who will respond by entering a number from 1 to 10.

  2. Write a program that displays the square of all numbers from 1 to 20.

  3. Write a program that asks the user for 5 numbers, and for each number entered, informs whether it is even or odd.

  4. Write a program that displays the sum of the numbers from 1 to 100

  5. Write a program that requests 10 numbers and at the end displays the sum of all of them.

  6. Write a program that asks the user for a number, and then displays all its dividers.

  7. Write a program that asks the user to enter a number between 10 and 20. If an invalid number is entered, ask again until a correct number is entered.

List VI

  1. Write a program that requests a number and then says if it is a perfect number.

  2. Write a program that draws a number from 1 to 10 and gives the user two chances to get it right.

    Write a program that draws a number from 1 to 10, gives the user two chances to get it right, but informs if the drawn number is greater or less than the first guess.

    Write the same program as before, now with 3 guesses.

  3. Write a program that calculates the sum of all even numbers from 25 to 200.

  4. Write a program that requests the code and height of 5 athletes.

    At the end of the data entry, inform the HEIGHT of the tallest athlete.

  5. Write a program that requests the code and height of 5 athletes.

    At the end of the data entry, inform the CODE of the tallest athlete.

    Also inform the average height of these 5 athletes.

    Do not restrict data entry to only 5 athletes.

    Now after including each athlete the program should ask the user if they want to include another.

    The answer is given with (0/1). The program continues to show the CODE of the tallest, and the average height.

  6. Write a program that asks for a number and then says if this number is prime.

List VII

  1. Write a program that receives 5 integers and displays the smallest.

  2. Write a program that receives integers until the user types 0 and then displays the largest and smallest.

  3. Write a program that draws 10 even numbers between 1 and 100 and displays them on the screen. (how to ensure that the draw displays only even numbers?)

  4. Write a program that asks for a number and then displays the factorial of this number.

  5. Write a program that asks the user for 3 numbers from 1 to 60.

    The program will then continuously draw 3 numbers from 1 to 60 until the 3 tens entered by the user are drawn.

    In the end, it should display how many draws were made.

List VIII

  1. Write a program that creates a vector of 10 positions and inserts the number 8 in all positions.

  2. Write a program that reads 5 numbers and displays the ones that are above the average.

  3. Write a program that creates a vector of 100 positions, fills it with random numbers from 1 to 100. Display the average of these.

  4. Write a program that creates and fills the same vector of 100 numbers. Calculate the sum of all numbers that are below the average of the last 10.

  5. Write a program that creates and fills the same vector of 100 numbers. Calculate the sum of all numbers that are below the average of the last 10.

    Write the contents of the vector from the previous exercise on the screen, placing each value next to the previous one (on the same line).

    If the vector value is a multiple of 10, then insert a line break.

List IX

  1. Write a 3x3 matrix of integers, associate the value 8 with the central element of this matrix. Display the matrix on the screen properly.

  2. Write a 10x10 character matrix.

    Assign the letter "B" to all elements of the matrix.

    Then assign the character "8" to a random element of the matrix. Display the matrix on the screen.

  3. Write a 20x20 integer matrix. Fill with random numbers between 10 and 99.

    Show the sum of the values of all rows of this matrix, and inform which row has the highest value.

  4. Utilizing the same matrix, display the sum of the elements of the main diagonal.

  5. Write a program that reads a word and displays how many "A" letters this word has.

  6. Write a program that creates a 10x10 matrix of characters and fills it with spaces. Assign a character "O" to element 5,5.

    The program should ask the user to enter one of the following commands:

    1 - up, 2 - down, 3 - left, 4 - right, 5 - exit.

    The direction commands make the character "O" move through the matrix.

    The program should repeat until the user enters 5.

RUN

  • Setup:

    Install the GCC C Compiler and the Make program.

    For Windows users:

    You will need to install some kind of Linux environment on your machine. You can use a Virtual Machine or WSL (Official Microsoft WSL guide: https://learn.microsoft.com/pt-br/windows/wsl/about). After installing your preferred Linux distribution, you will need to run this command inside the bash:

    bash
    sudo apt-get install gcc make
    

    For Mac users:

    Run this on your terminal:

    xcode-select --install
    

    For Linux users:

    Run this on your terminal:

    sudo apt-get install gcc make
    

    Now that everything is set up, we can actually run the program!

  • Running:

    Inside the project folder just type in this command:

    make
    

    It compiles the code and generates an binary for each file inside each folder.

    Then you just run one of them, of course changing "directoryName" and "filename" for the actual values, for example ./list1/bmi!

    ./{directoryName}/{filename}
    

About

SENAC - CS - ALGORITHMS AND PROGRAMMING I - In this repository i will reflect what I learned for this subject.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published