## [Solved] How to increment an IP address in a loop? [C] [closed]

A naive implementation (no inet_pton) would user 4 numbers and print them into a char array #include <stdio.h> int inc_ip(int * val) { if (*val == 255) { (*val) = 0; return 1; } else { (*val)++; return 0; } } int main() { int ip[4] = {0}; char buf[16] = {0}; while (ip[3] < … Read more

## [Solved] One line recursive loop in python

The list comprehension at the heart of this function is building up an implicit list that ultimately gets returned. We can unwind the function, remove the comprehension, and use an explicit list: def combine(n, k): “”” Given two integers n and k, return all possible combinations of k numbers out of 1 … n. “”” … Read more

## [Solved] JAVA ISBN-10 Number: Find 10th digit [closed]

nextInt() consumes the entire token 013601267, not just a single digit, which was not your plan. A much easier approach could be to consume it as a single string and then iterate over the characters: String num = s.next(); int sum = 0; for (int i = 1; i <= num.length(); ++i) { sum += … Read more

## [Solved] Syntax error in a for loop in python [closed]

If you want to use a range, then you need to call the function: for j in range(row): range is not part of the Python syntax, it is just another built-in object type. 1 solved Syntax error in a for loop in python [closed]

## [Solved] for loop: make increment and accessing in one loop

doing for( int i =0; i++<10; a[i-1]=i ) { printf(“%i:%i\n”, i-1, a[i-1]); } you set the entries after you print them because a[i-1]=i is executed after the body of the for, so you print non initialized array entries your code is also ‘complicated’ because you increase i too earlier in the test part of for, … Read more

## [Solved] While loop inside of for loop [closed]

There’s nothing wrong with having a while loop inside a for loop. To demonstrate: i = 0 kebab = [“chicken”,”garlic”,”cheese”,”tomato”,”lettuce”,”chilli”] print “Kebabs are so good, this is what mine has:” excitement_over_kebab = 1 for ingredients in kebab: while excitement_over_kebab == 1: print kebab[i] i+=1 if i == 6: print “Enough talk, my lunch break is … Read more

## [Solved] How for loop works?

Here is an explanation of everything happening in the for loop // keeps the for loop going while x is less than numbers.length which is the length of nmbers // sets x to 0 initialy | increases x by +1 each time it restarts to begin the loop // V V V for (var x … Read more

## [Solved] Print the following pattern in Python language

This code works perfectly: n=int(raw_input(‘n=’)) for i in range(1,n+1): for j in range(1,n+1): if j==1 or j==n or j==i: print’#’, else: print’ ‘, print solved Print the following pattern in Python language

## [Solved] on Python, I want to do this : remove or map list or for loop two lists in same time

Mlist = [‘alex’,’peter’,’alan’,’david’] Flist = [‘mary’,’kitty’,’susan’,’amy’] idx=Mlist.index(‘peter’) Mlist.remove(Mlist[idx]) Flist.remove(Flist[idx]) print (Mlist) print (Flist) solved on Python, I want to do this : remove or map list or for loop two lists in same time

## [Solved] How can I make a specific Java output with *? [closed]

This seems a homework assignment, and it’s nice to you to achieve this little goals to correct programming learning. As we’re not here to make your homework, here you have few steps to guide you through: Define a Scanner to ask user’s input Use Scanner to put user’s input into a variable Use this variable … Read more