Posts by Maniero • 444,682 points
6,921 posts
-
1
votes1
answer35
viewsA: Error accessing a struct
The code has some problems and I won’t talk about all of them, but that would be it: #include <stdio.h> #define SEMANA 7 #define TAM 1 typedef struct { int id; char nome[101]; float horasTrab;…
-
7
votes1
answer220
viewsA: How to add 1 to the number using the "for" command when the number N is a function parameter?
I imagine you got some code ready that sweeps through a collection of data that sums up your values. Learning based on ready-made code is very popular, but it’s also the reason why people don’t…
-
7
votes2
answers83
viewsA: Why do we use parameters/arguments in functions?
Functions and parameters Functions are not programming inventions. Contrary to what I understand people think, functions exist in mathematics, I don’t know why people don’t remember that. Functions…
-
2
votes1
answer665
viewsA: Difference in char* and const char* at the beginning of a function in C
I’m going to start with C because that’s what you used in the code, you didn’t use C++. That’s how he agreed to consider what a string in C. The language does not have the type string, it has only…
-
9
votes2
answers97
viewsA: Is it correct to program returning exceptions to the expected event?
Controversy This generates a bit of controversy because there are those who defend one thing and others who think the opposite. No one has proved what is right, so everyone only has opinions. Some…
-
3
votes3
answers136
viewsA: How to count from "1" instead of "0" in a Javascript array
Adding 1, that’s it. Because you don’t want to count from 1, you just want to present the element as vague 1. let vagas = ['Audi', 'HB20', 'Lamborghini', 'Maserati']; console.log(`No estacionamento…
-
6
votes2
answers63
viewsA: What does the %u do?
%u is the equivalent of %d, but it accepts numbers without signal, the u is just from unsigned. So it was used to match the final result established in the expression that will be printed. Here…
-
1
votes1
answer77
viewsA: Game modeling
What you call an attribute, and you must have learned from some material that uses the wrong name, actually is called field. Common fields can go in the abstract class, the specifics in other…
-
12
votes2
answers199
viewsA: What are the deconstructors?
There are some situations that you may want a particular object to be deconstructed with certain values assigned to variables. To deconstruct is not to destroy. To build is to take parts and to make…
-
3
votes1
answer48
viewsA: What is the appropriate style to write in Python?
That’s documenting in PEP8. Basically says to use the pattern snake_case, that is, write everything in lowercase and words are separated with a underline. This applies to almost all identifiers,…
-
1
votes1
answer286
viewsA: Print splitters in Python, with their sum in the output
The biggest reason for the error is that you are not adding up. Programming is interpreting the problem. In its description clearly has a sum, in the code there is no, so the problem is this. Making…
-
4
votes2
answers67
viewsA: Shorten condition that checks if value is one of several possible
It is possible to do: if 1 <= a <= 3: So you’re saying that 1 has to be less than or equal to a which in turn has to be less than or equal to 3. So reaches the numbers you want. Python allows…
-
0
votes1
answer203
viewsA: Exception Treatment does not work when dividing by zero
The division should be within the attempt, after the attempt is over and has already dealt with the possible mistake that has no way to happen, there is no point in making the division because there…
-
1
votes1
answer59
viewsA: CS0747 Error with C#declared
You’d have to do something like this: if (!int.TryParse(txtIdComanda.Text out var id) { //faz alguma coisa para indicar que deu erro e não permite continuar } if (!short.TryParse(txtMesa.Text out…
-
0
votes1
answer48
viewsA: How does access to strings in an array work?
1 - why [Month - 1]? Because arrays begin at 0, So if you typed month 1 you should get index 0, if it was 2 you should get 1, and so on until index 11 which is month 12 that we know. 2 - why the…
-
7
votes1
answer57
viewsA: Why can a double var store an int type?
Let’s start calling things by the right name, then let’s call x and y variable, because var is a C# command and using that word can confuse what you’re talking about. Then at the end I’d be saying a…
-
3
votes2
answers85
viewsA: How can we not do anything if the suit falls into the fake?
Not making a ternary, this operator was created to give a result, if you do not want a result to be made the operator should not be used, clearly it is a case for a if. But if I want to insist on it…
-
6
votes1
answer95
viewsA: Why are you making a mistake in calling a method?
The method beep() has no parameter, and you are passing a argument when you call it. Placing the parameter self which is always mandatory when creating a method solves the problem: class Car: def…
-
1
votes1
answer71
views -
1
votes1
answer38
viewsA: Error printing variables of a class object in code
Use keys to delimit what is code within the string. The point it finds indicates that it has finished the code, so it uses the object variable to interpret as code and the .nome becomes text. The…
-
0
votes1
answer66
viewsA: How to read or run other files and programs with Lua?
There is and there isn’t. There is os.execute() who does the same. Documentation. Wiki. It does not serve to run Javascript files, but can call the Node or Deno that will do this execution. There…
-
1
votes1
answer131
viewsA: Error: Try correcting the name to one that is defined, or Defining the name
You just passed IMC, has to go through IMCFormated also, so that the two variables exist in the local function and can be used. Therefore the function has to receive two parameters. Something like…
-
0
votes2
answers68
viewsA: What to use to store status in a database?
It seems obvious to me that the guy tinyint is best suited to store the status codes and then in the application makes the description on top of each code. But any integer can be useful if space is…
-
5
votes1
answer580
viewsA: What is the difference between SQL Server, Mysql and other SQL?
SQL Server is the name of a product of database microsoft. Obviously it uses SQL as query language and is mainly relational model (it uses other models too, can even be used as variations of Nosql…
-
1
votes1
answer62
viewsA: Error of expression "if"
There is no such syntax you used to compare. Read the documentation of language to use any resource. The correct syntax (without worrying if the logic is correct, because we are not even sure about…
-
3
votes2
answers151
viewsA: Why does changing a variable in a function not reflect in the passed variable itself?
And I return the question, why do you think a should be 3 if at no time you changed your value? You know What is a variable? Then there is a value stored in it, if you do not change the value of the…
-
8
votes2
answers139
viewsA: What is the default (Object) for in C#?
In this example it doesn’t seem necessary. That’s the same as: object obj = null; The default generates the default value of a type, in the case of reference types the default value is null. The…
-
3
votes1
answer67
viewsA: Instantiate a class with private attributes
The biggest reason it doesn’t work is that the display method doesn’t have a parameter to receive the object, in this case the self as used in other methods. class Pessoa: def __init__(self, nome,…
-
3
votes1
answer48
viewsA: Percentage of one value over another
The operators are reversed. To get a ratio you take the partial value and *divide at full value. You will already find the ratio, and will only multiply by 100 to indicate the proportion as a…
-
5
votes1
answer112
viewsA: Why does Python have such big numbers?
Python is a language of script, so what matters to her is to be easy, is to deliver what the programmer asks without creating difficulties. No matter efficiency or any other aspect. The computer…
-
7
votes1
answer168
viewsA: Why does Std::Cout use <<?
Because the language creators thought that this operator would be interesting to indicate "a piece of a stream". It was what visually gave some indication of being a stream, was available for this…
-
1
votes1
answer275
viewsA: What is the point of using Assert.assertNotNull() in frameworks?
Yes, at first it is quite correct, assertions should be standard in every method that one wants robustness. Of course, it may not be, it depends on the goal of the person. It is not right to use…
-
5
votes1
answer295
viewsA: Why is the C language considered to be a medium-level language?
Give a reference that this is true. And define what is medium level. There is no language level This language level cosia is complicated and there are controversies of what is low or high level,…
-
1
votes1
answer97
viewsA: What is Ienumerable.Getenumerator in C#?
GetEnumerator() ends with parentheses, right? And if you have this, as in all languages, it would be a... method! What seems strange is having a surname in the method. And this is what is called…
-
5
votes2
answers921
viewsA: What is the difference between table, database and database?
The terms are usually used more informally, but there is a more correct way to use, which does not always match the way it is used. In general "database" is used as a contraction of "database…
-
6
votes4
answers201
viewsA: How to reduce Python code 3?
I will not worry about failure if the person does not enter a valid number. You have to change the value of x to the next unit if it is not odd, otherwise it should not change, then the increment…
-
0
votes2
answers46
viewsA: Implementation of member functions
It is not wrong if it is desired. The definition outside exists for some reasons, some more important than others, mainly: Separate compilation does not require everything to go through the analysis…
-
0
votes1
answer154
viewsA: Print the letters in front of the alphabet
You have to check if you found the line break, because that’s what the fgets() puts when you finish typing. You can also check whether you found the null terminator of the string. The efficiency of…
-
6
votes1
answer71
viewsA: How to add a value key to a dictionary?
You should not force a concatenation just to break the line, you should indicate that the line continues just below, for that use the \ to indicate that it is the same line even having a break:…
-
2
votes1
answer103
viewsA: Return true when Bigdecimal variable is different from null, otherwise return false
Guaranteed more optimized has no, but shorter has: exampleMethod(x != null) An expression that has a relational operator always results in a boolean value, so true whether that comparison is true…
-
0
votes1
answer35
views -
3
votes1
answer113
viewsA: Is there any difference between the terms "call", "invoke" or "apply" a function?
I have never seen a clear formal definition of this, but in fact the terms are used in different contexts, although in practice it makes no difference. It has been agreed to use different terms when…
-
5
votes1
answer62
viewsA: Copied objects stay at different addresses?
First let’s understand the correct definitions. Nor $abc, nor $mno are objects, are variables. Variables can store objects, or references to objects. If they store objects obviously objects are…
-
5
votes2
answers64
viewsA: How to copy a string in C?
He is not modifying the string result because result is not a string, is a variable and you may notice that nowhere this variable is modified. It changes the variable p increasing the pointer to go…
-
9
votes3
answers300
viewsA: How to perform a condition in the array to verify that multiple elements exist at the same time?
An efficient version: function includesTwo(array, one, two) { let achou = false; for (const item of array) { if (item == one || item == two) { if (achou) return true; achou = true; } } return false;…
javascriptanswered Maniero 444,682 -
1
votes1
answer148
viewsA: Input treatment with scanf() return
The main problem is that the buffer gets dirty and has to clean it. scanf() is not very suitable for very simple data entry. More organized is so (although it could be improved): #include…
-
2
votes2
answers159
viewsA: C function that checks whether the whole string is lowercase
The logic is wrong and the code is more complex than it should be. If you find an uppercase then you already know that the text is not all lowercase (I think and to check if it is all, the question…
-
6
votes1
answer304
viewsA: Binary sum result
The concept of the question is all wrong, there is no binary number, number is number, arithmetic is arithmetic, binary or decimal is just the way to present on screen or paper, it is not accounted…
-
2
votes1
answer59
viewsA: Segmentation Fault na strcat()
Almost everything you want to know is in: String pointer does not work as expected If array is the same as pointer, why does one need to be copied to a variable and another need not? Where does the…
-
2
votes2
answers280
viewsA: Using another class variable in Javascript
There is the conceptual error, or the question does not make sense. It has another class, but has no other object. It would be good to read What is the difference between a class and an object? to…