Why do I get "error: variable 'sum_r' set but not used [-Werror,-Wunused-but-set-variable]" when I set a variable inside a for loop?

Why do I get an error, error: variable ‘sum_r’ set but not used [-Werror,-Wunused-but-set-variable] when I set the variables sum_r sum_g, and sum_b in a for loop then try to change their values later in another for loop? Here is my current code: // Blur image void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE… Read More Why do I get "error: variable 'sum_r' set but not used [-Werror,-Wunused-but-set-variable]" when I set a variable inside a for loop?

CS50-HALF Practice Problem – What can I do to troubleshoot my code, which is functioning properly but not producing the desired output?

CS50 Practice Problem HALF – Background Suppose you are eating out at a restaurant with a friend and want to split the bill evenly. You may want to anticipate the amount you’ll owe before the bill arrives with tax added. In this problem, you’ll complete a funtion to calculate the amount each of you owes… Read More CS50-HALF Practice Problem – What can I do to troubleshoot my code, which is functioning properly but not producing the desired output?

cs50/pset1/credit Can't figure out how to use a digit counter without changing the initial variable

The digit counter works, displaying thhe correct number of digits, however my variable (number) changes from the initial input. I need it to stay the same because I use it later on in he code to test what type of card it is. Here is an example input and output. /workspaces/cs50/credit/ $ ./credit Number? 378282246310005… Read More cs50/pset1/credit Can't figure out how to use a digit counter without changing the initial variable

incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (void)'

#include <cs50.h> #include <stdio.h> int get_cents(void); int calculate_quarters(int cents); int main(void) { //Ask how many cents the customer is owed int cents = get_cents; // Calculate the number of quarters to give the customer int quarters = calculate_quarters(cents); cents = cents – quarters * 25; } int get_cents(void) { int cents; do { cents =… Read More incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (void)'

why is my char array printing in lower case after i've converted it to uppercase?

I’m trying to do the CS50 substitution problem. My code uses cs50.h library to handle strings. Currently I have a function to convert a string to lower case, and one to convert it to uppercase: string strtolower(string text) { int length = strlen(text); for (int i = 0; i < length; i++) { text[i] =… Read More why is my char array printing in lower case after i've converted it to uppercase?

CS50 Week 2 Practice

I am getting an undeclared identifier error for the string text although I identified it previously. I am trying to create the for loop to run between 0 and strlen(text). Does anyone know what I am missing? #include <cs50.h> #include <stdio.h> #include <ctype.h> #include <math.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[]) {… Read More CS50 Week 2 Practice

Getting segmenatation fault even though i freed memory

#include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef uint8_t BYTE; int main(int argc, char *argv[]) { // Only allow 2 command line arguments if (argc != 2) { printf("Usage: ./recover FILENAME\n"); return 1; } // Open the file FILE *input_file = fopen(argv[1], "r"); // Check if the input_file file is a valid ifle if (input_file ==… Read More Getting segmenatation fault even though i freed memory

some issue with values im not quite understanding

def main(): dollars = dollars_to_float(input("How much was the meal? ")) percent = percent_to_float(input("What percentage would you like to tip? ")) tip = ((dollars * percent) /100) print(f"Leave ${tip:.2f}") def dollars_to_float(dollars): dollars_to_float = float(dollars) def percent_to_float(percent): percent_to_float = float(percent) main() so it seems like tip its not getting the values from dollars and percent but why?… Read More some issue with values im not quite understanding

Why doesn't the program print "letters" if i specified that i want to use it?

I need to print out the amount of letters, sentences and words input on the terminal when I run the program. I tried to do it this way but I’m surely doing something wrong. #include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <math.h> int count_letters(string text); int count_words(string text); int count_sentences(string text); int main(void)… Read More Why doesn't the program print "letters" if i specified that i want to use it?