Skip to main content
3 votes
Accepted

What's the most efficient prime-finding algorithm? (Week 1 Practice Problems)

You can likely google it to find out. But the first thing that comes to mind is to lower the high limit of numbers to check. Simply put, if you're checking whether N is a prime, you need only see if ...
Cliff B's user avatar
  • 69.2k
2 votes

Selection Sort: Holes in Logic

The main problem is in the following statements: string answer = 0; answer[i]= min_value; Let's see if I can explain it clearly; a variable of type string is really a typedef (an alias in other ...
MARS's user avatar
  • 5,179
1 vote
Accepted

Converting roman numerals to integer

Efficiency Your code is terribly inefficient and that can be enhanced even without jumping to a switch statement. Right now every one of your if-statements is individually checked every time... This ...
UpAndAdam's user avatar
  • 1,636
1 vote
Accepted

How can i arrange the output in decending order In this program?

In the for loop use, (i = n, i >= 0, i--). This will start from n and go to zero so the output is in descending order. Hope this helps. If it does, please check the tickmark.
Vsjain's user avatar
  • 1,016
1 vote
Accepted

rejects a height of 9, and then accepts a height of 2 expected "" #"\n"##"", not ""

The code is supposed to keep prompting for a new value until the user enters an acceptable number. This code doesn't do that. Instead, it will ask for a number, and if that number is out of range, ...
Cliff B's user avatar
  • 69.2k
1 vote
Accepted

Pset 2 - loop question

Maybe you're just overthinking it a little? ;-) Just move the printf(Success) statement below the for loop. If the test fails, it's going to exit through the return statement. Otherwise, the code ...
Cliff B's user avatar
  • 69.2k
1 vote

While Loop in C only executing once and then stopping

So after you get an error message that says "Out of Range", when you try to enter another value that is out of range, the loop stops. There is a "clearKeyboard()" function that is called in here - ...
bbNicky's user avatar
  • 11
1 vote
Accepted

Infinite loop in pset2 Initials

It's actually in a loop that prints the first initial that follows a space. You can test this by entering 3 names instead of 2, like david willima smith. It would repeat w's infinitely. The problem ...
Cliff B's user avatar
  • 69.2k
1 vote

pset2 initials.c, returning first initial

The previous answer points you some mistakes, you should correct them. But your major conceptual problem is here: if (isspace(name[i]) == true && .....) it does not work like that. isspace() ...
obesman's user avatar
  • 1,139
1 vote

pset2 initials.c, returning first initial

Problem with the while version here: while (i <= 1 && i<=n). It will execute the loop exactly once. After i++, i is 2, and i <= 1 is false, loop over. (I think there's a problem with ...
DinoCoderSaurus's user avatar
1 vote

Resize.c is not copying pixels correctly

A quick way to format code properly: select the code and click the {} in the format bar, to-da. This can be done on initial post or you can edit the question and fix the format. Here is the pseudo ...
DinoCoderSaurus's user avatar
1 vote
Accepted

PSET 4 - Recover.c only recovering one empty file

infile is a string, it's content is the expression "card.raw". So what exactly is this loop supposed to accomplish? for (int i = 0; i < *infile; i++)
Yuri Laguardia's user avatar

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