Questions tagged [statements]

In computer programming a statement is the smallest standalone element of an imperative programming language. A program written in such a language is formed by a sequence of one or more statements. A statement will have internal components (e.g., expressions).

A statement is the smallest standalone element of an imperative programming language. A program written in such a language is formed by a sequence of one or more statements. A statement will have internal components (e.g., expressions).

Resources

471 questions
2
votes
5 answers

using multiple return statements in a c++ function

I was wondering if it might be sort of advantageous for a c++ compiler if there's only one return statement in a function. one of my ex-bosses once told me so but I don't get the point if there would be any difference between declaring a return…
tai
  • 477
  • 1
  • 5
  • 16
2
votes
7 answers

Javascript reads only first elements(from array) in nested for loops

I have the following issue. There's a problem I have to solve. Fruit or Vegetable Write a JS function to print "fruit" , "vegetable" or "unknown" depending on the input string. Fruits are: banana, apple, kiwi, cherry, lemon, grapes,…
Nasco.Chachev
  • 666
  • 6
  • 22
2
votes
4 answers

My first IF doesn't work, but my else if and else parts work javascript

I am having an issue. My first IF statement doesn't work, but my ELSE IF and my ELSE statements do work, and I can't figure out why. (function(){ var dateHeure = new Date().getHours(); var dateHeure = dateHeure.toString(); var $p =…
guiguivey
  • 21
  • 4
2
votes
3 answers

Multiple conditions vs. multiple statements

Is there a difference in terms of performance between these code examples? if (this.game.physics.arcade.overlap(this.player, this.barels) && (this.game.time.now - this.srdicka.timecheck > this.srdicka.frequency) || (this.player.position.y >…
2
votes
2 answers

IF / ELSE statements in sql

My SQL statement: select * from categories where onair = 1 and City LIKE 's%'; First part: select * from categories where onair = 1 second part: and city like 's%'; If city column is not null, then I want to execute second part too.…
Arlong
  • 312
  • 3
  • 14
2
votes
3 answers

PHP: how to use a variable from one if statement in another

Separately the forms are ok, but combined.... not really. The struggle is that i can't access the variable $name from the first if statement in the second. Error : Undefined variable: name html:
2
votes
3 answers

What's the major difference between if statements and unless statements?

I am new to programming and I don't understand what the difference is. I am coding in Ruby.
2
votes
1 answer

Python user selected function

I am trying to make a program with functions that display five different flags. The user selects these flags from a list. My largest problem is that every flag prints, without regard to the flag I chose. I have tried to keep each part of the code…
Michael
  • 33
  • 6
2
votes
3 answers

Multiple if statements in C

Suppose I want to calculate net_salary of an employee after taking into account the number of years he's worked and the number of kids he has. I don't want to use nested if statements since that will complicate the number of checks I need to…
idnow
  • 27
  • 2
2
votes
4 answers

Is class member declaration not a statement?

I thought the class member declarations are declaration statements. But when I look at the declaration statements from the spec. I found this: declaration-statement: local-variable-declaration; local-constant-declaration; Obviously a…
Selman Genç
  • 100,147
  • 13
  • 119
  • 184
2
votes
6 answers

Can I have two initializing statements in a "for" loop?

In C++, a for loop normally takes three statements, in the form: for (init; condition; step) { Loop statements } Can I place two or more statements in the place of init? Let's say I want to define two starting variables, a and b. To do this, I…
Johan
  • 343
  • 1
  • 4
  • 13
2
votes
1 answer

MySQLi multiple prepared statements using previous fetched $variable

$stmt = $mysqli->prepare("SELECT id,name,master,level,exp FROM player.guild ORDER BY exp DESC"); $stmt->execute(); $stmt->bind_result($id, $name, $master, $level, $exp); $stmt->fetch(); $guildnum =…
2
votes
2 answers

How to use the SQLITE3 LIKE statement

I have problems running a dynamic LIKE statement in my project: this query works like a charm and returns all items with a 't' in their name: const char *sql = "select * from bbc_ipad_v1_node where name LIKE '%%t%%'"; When I try to do this…
Thomas Joos
  • 2,451
  • 5
  • 26
  • 30
2
votes
3 answers

Try-clause containing multiple statements

Let's say I have the following function/method, which calculates a bunch of stuff and then sets a lot a variables/attributes: calc_and_set(obj). Now what I would like to do is to call the function several times with different objects, and if one or…
Aniss
  • 19
  • 2
2
votes
3 answers

While loop executing too early in C++

I wrote a simple program based on that from Chapter 5, listing 5.14 from C++ Primer 5th edition, supposedly meant to take an input time from a user and make the programe "wait" for that amount of time in seconds. The program does so using a while…