$string="City" $consonants=array("B","b","C","c","D","d","F","f","G","g","H","h","J","j","K","k","L","l","M","m","N","n", "P","p","Q","q","R","r","S","s","T","t","V","v","W","w","X","x","Y","y","Z","z"); foreach($consonants as $chk2) { if(strpos($string,$chk2)!= false) { $ans2[]=$chk2; } } if(isset($ans2)) { $comment2="Consonants in this string: ".join(" ",$ans2); } else { $comment2="Consonants in this string: None"; } echo "".$comment2."<br/>"; so the error is that the displayed consonants does not include the first letter. what could be wrong?

Member Avatar
Member Avatar
+0 forum 3

Hello, I'm trying to create a character array that would find the absolute value of each value. Ex. Candadite: 111111 / Target: 444444. abs(1-4)(1-4)(1-4)(1-4)(1-4)(1-4) answer: 333333. I have the code running, but I get a consistant answer of 700, even when I move to a new Target set. If anyone could help I'd appreciate it greatly, thanks :) Sorry if this is poorly discribed, I have attatched my project's word document if you need further details. Thanks again #include <iostream> #include <cmath> #include <iomanip> #include <Windows.h> #include <fstream> using namespace std; void readit(); void calcit(char[10][6], char[3][6], char a, char b, …

Member Avatar
Member Avatar
+0 forum 4

I have 3 td's in a portion of a table. Sometimes, the data coming in from the database is less than 3. I need a method that will lay-out the data precisely compared to a rank in the table. Ideal situation: array |-0 |-name => Joe |-rank => 0 |-1 |-name => Dick |-rank => 1 |-2 |-name => Mike |-rank => 2 Yields: <tr> <td data-rank="0"> Joe </td> <td data-rank="1"> Dick </td> <td data-rank="2"> Mike </td> </tr> Problem situation: array |-0 |-name => Dick |-rank => 1 |-1 |-name => Mike |-rank => 2 Yields: <tr> <td data-rank="0"> Dick …

Member Avatar
Member Avatar
+0 forum 7

// Also attached to this question is the assignment sheet. Need help pls. import java.util.*; import java.awt.*; import java.applet.*; public class Lab15st extends Applet { private int numBars; // number of bars to be sorted private int barHeight[]; // array of bar heights private int sortDelay; // delay between comparison iteration public void init() { numBars = 47; sortDelay = 20; // Change to 50 is using the "Selection Sort". barHeight = new int[numBars]; getBarValues(); } public void getBarValues() { Random rand = new Random(3333); for (int k = 0; k < numBars; k++) barHeight[k] = rand.nextInt(591) + 10; // …

Member Avatar
Member Avatar
+0 forum 2

Using swift programming import UIKit var str = "Hello, playground" func ls(array: [Int]) -> (large: Int, small: Int)//function { var lar = array[0] // array of large number var sma = array[0] // array of small number let num = 0 // check odd or even for i in array[1..<array.count] { if i < sma && num % 2 == 0 { sma = i }else if (i > lar) { lar = i } else if num % 2 == 0 { print("this is an even number") } else { print("this is an odd number") } } return (lar, …

Member Avatar
Member Avatar
+0 forum 5

hi, so i am currenty working on a program that needs to ask the user for student name, and test score. it must use parallel arrays and must sort the scores ascending order from lowest to highest, with corresponding student name entered. and it must average the amount of scores and display the average. the program runs fine. but incase i try to use 5 students and scores, it only displays the name AND score for the last entry.(5th entry). it must do it for all entries. here is the code. thank you for your help. it is much appreciated. …

Member Avatar
Member Avatar
+0 forum 1

My application must let a nurse enter information for a number of patients about the patients' number of repetitions for various otherwise ordinary activities. The nurse gets a book in the format to enter the information. Month Date Day Activity Repetitions January 1 Monday brushed_teeth 9 January 1 Monday combed_hair 5 January 1 Monday stepped_up_bottom_step 20 January 1 Monday cleaned_basin 40 January 2 Tuesday brushed_teeth 10 I have no luck getting information stored and looped correctly. #include <iostream> #include <string> using namespace std; struct Patient { char f_name[20]; char l_name[20]; int pat_id; char month[12]; int date; char Day[15]; char activity[50]; …

Member Avatar
Member Avatar
+1 forum 5

The problem asks: Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid, as shown in the following sample run: Enter number of lines: 7 [CODE=text]......1 .....212 ....32123 ...4321234 ..543212345 .65432123456 7654321234567[/CODE] (except the example given shows spaces in between the #s in the pyramid & did NOT include the "." I'm using those for placeholders - this is supposed to look like a perfect pyramid - all of the 1's are in a vertical column, all the 2's are in a vertical column, etc.) I understand how to get the …

Member Avatar
Member Avatar
+0 forum 16

1. FCFS non-preemptive (results provided) 2. SJF non-preemptive 3. MLFQ

Member Avatar
Member Avatar
+0 forum 1

i should to move the biggest value to the last index in the array then to print the array. when i print it i get things like letters, smiles... what is the wrong in the code? .model small .stack 100h .data array db 3,8,5,3 n equ 4 b db dup 6 ('$') .code mov ax,@data mov ds,ax mov cl,0 mov si ,offset array mov di ,offset b mov ax,[si] myloop: cmp cl,n-1 je theend cmp ax,[si+1] jb next cmp ax,[si+1] jae continue next: mov di ,ax add di ,48 jmp my continue: mov di,[si+1] add di,48 jmp my my: inc …

Member Avatar
Member Avatar
+0 forum 1

Hello, i want to make a categories menu which each will have its own sub-categories and that category will have own sub-categories im trying to make with arrays but i'm not really good at it.. im trying right now with bunch if statements but is there any other method of doing this with loops or something eazier ? <form action="" method="POST"> <?php $category = array("Cars" => 1, "Bikes" => 2, "Phones" => 3); $cars_category = array("Honda" => 1, "BMW" => 2, "Mercedes" => 3); $bikes_category = array("Suzuki" => 1, "GSXR" => 2, "Yamaha" => 3); $phones_category = array("Samsung" => 1, …

Member Avatar
Member Avatar
+0 forum 5

It has been a long time since i do C++ programming and I am stuck on this question. I don't remember how to solve this kind of question. haha Part 1: Develop a C++ program which asks the user for the choice of either 3x3 or 4x4 2-dimensional array (use 'if' statement). once the choice is made, create either: > two 3x3 or arrays (A and B) by assigning random numbers, (0 to 100), to the elements of the arrays or > two 4x4 or arrays (C and D) by assigning random numbers, (0 to 100), to the elements of …

Member Avatar
Member Avatar
+0 forum 8

Test Scores #2 Modify the program of Programming Challenge 2 to allow the user to enter name-score pairs using two parralell arrays. For each student taking a test, the user types the student’s name followed by the student’s integer test score. Modify the sorting function so it takes an array holding the student names and an array holding the student test scores. When the sorted list of scores is displayed, each student’s name should be displayed along with his or her score. In stepping through the arrays, use pointers rather than array subscripts. here is the code i have so …

Member Avatar
Member Avatar
-1 forum 10

so the program needs to dynamically allocate an array large enough to hold a user=defined number of test scores. once all scores are entered, the array should be passed to a function that sorts them in ascending order. another function should be called that calculates the average score. the program should display the sorted list of scores and averages with appropriate headings. use pointer notation rather than array notation whenever possible. the problem i am having is making it so that the program doesn't accept negative numbers for test scores. errors - Error C4716 'showAverage': must return a value ConsoleApplication9 …

Member Avatar
Member Avatar
+0 forum 2

<!DOCTYPE html> <html> <body> <script type="text/javascript"> var images = ["strawberry.jpg", "apple.jpg", "cherry.jpg", "orange.jpg", "pear.jpg"]; var length = images.length; var randImg1 = Math.round(Math.random() * (length - 1)); document.write('<img src="' + images[randImg1] + '" >'); var randImg2 = Math.round(Math.random() * (length - 1)); document.write('<img src="' + images[randImg2] + '" >'); var randImg3 = Math.round(Math.random() * (length - 1)); document.write('<img src="' + images[randImg3] + '" >'); if (randImg1 == randImg2 && randImg2 == randImg3 && randImg3 == "strawberry.jpg") { } </script> </body> </html> I want to compare the images of the arrays, if 3 images are strawberry there should be an alert box …

Member Avatar
Member Avatar
+0 forum 4

Hello, I've been working at this code from a couple angles, I've had two people I've known to help me, but even with their help it hasn't worked. The question I have relates to CodeLab: Write the definition of a function named printStarBucks that receives a non-negative integer n and prints a line consisting of N asterisks followed by N dollars signs. So, if the function received 5 it would print: *****$$$$$ and if received 3 it would print ***$$$ The function must not use a loop of any kind (for, while, do-while) to accomplish its job. The function should …

Member Avatar
Member Avatar
+0 forum 2

I am new to coding and im having trouble with arrays in javascript. I want to be able to compare stuff inside an array but only if the three values match up to one of the sets of three values in the array var array = [[1,2,3][4,5,6][3,6,7]] if(array.indexOf([1,2,3]) === 1){ } but when I do this it doesn't work does anyone know why?

Member Avatar
Member Avatar
+0 forum 2

Hello, I'm trying to plot this function with using this values: Rh = 9.8 H0 = 0.063 def Thickness_H(H0, r, Rh): return float(H0)*np.exp(float(r)/float(Rh)) r = np.linspace(0,1, 10) x =Thickness_H(H0, r, Rh) plt.plot(r, x) plt.show() I'm trying to defind r like what i know but this dose not work, I'm getting this error: only length-1 arrays can be converted to Python scalars. may you please help me in this point? Thank you

Member Avatar
Member Avatar
+0 forum 6

Hi Ive got 3 listboxs In Listbox 1 I have a list of names, listbox2 a list of days. These lists have been put into arrays _names & _days. What Im trying to do is join the 2 lists with a delimiter of "-" then display the joined lists in Listbox3. For example Listbox1 Listbox2 Listbox3 Mark Monday Mark-Monday Sue Friday Sue-Friday Dave Tuesday Dave- Tuesday If anyone could help please

Member Avatar
Member Avatar
+0 forum 1

Was hoping someone could help me make changes to this. I don't really want to redo the whole program. Here's what it's asking. Write a program that allows two players to play a game of tic tac toe. Use a two-dimensional char array with three rows and three columns as the game board. Be sure to pass arrays as parameters to functions. The program should be running on loops. Each element of the array should be initialized with an asterisk (*) #include <iostream> using namespace std; char square[10] = {'o','1','2','3','4','5','6','7','8','9'}; int checkwin(); void board(); int main() { int player = …

Member Avatar
Member Avatar
+0 forum 2

We are suppose to create a program that will let us play tic tac toe. We are required to have 4 functions including main and use arrays as parameters to functions. Is my code correct?? Also there's something wrong with my code and can't figure it out. #include<iostream> using namespace std; bool player1Won(); bool player1WonInARow(); bool player1WonInAColumn(); bool player1WonInDia(); bool player2Won(); bool player2WonInARow(); bool player2WonInAColumn(); bool player2WonInDia(); char tic_tac_toe[3][3]={'*','*','*','*','*','*','*','*','*'}; int player1R[5]; int player1C[5]; int player2R[4]; int player2C[4]; int countForP1R=0; int countForP2R=0; int main() { int i=0; for(;i<9;i++) { int x,y,z,k; //display the contents of the board for(int a=0;a<3;a++) { for(int …

Member Avatar
Member Avatar
+0 forum 2

Hi, i am trying to make a program which has to display some data which has been put in by the user over some time. The value the user inputs is a decimal, and should be displayed at the y-axis, while the x-axis should display the time the value was entered. I am saving my data into a txt.file in on long line and i would like for the user to be able to enter the date (name od text file) and the program will display the points. I have tried typing in the values as "12:00:00a3,4b13:00:00a15,2b" in my txt …

Member Avatar
Member Avatar
+0 forum 1

the last array array 3 is not giving me the desired output. i see no logic errors therefore i do not know why i am getting the wrong output. #include<stdio.h> int arr1[5]={55,145,950,25,500}; int arr2[5]={44,58,98,25,62}; int arr3[5],array1,array2,array3; int i=0,j=0,k=0; for(i=0;i<5;i++){ array1=arr1[i]*2; printf("array 1 doubled is %d . \n",array1); //i++; } for(j=0;j<5;j++){ array2=arr2[j]+3; printf("Array 2 increased by 3 is %d \n",array2); //j++; } for(k=0; k<5; k++){ arr3[k]=array1+array2; //printf("the reverse order after operations is %d",arr3[0]); //k++; printf("reverse order is %d\n",arr3[k]); } }

Member Avatar
Member Avatar
+0 forum 2

I need to sort some information from an array. I'm trying to find the minimum value out of two numbers, from a csv file, the first part of the information in the file is the names of people, so instead of 0, I put 1 in int(row[1]) import csv print("1 for Group A\n2 for Group B\n3 for Group C") choice = (input) Group_A = open("class scores A.csv") Group_B = open("class scores B.csv") Group_C = open("class scores C.csv") if choice == 1: print("1 for students' highest score in alphabetical order\n2 for highest score to lowest score\n3 for average score highest to …

Member Avatar
Member Avatar
+0 forum 2

Just started learning MPI and all, need a little help with it though. int main( int argc, char *argv[] ) { int rank, n; MPI_Init( &argc, &argv ); MPI_Comm_size( MPI_COMM_WORLD, &n ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); int a = rank; int b = 0; int C[n], D[n]; for ( int i = 0; i < n; i++ ) { C[i] = rank + i; D[i] = 0; } < MPI CODE > MPI_Finalize( ); return 0; } Suppose n = 4. There are two integer variables a and b and two integer arrays C[n] and D[n]. What is the value …

Member Avatar
Member Avatar
+0 forum 1

Hi All, I have a nest list and i need to get the indivdual columns i can do a foreach and the sublist has the 4 arrays but i cant access each columns e.g. the first column is 1 2 the second column is 5 8 Thanks for the help. List<List<float>> myList = new List<List<float>>(); myList.Add(new List<float> { 1, 2 }); myList.Add(new List<float> { 5, 8 }); myList.Add(new List<float> { 4, 44 }); myList.Add(new List<float> { 9, 7 }); foreach (List<float> sublist in myList) { foreach (float item in sublist) { } }

Member Avatar
Member Avatar
+0 forum 7

Hello, I am working on a C# GUI in Visual Studio to write a program named ChatAWhile that allows a user to enter an area code and the length of time for a call in minutes, and then display the total cost of the call. The area codes given are 262, 414, 608, 715, 815, 920. The Per Minute Rates are 0.07, 0.10, 0.05, 0.16, 0.24, 0.14. here is the code I have thus far.... public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int[] areaCode = new int[] { …

Member Avatar
Member Avatar
+0 forum 2

<?php $array['key1']['key2']=array(); array_push($array,$array['key1']=>'one',$array['key2']=>'two') print_r($array['key1']['key2']); ?> can someone tell me if this is possible for multidimensional arrays? revise the code if I am wrong actually I am creating a site for billboards reservation

Member Avatar
Member Avatar
+0 forum 10

Write a program that reads integers, finds the largest and counts the occurrences. Assume that when the user enters it ends the sequence. Example : 3 5 5 5 0 Largest : 5 Occurrences : 3 I can't use arrays . I know I'm suppose to use loops but I can't just figure it out . I would greatly appreciate any help ! C programming

Member Avatar
Member Avatar
+0 forum 2

hello every body here i got some problem with assign value to arrays, so i want to print multiplication table of the arrays: #include <stdio.h> int main(){ int x=5; int y=5; int i,j; int tab[x][y]; for( i=0; i<x; i=i+1){ tab[i][j]=i; for(j=0; j<y; j=j+1){ tab[i][j]=i; printf("%d", tab[x][y]); } printf("\n"); } return 0; } i'm getting like 00000 00000 00000 00000 00000

Member Avatar
Member Avatar
+0 forum 5

The End.