Questions tagged [if]
The if tag has no usage guidance.
23
questions
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
[-...
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>
#...
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 {{ ...
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 ...
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, ...
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:
...
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 ...
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 (...
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 ...
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 (...
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 <...
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 {
...
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 ...
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!
#...
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 ...
0
votes
2
answers
56
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
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
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++;
}
...
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 ...
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 ...
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.
---
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>
...
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 ...