Hot answers tagged

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 ...
user avatar
  • 5,172
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.
user avatar
  • 957
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, ...
user avatar
  • 63.1k
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 ...
user avatar
  • 63.1k
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 - ...
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 ...
user avatar
  • 63.1k
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() ...
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 ...
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 ...
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++)
user avatar
1 vote

Clarification regarding for loops and arrays

Rob was demonstrating the use of a for loop to load values into an array. The i doesn't stand for anything. It is simply a counter for the for loop. It is a standard and common practice to use a ...
user avatar
  • 63.1k

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