Hello! I have to print patterns using '*' and I am at a loss how to get these patterns printed! I figured out the first one, * ** *** **** ***** ****** ******* ******** ********* ********** and now i have to do it upside down: ********** ********* ******** ******* ****** ***** **** *** ** * and backwards: ********** _********* __******** ___******* ____****** _____***** ______**** _______*** ________** _________* and _________* ________** _______*** ______**** _____***** ____****** ___******* __******** _********* ********** this is the code i have for the first one: [CODE] for (int i =0; i < 10; i++) { for (int …

Member Avatar
Member Avatar
+0 forum 16

Hello everybody, I was asked by an interviewer the following question. but I was not able to answer. Please get back to me if you know the answer. thank you in advance. Que: What is the exact difference between the "for" loop and "while" loop in C language ?

Member Avatar
Member Avatar
+0 forum 25

I am making a program that does synthetic division, except for it is not showing the quotient only the remainder. I have checked my for loops so many times, and I can't understant what is happening here is my code: import java.util.*; import java.lang.*; class synthetic { static Scanner userInput = new Scanner(System.in); public static void main(String[] args) { System.out.print("What is the highest degree of the polynomial function: "); int degree = userInput.nextInt(); synthetic(degree); } public static void synthetic(int degree) { int[] coefficients = new int[degree+1]; for(int i=0; i<=degree; i++) { if(i == 0) { System.out.print("Leading coefficient: "); coefficients[i] = …

Member Avatar
+0 forum 0

Although there are many similar questions and answers here and i've tried my best to make it work but no luck. This is my code: $content = "Blah...blah...[image=1], blah...blah...blah...[image=2], blah...blah...blah...[image=1], no more..."; function get_image($content) { $stripper = $content; preg_match_all("/\[image=(.+?)\]/smi",$stripper, $search); $total = count($search[0]); for($i=0; $i < $total; $i++) { $image_id = $search[1][$i]; if($image_id > 0) { $image = 'This is an image: <img src="images/'.$image_id.'.jpg" />'; } $stripper = str_replace($search[0][$i], $image, $stripper); } return $stripper; } I want to remove the duplicate "[image=1]" and return: Blah...blah...This is an image: <image>, blah...blah...blah...This is an image: <image>, blah...blah...blah..., no more... or Blah...blah..., blah...blah...blah...This …

Member Avatar
Member Avatar
+0 forum 2

i have some code i am working on andit keeps throwing an expression expected error. this code is designed to cheeck a RichTextBox form and highlight text, specified by a dictionary. Dim location As UInteger = 0 Dim dict As Dictionary(Of String, ULong) = getWords(rText1) Dim wcount As Integer = 0 For i As Long = 0 To dict.Count For j As Integer = 0 To args.Length If dict.ContainsKey(args(j)) Then For Each args(j) In dict.Keys Dim count As ULong = dict.Values.ElementAt(wcount) Dim colorSpace = count - args(j).Length rText1.Select(colorSpace, count) rText1.SelectionColor = Color.DarkBlue Next() 'error here End If Next For j …

Member Avatar
Member Avatar
+0 forum 2

Hi Everyone. It's been a while since I was on here last, but ran into an interesting problem with a nested for loop that I cannot solve. Hoping someone here will know the answer. I placed breakpoints in my code at the For x=1 to 10 line and after to see where run-time is ending. For some reason VBA is not executing the loop at all. Does anyone know what I'm missing? Thanks in advance. sub help() Dim x As Integer Dim y As Integer Dim lastcell As Long Dim ws As Worksheet Dim wscurr As Worksheet Dim gcounter As …

Member Avatar
Member Avatar
+0 forum 6

I wrote this code for an assignment that asked to create a program that calculates and displays the average of any amount of real numbers. The program is supposed to ask the user how many numbers they want to enter and then use a loop to ask the user to enter a number, keeping track of the sum as they are entered, and then calculating the average. I have it somewhat ok, until the end where it's supposed to give the average. I tried a couple things but none of them gave me the right answer. I don't think I'm …

Member Avatar
Member Avatar
+0 forum 8

Hi hope someone can can help im having a problem with how ripple is dealing with for loops when emulating an android app using html5 css jquery and jqtouch simple loop [CODE] var len = 1; for (i = 0; i <len; i++){ alert('foo'); } [/CODE] run it through chrome all is well as expected; run it through ripple (phonegap); I get 6 alerts; found some stuff saying it may be a bug in ripple and to change the device but still got the problem!!!!! has anyone come across this and know a work around. cheers in advance Niall

Member Avatar
Member Avatar
+0 forum 1

Hi! I'm making a chess program, that need to move pieces on the chess board, get an input,check if the move is valid and print the output. The compiler finds some errors that i don't understand...I need some help with the pieces functions. Plz help me fix them!!! my attempts : //Chess project// #include <cstdlib> #include <iostream> using namespace std; #include<stdio.h> #include<string.h> #include<stdlib.h> // all figures are represented as a constant integers// //constants // all columns are presented as an integers # int board[8][8];//chess board is presented as a 2D array of int #define empty 0 #define pawn 1 #define …

Member Avatar
Member Avatar
+0 forum 35

Hi guys, Working on a table. Each of the entries has an A or B in the 'tip' field. I order them by 'tip' how can i add a special row for the first entry of the A or B series from the query? I know it's not an IF Example: ENTRY TIME A 231 name1 3:23 A 123 name2 4:23 A 123 name3 5:23 A 123 name4 6:23 A 123 name5 7:23 A 123 name6 8:23 A 123 name7 9:23 EXIT TIME B 124 name8 10:23 B 125 name9 11:23 B 126 name10 12:23 B 127 name11 13:23 B …

Member Avatar
Member Avatar
+0 forum 1

Okay so this is another question printing patterns but this time using input! I have to prompt the user and read an odd number from the input. I can only use System.out.print('*'); System.out.print(' '); and System.out.println(); I need to maximize my use of repetition and minimize the number of output statements. for examples: n = 11 _____* ____*** ___***** __******* _********* *********** _********* __******* ___***** ____*** _____* n = 7 ___* __*** _***** ******* _***** __*** ___* where _ are spaces! etc. I haven't even begun this code as i have no idea how to start it! Please help!

Member Avatar
Member Avatar
+0 forum 6

This program determines the grade average, raised grade average, of individual students and all students. The program takes scanner input. In the scanner, the number of students, the number of grades for each student, and the grades of each student are entered. Ultimately, I need to print out each student's grade average, grade average when the lowest grade is dropped, total grade average of the "class," and raised grade average of the class. I have been spending an inordinate amount of time on this. Currently, my questions are: [COLOR="red"] How do I use nested for loops to take all the …

Member Avatar
Member Avatar
+0 forum 3

So basically I'm stuck at the do-while statement. Should I use a do while? or a for loop? This program is supposed to test my ability to use loops. [CODE]/*Create an application that reads an integer value and prints the sum of all even integers between 2 * and the input value, inclusive. Print an error message if the input value is less than 2. */ import java.util.Random; public class Project3 { public static void main (String[]args) { int critical,test,count = 2; Random rand = new Random (); critical = rand.nextInt(21); test = critical % 2; System.out.println("The random number is: …

Member Avatar
Member Avatar
+0 forum 2

Hello every body I'm trying to iterate through a list for a certian number of times using a for loop. below is the current code I've written, but this will iterate through the list until it ends. [CODE]list<FileInfo*>::iterator p = currentlist.begin(); while(p != currentlist.end()) { cout << (*p)->remainingtime << " "; (*p)->remainingtime--; cout << (*p)->remainingtime << " "; if ((*p)->remainingtime==0){ p = currentlist.erase(p); } } cout << "\n\n";[/CODE]

Member Avatar
Member Avatar
+0 forum 2

Hey so Im a beginner, and I need some help. My professor gave us this code: [CODE] def average(list): total = 0.0 for number in list: total += number return total / len(list) [/CODE] Then, he asked us to rewrite that program so that it uses a while loop instead. I have no idea :/ Everything I've tried so far doesn't give me the right answer. If you could please help me, I'd be forever grateful

Member Avatar
Member Avatar
+0 forum 1

Hey so Im a beginner, and I need some help. My professor gave us this code: def average(list): total = 0.0 for number in list: total += number return total / len(list) Then, he asked us to rewrite that program so that it uses a while loop instead. So far I tried and got this... def average(list): total = 0.0 i = 0 while (I < len(list)): total += list[i] i += 1 return i When I tried to run that, I kept getting the wrong answer for any list I tried. :/ If you could please help me, i'd …

Member Avatar
Member Avatar
+0 forum 3

Hi trying to recover an RSA encrypted 5 character word using a forward search dictionary attack in Python but having difficulty. The word was encrypted in 2 24 bit blocks (3648141 5604637) padding last block with a space e = 5 n = 21508387 table = {} for ptext in range(65,90): ctext = pow(ptext,e,n) table[ctext] = ptext print table I know I need to do the above so that it decrypts all combinations 3 characters long AAA AAB... ZZA ZZB, etc by making the for loop gor around 3 times before applying the pow but what I have only decrypts …

Member Avatar
+0 forum 0

Hi everyone, well I have trying to do an elevator simulator, wich have to includo the panel with the floor, available floors, and a button panel with available floors and button up, down, but I dont understand is how to use the timers for up and down, because I vague idea to select the floors is to usea a for or select case but I dont know wich one is the most appropiate in this case. Wha tI have so far is: [CODE] Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer2.Enabled = False If lbl1.Text …

Member Avatar
Member Avatar
+0 forum 9

Hi the aim of my program is to allow a user to enter the size of an array and then allows the user to enter the values into an array. The bit im having a problem with is I want to count how many odd and even numbers there are in the array. I then want to print out the odd and even numbers. I've had a go but its not working-I was hoping that someone could look at the code and see where Im going wrong or if you've got another way to do it please reply. [CODE] # …

Member Avatar
Member Avatar
+0 forum 28

Hello guys, I'm trying to make it so that the user can opt to change student's course code or credit points (they can choose to change neither, either or both) in case 5 of my main switch statement. The problem is, the loop doesn't end after you choose to do anything! The search for a student works and the prompt works, but after that, it's just a neverending loop! Any direction or advice would be awesome! Here's my whole code (I've tried making functions for things as well, but I'm no good at it!): [CODE]#include <iostream> #include <iomanip> #include <string> …

Member Avatar
Member Avatar
+0 forum 8

Oh. btw admin! sorry about my earlier thread. i promise not to do something like that ever again :) anyway. i was having trouble with my project and its about Multiplication with loops. i started with a few codes and im really frustrated with what im doing now. please let mee fix this stuff i dont really know about looping statements @---@. thanks heres tha code. [CODE]import java.io.*; public class Multiplied{ public static void main(String [] args){ BufferedReader buffer= new BufferedReader(new InputStreamReader(System.in)); int i; int j; try{ {System.out.println("Enter a number: "); i = integer.parseInt(num.readLine()); } for (int i=1; i<=maxNo; ++i) …

Member Avatar
Member Avatar
+0 forum 6

Hello all, I have a form with 24 textboxes incremented by a letter. example: txtDimVala1.text, txtDimValb1.text, txtDimValc1.text, etc. I created a code to check each textbox, but there must me a more efficient way to loop it. I have tried a few loops but I cant get them to work looping through the different textbox values. Thanks for any help in advance. below is the code i already have [CODE] Private Sub CheckDims() If (IsNumeric(txtDimVala1.Text)) Then Dim num As Decimal = txtDimVala1.Text Dim num2 As Decimal = txtDimL1.Text Dim num3 As Decimal = txtDimU1.Text If num < num2 Or num …

Member Avatar
Member Avatar
+0 forum 9

I have no idea what went wrong with my most recent code, but I suspect it has something to do with the following so I'll start there. Did I do something wrong in this? [CODE]cards=['1','1','1','1','2','2','2','2','3','3','3','3','4','4','4','4','5','5','5','5','6','6','6','6','7','7','7','7','8','8','8','8','9','9','9','9','A','A','A','A','K','K','K','K','J','J','J','J','Q','Q','Q','Q'] import random random.shuffle(cards) h1=[] for card in cards[1:7]: h1.append(card) cards.remove(card)[/CODE]

Member Avatar
Member Avatar
+0 forum 15

Hi! I'm a newbie in this forum. I'm a novice C++ programmer and we are tasked to create a program with the following requirements: [QUOTE]Given the sequence of numbers [I][B]n a1 a2 a3 . . . an[/B][/I] a simple histogram should be printed to the computer screen. The number [B][I]n[/I][/B] is the number of height values while the numbers [I][B]a1, a2, . . . , an[/B][/I] are the [B][I]n[/I][/B] height values. The histogram should be printed vertically using the character ’*’. For example, the sequence 4 2 3 1 5 should result to the output: * * * * * …

Member Avatar
Member Avatar
+0 forum 1

I am making a page which pulls from the user's browser their preferred language, via the Request.UserLanguages....which returns a two letter code (ex. "en") or detailed code (ex. "en-GB"). I basically get the string of user languages (they are in order of preference) and store them in a string array. Then I use a loop to check if the language code in the first position of the string array is any of the codes for a certain language (another string array hard coded in). Is there a better way to do this? I'm noticing increased load time and am worried …

Member Avatar
Member Avatar
+0 forum 2

hi all, I have this minor problem which is making me go cranky at the mo.. Can't think straight, need some insights to what I can do... Below is the code which I am working on which takes the test sample values stored in my test 2D array subtracts the centroids stored in centroid 2D array and stores it in temp1 1D array where temp1 goes from 1 to 4. The values in temp1 array are now squared, summed up and storee inside temp1 array again and does this for 2308 times (CLEN). I want to know how I can …

Member Avatar
Member Avatar
+0 forum 2

could someone plz help.. i'm stuck in one part where u have to access the array form the main class(random) ive juss posted the two classes i have doubt in.. the question goes soemthin like this: Q:Make a java class file for function that can do addition, then make a new java class file again for random numbers(which will allow your program to make random equations for addition).Make a new java class file for menu where the user decides what grade(from 1 to 6) they study in and if u type something wrong like a character or anything, the program …

Member Avatar
Member Avatar
+0 forum 5

I have been trying for about 6 hours to get this program to work. It's a C++ program for for loops. I am trying to go through a book, but I don't have source code for how this should be. I need to make a program that looks like this below: + = are to show open space *++++++++++**********+**********++++++++++* **+++++++++*********+++*********+++++++++** ***++++++++********+++++********++++++++*** ****+++++++*******+++++++*******+++++++**** *****++++++******+++++++++******++++++***** ******+++++*****+++++++++++*****+++++****** *******++++****+++++++++++++****++++******* ********+++***+++++++++++++++***+++******** *********++**+++++++++++++++++**++********* **********+*+++++++++++++++++++*+********** So far I got the code below, but have no clue what to do from here. Any help would be greatly appreciated. Thank You!!!!! [CODE]#include <iostream> #include <conio.h> using namespace std; int …

Member Avatar
Member Avatar
+0 forum 3

So here is my problem, my friend and I are writing a simple project for a electrical eng. teacher, who really doesn't know too much about programming c++. We were assigned to make a successive approximation ADC [URL="http://en.wikipedia.org/wiki/Successive_approximation_ADC"]Look here[/URL] in any coding language possible. I would have liked to make it in Java for Linux, but the professor insisted we make it for c++ and specifically for windows. (derp) I have limited c++ knowledge, but I tried my best and wrote a successful decimal to binary conversion loop. However, said friends code refuses to work for any bit value above …

Member Avatar
Member Avatar
+0 forum 9

I'm working through an exercise to create a short program to calculate E using the series 1 + 1/1! +1/2! + 1/3! + ... The summation has to stop when value of a term is less than a value entered by the user. The code I have to produce the basic factorial works fine when tested seperately, but when I run this code, it comes up with some very strange results for the factorials (1!, 2!, 3!, 4! etc come up as 0.5, 0.5, 1.5, 18 etc, instead of 1, 2, 6, 24 etc). This therefore goes on to give …

Member Avatar
Member Avatar
+0 forum 5

The End.