Questions tagged [if]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
89 views

Else is ruining my code in dna and I don't get why

I'm trying to record the longest run of each STR I need and I'm close. Without the final "else" the code works fine with small dictionary and almost fine with long (because the count I ...
0
votes
1answer
112 views

what is the significance of break; in tabulate function?

I know break statements are pretty basic, but it's got me here: This is my function: for (int i = 0; i < voter_count; i++) { for (int j = 0; j < candidate_count; j++) { if (...
0
votes
1answer
102 views

pset1 - credit - if-else statement issue

I have written a (clumsy) solution to the credit pset1. However, the solution only works for "Mastercard" credit card numbers (i.e. 5555555555554444). For "Visa" and "Amex" my code does return the ...
0
votes
2answers
61 views

Problem with credit.c concerning if loops with multiple initial conditions

I am working on the credit.c code. I am trying to make sure that the number of digits and the first digits of each credit card number value that is entered correspond with the brand that credit card ...
0
votes
1answer
392 views

Receiving 'error: expected expression' for code inside if statement (pset1)

Originally, my if statements looked like these (please note that I didn't really write them one after the other like this): if (counterCardLength == 15 && FindFirstTwoDigits == 34 | 37) if (...
1
vote
1answer
41 views

Output of characters at specific place place using uint_list

I am trying to make an output using 3 characters (vertical line, plus sign, minus sign) and using uint_list to increase or reduce the length. #include <stdio.h> #include <stdlib.h> #...
0
votes
1answer
26 views

Why are these if-else statements not letting my program compile?

I was wondering what is wrong with these if else statements because this program is not compiling. Any information would be appreciated and any advice please. #include <cs50.h> #include <...
0
votes
1answer
14 views

Pset 2 Crack: If statement doesn't check password correctly

I have a piece of code that checks the hash of the guessed password. if (temp == val) { printf("%s\n", paswrd); return 0; } else { ...
0
votes
1answer
961 views

control reaches end of non-void function

I have problem with my code (I guess). I have got the control reaches end of non-void function error even though my ifs (i think so ;) ) are covering all of the possibilities. Please have a look: ...
0
votes
1answer
83 views

PSET2 Caesar Bug in Uppercase Case For Loop

having an issue with caesar.c. I've got a loop working for lowercase cases where the key size would cause the key to loop out of alphanumeric characters, but when I try to implement the same loop for ...
1
vote
1answer
46 views

How to disable a table (portfolio) in index.html?

If there are no records in my portfolio, I do not want to show the table in index.html So, I tried as a parameter to pass a variable empty with value to index.html, where it was checked {% if {{ ...
0
votes
1answer
58 views

PSET4 If statement returns false on recover.c

The if statement given for recover.c for some reason keeps returning false and I'm not sure exactly what I'm doing wrong here. ---
0
votes
1answer
53 views

pset2 initials if statement not checking

I've debugged the code below and noticed the program checks the if statement inside the for loop but doesn't run the code inside even when the statement is true. Why is this? Thanks in advance! #...
0
votes
1answer
63 views

Why this code doesn't work?

I just started learning programming couple of days ago, and I made this for fun but it doesn't work on if and else with string.. what should I fix? #include <stdio.h> #include <cs50.h> ...
2
votes
2answers
597 views

Pset4 recover, comparing hex in if statements

I'm trying to solve "recover" but, I'm unable to compare my if statements. This is my error message: error: comparison of constant 224 with expression of type 'char' is always false [-...
0
votes
1answer
40 views

PSET 2: Nested IF statement

I'm trying to solve Caesar cypher ploblem from the course by using an if statement inside another if statement (Nested IF statement? apologies if I'm using the term incorrectly.) My draft attempt in ...
0
votes
1answer
24 views

I have a nested for loop, with if conditions that won't print out

My vigenere program, compiles and has most of the check50 test-thingy right. However, I cannot get the program to print out the cipher. Not sure what is legal here or not but I have gone over and ...
0
votes
2answers
74 views

pset5 check wrong if condition

This is how code looks before functions in dictionary.c typedef struct node { bool is_word; struct node* children[27]; } node; node* root; The load function works fine, but when the program ...
1
vote
1answer
28 views

Understanding continue statement in while loop in (pset6)

so I am all finished with pset6; however, I am having a hard time understanding what is going on here: while (true) { reset(); if (connected()) { // ..... bunch of other code that ...
0
votes
2answers
41 views

Having issues with a scratch “If” function

I'm having some issues with this "If" scratch function. Can someone tell me if I'm doing somethign wrong? Here is the link to the game. I'd apprecite the help! Thanks!
0
votes
1answer
192 views

when to use a series of ifs and when to use if/else if/else?

I noticed in week two's Monday lecture (where apple SSL bug was highlighted) that the programmer used a series of if statements. Is there a difference in logic between the two constructs. that is, ...