# Tag Info

### why do we use remainder 26 (%26)?

% 26 will always give you a number between 0 and 25. The Caesar algorithm works on the assumption that your letters A-Z (or a-z) are represented by the numbers 0-25, so if you have 'z' (25) and a key ...
• 18.7k
1 vote
Accepted

### cash CS50 2020 pset1 modulo

Why are you using modulo for this? It produces an unreliable result in this usage. Further, the actual numbers don't make sense. The modulo function returns the remainder after an integer division. ...
• 69.2k
1 vote
Accepted

### PSET1 - Credit Checksum Problem

test.c:35:49: error: invalid operands to binary expression ('double' and 'double') printf("%lld\n", ((l / (pow(10.00, i))) % 10)); ~~~~~~~~~~~~~~~~~~~~~ ^ ~~ 1 error ...
• 69.2k
1 vote
Accepted

### PSet1 cash, modulo problem

Welcome to the world of (binary) floating point. A value like 4.2 cannot be precisely represented in binary, it would be represented by an infinite sequence of binary digits. Obviously we don't have ...
• 21k
1 vote
Accepted

### Pset1 Cash Understanding modulo operator and while loops

You have created an infinite loop. If the loop starts, it will never exit the loop. It tests the value contained in amount to decide to continue or exit, but since the value of amount is not changed ...
• 69.2k
1 vote
Accepted

### Pset 2 Caesar: "invalid operands to binary expression ('string' (aka 'char *') and 'int')"

In that formula, use p[i], the ith character of p, not p itself.
• 21k
1 vote
Accepted

### Another modulo question for CS50 Caesar

I would suggest that you convert both your uppercase and lowercase chars into an index value of 0-25. That is the premise of the caesar formula.
• 18.7k
1 vote
Accepted

### Trying to make cash.c from pset 1 without mod

Please have another look at the second hint of this exercise (https://docs.cs50.net/2018/x/psets/1/cash/cash.html#hints). After you have followed that advise, you will be able to use the modulo ...
• 1,009
1 vote
Accepted

### Output of characters at specific place place using uint_list

If you want to print something different based on a condition, you need to use a conditional like an if. As written this program will only ever output (sign) and 5 dashes. Full stop. This does not ...
• 28.6k
1 vote
Accepted

### PSET1 / Credit / Modulo problem / Error: invalid operands to binary expression ('double' and 'double')

the definition of the pow function says that it returns a double that is the reason of your error, since the operator modulo requires integers, it is possible that it works if we do a casting although ...
• 5,179
1 vote

### Refactoring Pset1 Greedy Modulo

You could simply use coins as the variable that holds the coin value and add to it with each equation. coins = 0; coins += amount/25; ... coins += amount/10 .... etc etc. Then, at the end, coins ...
• 18.7k
1 vote
Accepted

### vigenere key wraparound issue

Take a close look at this line and think very carefully about what the modulo operation is being applied to: int cipherKey = (((key[i]) - 'A') % KeyLen); It coverts a key letter to a number between ...
• 69.2k
1 vote
Accepted

### greedy with modulo

You're creating multiple shadow variables in the code. A shadow variable is a new var with the same name as one that has been created earlier, but the new var is created in a place where it will have ...
• 69.2k
1 vote
Accepted

### strange output in vigenere. Even when done by hand to add ascii values

We have 26 characters in English alphabet, so use %26 and not %25. Also, note what you apply that %26 to, you seem to apply it to tolower(argv[1][counter]) - 97 only instead of to the whole sum.
• 21k
1 vote
Accepted

### Pset2 Vigenere z key stops functionning after e

By the let me tell you that your program is not working at all It's showing error something like this b.c:16:10: runtime error: null pointer passed as argument 1, which is declared to never be ...
• 252

Only top scored, non community-wiki answers of a minimum length are eligible