Category Archives: Programming (en)

C Language: Recursion Exercises

To learn recursion you need to pump up some muscles. To do so – make some of exercises  which are listed below. If something did not work out, you can peep the solution. Most likely the next day you will … Continue reading

Posted in C language (en) | Leave a comment

C Language: Recursion and the Collatz Conjecture

We continue to take the Computer Science CS50 course and the C language. We study recursion using the example of the Collatz hypothesis – an interesting (and easy to understand) mathematical problem that has not yet been solved by scientists. … Continue reading

Posted in C language (en) | Leave a comment

C language: multi-round voting

In the third week of the Computer Science CS50 (Harvard) course, it is proposed to do homework in Problem Set 3 called runoff.c – you need to write a program code that does not just calculate which candidate received the … Continue reading

Posted in C language (en) | Leave a comment

C Language: Majority Elections

The third week of Computer Science CS50 (Harvard) training begins and we continue to learn the C language. The first task: the implementation of a voting system where the candidate with the most votes wins, the so-called. plurality system or … Continue reading

Posted in C language (en) | Leave a comment

C language: Scrabble game with a friend

In the second week of the Computer Science CS50 (Harvard) course, after completing all the individual tasks, we move on to the C lab, which must be completed in a group. It will be an interesting task – to write … Continue reading

Posted in C language (en) | Leave a comment

C Language: Advanced Caesarian Encryption

We continue to do homework from Problem set 2 in Computer science CS50 (Harvard). Last time, we learned how to encrypt text by shifting letters by a certain number (key) entered by the user. And this time we will solve … Continue reading

Posted in C language (en) | Leave a comment

C Language: Calculating the Level of Difficulty of a Text Using the Coleman-Liau Index

We continue to take the Computer Science CS50 (Harvard) course, and this time we will do the task of calculating the level of complexity of the text according to the Colman-Liau index (readability.c) in the C programming language. According to … Continue reading

Posted in C language (en) | Leave a comment

C Language: Caesar Text Encryption

We continue to do homework in the Computer science CS50 (Harvard) course, and this time we need to write the program code and encrypt a text message. The essence of the ceasar.c task is that the program asks for the … Continue reading

Posted in C language (en) | Leave a comment

C language: how many coins does the cashier give

While studying Greedy Algorithms at CS50 (Harvard), let’s solve the problem about coins (Cash.c). Let’s say you need to give change to a customer in a store and you want to minimize the number of coins you give out to … Continue reading

Posted in C language (en) | Leave a comment

C Language: Checking Credit Card Number Using Luhn’s Algorithm

In the cs50 course (Harvard) there is a C programming problem to determine the correctness of a credit card number through the Luhn algorithm (credit.c). Let’s analyze this problem and show two more solutions. So. Any credit card has a … Continue reading

Posted in C language (en) | Leave a comment

C language: draw a pyramid from Mario

An interesting puzzle for beginners from CS50 (Harvard). Task: draw a pyramid from the Mario (mario-less.c) game using # symbols (lattice or hash). The user is asked: “How many blocks to make a pyramid from?”, he enters a number and … Continue reading

Posted in C language (en) | Leave a comment

JavaScript – loop with do-while postcondition

In JavaScript, in addition to the while and for loops, there is another variant of the do-while loop: do{ }while(); The meaning of this construct is that what is inside the curly braces is executed first, and then the while() … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – while and for loops

JavaScript has two loops, while and for. They both run at the same speed. The for loop is more flexible – it has three parts separated by semicolons in parentheses. General entry: for(first; second; third); Inside the parentheses, the semicolon … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – simple tasks for loops

Goal: write JavaScript code that calculates how much 2^10 is using a loop. Solution: varnum=2; varpower=10; varresult=1; var subpower=1 while (subpower<=power){result*=num;subpower++}; document.write(result)

Posted in Javascript (en) | Leave a comment

JavaScript – how to embed code in html and display on the site

JavaScript code can be written in any notepad and saved with a .js extension – you can also embed the code in an html page using the <script>…</script> tags in both the head and body sections. It is better to … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – Loops, Counter

A loop is a piece of code that repeats a certain number of times. The number of repetitions or the number of iterations is described with a counter. The loop is written with while(an expression that is converted to a … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – data output

Inside the html code, you can insert and execute JavaScript using the <script>…</script> tags, which can be inserted into the head of the page. Data output is different depending on the interpreter: var cat = “vera”; //cat’s name document.write(‘Hi, ‘ … Continue reading

Posted in Javascript (en) | Leave a comment