[Solved] counting the number of zeros [closed]

Here you go: char[] numArray = num.toCharArray(); int counter=0; for(int i=0;i<numArray.length;i++) { if(numArray[i]==’0′) { counter++; } if((i==numArray.length-1&&counter>0)||(counter>0&&numArray[i]!=’0′)) { System.out.println(“Number of Zeroes: “+counter); counter=0; } } Some important points: 1) It’s best to use an array of char values here, instead of operating using a double, because a char array can store many more values- the … 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

[Solved] How to convert a datetime string to UTC?

You should look at the DateTime object and its related functions in the documentation. If your input date is already in a string format, DateTime::createFromFormat() will help you create an epoch-type integer date the object can work with. After that, it’s just getTimezone() and setTimezone(). 0 solved How to convert a datetime string to UTC?

[Solved] c# Cut String at Capital Letter

Dictionary<string, double> Chemicals = new Dictionary<string, double>() { { “H”, 1.00794 }, { “He”, 4.002602 }, { “Li”, 6.941 }, { “Be”, 9.012182 } }; List<string> Properties = new List<string>(); Regex reg = new Regex(“[A-Z]{1}[a-z0-9]*”); Properties = reg.Matches(txtInput.Text).Cast<Match>().Select(m => m.Value).ToList(); double Total = 0; foreach (var Property in Properties) { var result = Regex.Match(Property, @”\d+$”).Value; … Read more

[Solved] Python, def_init_(self): syntax error

Instead of def_init_(self,name,age) You should use def __init__(self,name,age): def means you start a function (definition), and it needs a space to follow. The function __init__ is the constructor. There should always be a colon at the end of a function definition (followed by the body of the function). 0 solved Python, def_init_(self): syntax error

[Solved] How can I make blocks in different colors behind the text in C#?

For a console application, which is what it looks like you’re working with, you are looking for Console.BackgroundColor and Console.ForegroundColor: static void Main() { Console.ForegroundColor = ConsoleColor.Red; Console.Write(“Red”); Console.ForegroundColor = ConsoleColor.Green; Console.Write(“Green”); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(“Blue”); Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.Red; Console.Write(“Red”); Console.BackgroundColor = ConsoleColor.Green; Console.Write(“Green”); Console.BackgroundColor = ConsoleColor.Blue; Console.WriteLine(“Blue”); Console.ResetColor(); Console.Write(“\nPress any key … Read more

[Solved] php pull field with variable+string

Context: OP posted his code within the comments; https://pastebin.com/LM1ecp13 Solution: This line;$fetch = mysqli_fetch_array(mysqli_query($conn,”SELECT id, name, price FROM stock WHERE id=’$cart[wid]'”)); Is the problem. You are selecting id, name, price but you are missing 28price hence why you are getting the undefined index error… Your query should be “SELECT id, name, price, 28price FROM stock … Read more

[Solved] I have a segmentation fault and am unsure about what is wrong with my code

The problem is obvious now you’ve said on which line the code crashes. Consider these lines… char *word = NULL; int i = 0; //index FILE *dictionaryTextFile; dictionaryTextFile = fopen(dictionary, “r”); //scan for word while(fscanf(dictionaryTextFile, “%s”, word) != EOF) You’ve got 2 problems there. Firstly, you don’t check that the call to fopen worked. You … Read more

[Solved] HTML Change login label to username after login

You need a simple condition if($_SESSION[‘logged_in’]){ echo $_SESSION[‘username’]; }else{ echo ‘Please login’; } When your login condition gets true set some session data or cookie data then use a condition to display content based on session or cookie 4 solved HTML Change login label to username after login

[Solved] in this code i want add popup box link but showing one error inside .. help me [closed]

Try it like this: $string = substr($string, 0, 500); $string = substr($string, 0, strrpos($string, ‘ ‘)); $string .= ‘… <a href=”#” onclick=”showAjaxModal(\” . base_url() . ‘index.php?modal/popup/readmore/’ . $row[‘categories_id’] . ‘\’)”>… Read More</a>’; You are missing the single quotes which should wrap the url inside the showAjaxModal function. 1 solved in this code i want add … Read more