Questions tagged [increment]
DO NOT USE THIS TAG ALONE. Use with a language tag like [javascript] or [python]. Adding one to the value of a variable, generally with the use of an increment operator.
3,495
questions
-1
votes
0
answers
33
views
What is the output of this C program that uses increment and decrement operators? [duplicate]
Could you please explain the output of this C program and where I went wrong:
#include <stdio.h>
int main() {
int a = 2, b = 3;
b = a++ + b--;
printf("\na=%d, b=%d", a, b);
...
0
votes
1
answer
32
views
How can I increment sire codes beyond 'Z' in Laravel?
How to increment the sire code like Excel column values (A, B, C, ..., Z, AA, AB, AC, ...)?
Description:
I have a code snippet where I need to increment the sire code in a specific pattern similar to ...
0
votes
2
answers
61
views
How can I increase the value stored in count by one every time it is a multiple of 2? [closed]
How can I increase the value stored in count by one every time it is a multiple of 2
I have a function that returns the value of i, it is initialized to 0 and it is auto-incrementing, that is, when i ...
0
votes
1
answer
37
views
How to increment a value in column when a chose value id in another column
I have this kind if table :
Value:
U
R
T
'*
D
E
'*
M
R
Z
.*
...
I want to create a second column with value incremented when a "*" is the first column :
Value,newcolumn:
U 1
R 1
T 1
'* 1
D 2
...
1
vote
2
answers
52
views
Does working of increment and decrement operator change if used with logical operators [duplicate]
#include <stdio.h>
int main()
{
int a = -10, b = 3, c = 0, d;
d = a++ || ++b && c++;
printf("%d, %d, %d, %d, ", a, b, c, d);
a = -10, b = 3, c = 0;
d = c++ &&...
0
votes
1
answer
49
views
How to increment variable every two cycle if condition exist in a while loop
I have an array from database into a loop "while" cycle and i need every two cycle if two row have same value increment +1 a variable.
every 2 cycles if there is a winner and immediately ...
0
votes
0
answers
27
views
Writing loop in SASS that increments various variables [duplicate]
I have a base class which I need to increment by 100:
.myclass.link-1 + a {
color: red;
}
So when my class has a link number of 1 (.link-1), it needs to target the first adjacent sibling with an &...
-1
votes
2
answers
46
views
How do I increment tuples in an array in python
I'm trying to create this map where you can move North, South, East, and West for a Python text adventure project. The problem is I can't seem to figure out how to change the coordinates or if I'm ...
-2
votes
3
answers
53
views
Rock paper scissor game in Node JS environment
The game is going to play against the computer, so begin with a function called getComputerChoice that will randomly return either ‘Rock’, ‘Paper’ or ‘Scissors’. We’ll use this function in the game to ...
0
votes
1
answer
64
views
Is i++ in any immaginable scenario faster than ++i?
(I'm assuming the old value of i is not needed, so i++ and ++i should at most affect performance.)
The thing is, I've seen a counter incremented like this in code
i++;
and it left me wondering: ...
0
votes
2
answers
30
views
MariaDB INSERT - How can I increment a counter on duplicates?
I am writing event-log data to a MariaDB database. The primary key includes the time to one-second granularity. I sometimes get bursts of identical input data. This violates the key and is ...
-3
votes
2
answers
81
views
CS50 "C" loop incrementation with "if" condition produce wrong outcome
I'm trying to learn coding from beginning by CS50. Currently i'm writing program called "runoff". Here's the description in short:
Program is an algorithm for determining the winner of an ...
0
votes
1
answer
21
views
Button inside array mapping in React
I have created two buttons inside a mapped array elements with the function to decrement and increment a value, but clicking on one button increments all the other button values
code below
const [cart,...
0
votes
1
answer
35
views
Incrementing a global variable inside of a function - Python
p1_wins = 0
p2_wins = 0
def my_function(p1_wins, p2_wins, p1_answer, p2_answer)
if p1_answer > p2_answer:
print('Player 1 Won the Round')
p1_wins += 1
elif p1_answer < ...
-2
votes
3
answers
49
views
How to Decrement an Incremented counter as long as it stays zero or above and returns 0 instead of "undefined"?
incrementing and decrementing works as expected but I need the number to display '0' instead of 'undefined' if it becomes zero or less.
Currently, When it becomes zero, it goes one step more and ...
0
votes
1
answer
32
views
Java arithmetic increment operator [duplicate]
int a = 6;
int b = a + a++;
answer is 12
int a = 6;
int c = a++ + a;
answer is 13
why are the answers for b and c are different ?
since postfix has higher a precedence value, then the answer ...
1
vote
1
answer
56
views
How do I generate an entity and code in an 'in-game' time that changes attributes such as the age of an entity?
I want to make a game that logs multiple things.
Character (Displayed on html the list of its attributes, generated upon the push of a button, such as a "Generate Person" button. (vvv))
...
1
vote
1
answer
41
views
Increment a counter by a user specified amount each time
I'm using the following code and am trying to work out how to increment a number by say 10 or 100 (a user-specified amount) until it reaches the countTo value.
The code below is working fine but ...
0
votes
1
answer
54
views
Is it possible to auto-increment each new excel sheet with a new order number?
I am building a receipt sheet in excel:
As you can see I have order number and customer number. I want to auto-increment these in a way that's most convenient for one that's gonna use the sheet. These ...
0
votes
2
answers
41
views
Python increment operator [duplicate]
So, i'm trying to increment a variable by 0.01
On the 6th iteration, the total seems to be getting incremented by more than 0.01
Can anybody please explain what's going on?
I'm trying to loop through ...
0
votes
0
answers
13
views
When _gemCount is 1 and i collide with another gem it doesnt go to 2 but when i collide with a third gem it goes to two
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace GamePrototype
{
public class GemTriggers : MonoBehaviour
{
[...
0
votes
1
answer
73
views
How can I increment a pandas dataframe index?
If I have a variable set to a value from a pandas dataframe, how can I increment the index so that the value of my variable will change to the next incremented index?
numbers.csv
Ex.
df = pd.read_csv('...
0
votes
0
answers
15
views
C++ can’t figure out loop in random number gen
I can’t seem to figure out this random number stuff in my class and everyone on here seems to be extremely helpful
This is what I have done for the segment and the instructions
// Item #5 - Write a ...
0
votes
1
answer
100
views
Arena simulation - how to make entities leave the system after going through the same process twice?
I would like to create a simulation in Arena with a special condition.
The scenarios is as follows:
Entities arrive in the system, go through the process A and then arrive at a decision point where 80%...
0
votes
1
answer
27
views
Looping through an array of arrays and creating an array from incremented values
Hello I have a foreach question. I am trying to loop through an array of arrays, and as each array goes through, the values
$alreadyhere = 0;
$nothere = 0;
$addedNewMember = 0;
$...
-1
votes
2
answers
48
views
I'm building a rock, paper, scissors game - cannot make a variable increment after if statement is true
I am making rock, paper, scissors game. I can't make 'yourScore' and 'computerScore' increment after true if statements. Everything else works. I've been trying different variations for the last 2 ...
3
votes
2
answers
68
views
Fill gaps between 1's in Pandas dataframe column with increment values that reset when next 1 is reached
Apparently this is a more complicated problem than I thought.
All I want to do is fill the zeros with ++1 increments until the next 1
My dataset is 1m+ rows, so I'm trying to vectorize this operation ...
1
vote
1
answer
38
views
Pre Increment in the IF statement has no effect. Why?
The pre-increment in the IF statement has no effect. Can anyone please explain?
<?php
$x = 10;
if($x < ++$x)
{
echo "Hello World";
}
?>
0
votes
0
answers
13
views
Group numbers together
I am trying to automatically group a variable columns in groups of 3. What I am trying to achieve is the following:
Current table:
Month Value
1 50
2 40
3 35
4 56
5 25
...
0
votes
1
answer
61
views
VBA Excel Incremented worksheet name Add After Statement using a stored variable sheet name
How to add a worksheet in excel with VBA after a specific sheetname held by variable?
I tried:
Set sh = wb.Worksheets.Add(After:=wb.Sheets(wsPattern & CStr(n)))
The previous incremented sheetname ...
0
votes
0
answers
39
views
im trying to increment the score by 10 only when the end of myCar passes the end of enemyCar
Im trying to increment the score by 10 only when the end of myCar passes the end of enemyCar. The score should be incremented by 10 at each passing and each time i reload it I can't seem to start with ...
0
votes
1
answer
57
views
how to print last incremented value in set_fact ansible? [closed]
Here is my ansible playbook. I'm inputting a file to my playbook and if it finds keywords like "open" or "allowed" in the file, I'm asking it to increment the variable ...
1
vote
0
answers
22
views
Incrementing a number in a <td> with JQuery works only 1 up
Clicking on a + sign i want the number in the nearby <td> to go 1 number up.
This works/it seems to work, but only from 0 to 1 and not higher.
This is the code i'm using:
$('[id^=plus]').click(...
0
votes
2
answers
55
views
add 1 to a single element in an array
There is an array containing numbers and I want to increment only one number in the array
let array = [1, 3, 5]
// just add 1 in the second element of the array and return that array
// array = [1, 4, ...
1
vote
1
answer
52
views
How can I add to a multiplier inside an inner for loop?
I have an array of objects, and each object has a nested object with a key that I would like to increment each iteration with a higher multiplier.
I have an object:
object = {
id: 1,
innerArr:...
0
votes
1
answer
33
views
EXcel increment in formula
I am working on excel sheet, but i am having challenge with incrementing; I want to move from a1-a2 to a3 etc. but it's moving from a1 to b1
shows the exact result i am looking for without manually ...
0
votes
0
answers
38
views
How To Optimize Game Increment Function In Rock, Paper, and Scissors Javascript Game To Not Label A Winner In a Tie Game Situation?
I am a newbie programmer, making a rock, paper, scissors game. I have the game "working", however, I am unable to isolate why some tie games actually credit either the player or computer as ...
0
votes
0
answers
13
views
How to up revision the id by getting the max value from last digit
I have EBT2301001 Rev.2 from database.
I want to increment the last digit from 2 to 3. How can I done for it by using C#?
Increment EBT2301001 Rev.2 to EBT2301001 Rev.3
Retrieve the EBT2301001 Rev.2 ...
0
votes
0
answers
21
views
Increment int value with more than 1 after evaluation instead of before
Is there any nice way to increment an int variable with more than 1 after evaluation instead of before evaluation?
The ++ operator can be used to increment either before or after evaluation, but is ...
2
votes
2
answers
152
views
Increment Counter in CSS for a list with :before
I tried to increment a counter for a list with CSS. However, even though I can see the list numbers, those don't increment.
I used :before and the CSS property counter. Here's the code:
....
0
votes
1
answer
37
views
Increment & Decrement not working as intended in Javascript
The unexpected behavior I'm getting is when clicking the donate or undonate button. It takes 2 clicks initially for the tracker to display the incremented or decremented number despite the color ...
-1
votes
5
answers
40
views
Python increment in a list
i have this code below :
list = [254,255,256]
# Getting length of list using len() function
length = len(list)
i = 0
counter = 0
while i < length:
url = "https://test/api/v1/implantacao/...
3
votes
2
answers
116
views
Snowflake SQL : How do I insert and build in a array : all dates between a specific start and a specific end date
Given two dates, activation_date and termination_date per customer
Imagine there is 20 days between the activation_date and the termination_date.
How do I get by customer an array which start with the ...
0
votes
2
answers
54
views
How can I increment a variable inside a function without using global variable please?
I need a way to print a timer every second and execute an action every 10 seconds.
The output of the program should be like below.
Timer is 1
Timer is 2
Timer is 3
Timer is 4
Timer is 5
Timer is 6
...
0
votes
2
answers
75
views
Add Unique Identifier column in SQL View
I'm using SQL in Databricks and I have a view of a table which looks like this:
COL_A | COL_B |
-----------------------
AA | AB |
AA | AC |
AA | AD ...
0
votes
1
answer
74
views
Vue - Get id of particular clicked post
Basically my goal is getting the number of click for each post.
Until now, i only just successfully get the number per clicks on console :
But i need to know which post was clicked, For distinct that,...
3
votes
3
answers
47
views
How do I create a function which will return a dictionary with two functions in that will increment/decrement a count in Python?
I've been tasked with creating a function "make_counter" which takes a number as its only argument. It should return a dictionary containing two functions that can be invoked to increment ...
0
votes
2
answers
61
views
Windows batch: Check for highest folder prefix and create new project folder
In the past I found plenty of solutions just by searching StackOverflow's discussion history. However, I am stuck with this batch file, (as Windows scripting is not something I generally do).
The ...
-1
votes
1
answer
36
views
Java Unexped Outputs From Pre-Increment
I am trying to figure out why the following code gives two different results
I tried the followingL
int x = 4, y = 4;
System.out.println(x + --x);
System.out.println(--y + y);
And It outputs 7 6. ...
-2
votes
1
answer
59
views
Why does it show 0 on click and not 1? (javascript html)
I have built a small website, where I have a html button and an html input text field.
I wanted to create a js function which manipulates the value of the input field by incrementing it by 1.
my html :...