[Solved] C for loop not working

I tried to run that and my outputs for r1 and r2 are qwdaweqwe asdas–sd (two spaces) and basically it is what the code should be doing. But if I get your intention right, you want to work with those empty strings. Then you should be feeding your function with different numbers, because array indexing … Read more

[Solved] Java incrementing every character in a string by a large amount?

First I’m going to remove all of the I/O (except for outputting the result), get rid of the decryption piece for brevity, and write encrypt(String) and encrypt(char) as pure functions. public class EncryptionMain { public static void main(String args[]){ System.out.println(encrypt(“Hello”)); } static String encrypt(String plaintext) { StringBuilder ciphertext = new StringBuilder(plaintext); for (int i = … Read more

[Solved] Counting down or Counting up, Which one is faster? [duplicate]

Never wonder; use Google Caliper to find out. Since there has been quite a bit of discussion around the relative weights of testing against zero vs. upper limit and incrementing vs. decrementing, here’s the Cartesian product of all these cases: import java.util.Random; import com.google.caliper.Runner; import com.google.caliper.SimpleBenchmark; public class Performance extends SimpleBenchmark { static final Random … Read more

[Solved] For/if/else loop has unexpected identifier [closed]

Just about every angle-bracket language I know follows the following conventions: The condition of an if statement normally goes in parenthesis You shouldn’t have a curly brace at the end of turnCard(‘hit5′}; You shouldn’t have a ; at the end of your if-statements(or your for statement) Some languages allow you to use single-quotes like that … Read more

[Solved] Do and While Loop

You can use the while loop as follows: int i=1; while(i<=7) { sal = load(); rate = calcRate(sal); calcRaise(sal, rate, &raise, &totraise); calcNewSal(sal, raise, &newsal, &totnewsal); calcTotSal(&sal, &totsal); print(sal, rate, raise, newsal, totsal, totraise, totnewsal); fflush(stdin); i++; } And the do-while as follows: int i=1; do { sal = load(); rate = calcRate(sal); calcRaise(sal, rate, … Read more

[Solved] My Python code is looping at the wrong place

its easy to get confused when you have a big chunk of code like this … instead try and split your problem into smaller parts start with a function to get the details of only one student def get_student_detail(num_tests): # get the detail for just 1 student! student_name = input(“Enter Student Name:”) scores = [] … Read more