Category Archives: C language (en)
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
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
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
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
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
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
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
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
[C language ] Arithmetic progressions and MMORPGs
I am an avid MMORPG player and for me learning to program becomes much more fun and interesting if the programs I write have some connection to the games. This is especially important when it comes to some abstract mathematical … Continue reading
[C language] Operation precedence
It seems to me that I formatted the priorities of K&R operations more successfully: → ( ) [ ] -> . ← ! ~ ++ – – + – * & (type) sizeof → * / % → … Continue reading
[C language] memcpy() function
I remember that when I saw the memcpy () function for the first time in the code, I did not understand what kind of unknown animal it was. No one even thought to write a comment that explains it (no, … Continue reading
[ C language] Symbolic I/O and Redirection (Chapter 8)
The eighth chapter in Steven Prata’s book “C Primer Plus” (in the new edition it is called “Character I/O and Input Validation”). EOF (end of file) – designation of the end of the file. Ctrl+Z on Windows, Ctrl+D on UNIX. … Continue reading
[C language ] Insidious newlines on input
While doing the last exercise in Chapter 7, I ran into a problem reading an input line if it contains a newline. Everywhere this is explained somewhat abstrusely, I will try on my fingers: The problem is that when you … Continue reading
[C language] Printf statement line break
I forgot how to properly “cut” long pieces of printf, so I decided to write this cheat sheet. Let’s say you have a long printf expression and you need to break it into several smaller ones for readability (or to … Continue reading
[C language ] Scanf character input (%d): infinite loop error
When completing tasks from the seventh chapter, for the first time I encountered a “pinched cycle”. Let’s say the user enters the character q into a field (don’t do this unless you have the ability to interrupt the program): #include … Continue reading
[C language] Programming Exercises (Chapter 7)
Tasks from the seventh chapter of Stephen Prata’s book “C Primer Plus” – “C Control Operators: Branching and Jumps”. 1. Write a program that reads input until a # character is encountered, and then displays the number of spaces read, … Continue reading
[C language] C Control Statements: Branching and Jumping (Chapter 7)
The seventh chapter in Stephen Prata’s C Primer Plus. I want to start with a suitable divisors.c program For a given integer, you need to print all the integers by which the given number is divisible without a remainder; if … Continue reading