Questions tagged [if]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
2 answers
747 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 [-...
olafironfoot's user avatar
1 vote
1 answer
43 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> #...
Iftikhar's user avatar
  • 113
1 vote
1 answer
50 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 {{ ...
wingedRuslan's user avatar
1 vote
1 answer
78 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 ...
Chris's user avatar
  • 159
0 votes
1 answer
211 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, ...
shiru_E's user avatar
0 votes
1 answer
2k 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: ...
koko loko's user avatar
0 votes
1 answer
67 views

credit pset1 cs50 sum while loop

I was doing the credit problem with the visa test card in the page: 4003600000000014 It passed that test, however in other tests it doesn't pass. I think it's a matter of the sum that it can't compute ...
Thom OM's user avatar
0 votes
1 answer
242 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 (...
Musical_Ant's user avatar
0 votes
1 answer
119 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 ...
T.Layton's user avatar
0 votes
1 answer
599 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 (...
yuniFlaminjo's user avatar
0 votes
1 answer
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 <...
David Mark Serrano's user avatar
0 votes
1 answer
16 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 { ...
Mark Cangila's user avatar
0 votes
1 answer
88 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 ...
mschweitzer1's user avatar
0 votes
1 answer
54 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! #...
Joshua Swift's user avatar
0 votes
1 answer
44 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 ...
MrDantab's user avatar
0 votes
2 answers
55 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!
Jose Antonio Velasco's user avatar
0 votes
0 answers
21 views

Scratch Problem I can;t able to find Out my problem

Please Somebody help me Why Sprite of Ball is not working when condition hits . When ande touches the ball the ball should to initial position but it is not working
DevloperOso's user avatar
0 votes
1 answer
17 views

Getting error expected ')' and I don't know why

if ((word{i} >= 'a' && word{i} <= 'z') || (word{i} >= 'A' && word{i} <= 'Z')) { while (points{j} < word{i}) { j++; } ...
Harr's user avatar
  • 35
0 votes
1 answer
112 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 ...
Alejandro Sánchez's user avatar
0 votes
2 answers
93 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 ...
user avatar
0 votes
1 answer
62 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. ---
NovNov's user avatar
  • 7
0 votes
1 answer
78 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> ...
gly's user avatar
  • 3
0 votes
1 answer
25 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 ...
Lisa Kucharski's user avatar