Check if a number belongs to the range [a, b]. a and b are real numbers read from the keyboard

Computers are some of the most versatile tools that we have available. They are capable of performing stunning feats of computation, they allow information to be exchanged easily regardless of their physical location, they simplify many every-day tasks, and they allow us to automate many processes that would be tedious or boring to perform otherwise. However, computers are not “intelligent” as we are. They have to be told in no uncertain terms exactly what they’re supposed to do, and their native languages are quite unlike anything we speak. Thus, there’s a formidable language barrier between a person who wishes a computer to do something, and the computer that typically requires instructions in its native language, machine code, to do anything. So far, computers cannot figure out what they are supposed to do on their own, and thus they rely on programs which we create, which are sets of instructions that the computer can understand and follow.

An Overview of Programs and Programming Languages

In order to better communicate to our computers what exactly it is we want them to do, we’ve developed a wide range of programming languages to make the communication process easier.

Depending on the type of project, there are many factors that have to be considered when choosing a language. Here is a list of some of the more noteworthy ones:

  • Compiled, interpreted, or JIT-compiled
    Compiled languages are translated to the target machine’s native language by a program called a compiler. This can result in very fast code, especially if the compiler is effective at optimizing, however the resulting code may not port well across operating systems and the compilation process may take a while.
    Interpreted languages are read by a program called an interpreter and are executed by that program. While they are as portable as their interpreter and have no long compile times, interpreted languages are usually much slower than an equivalent compiled program.
    Finally, just-in-time compiled (or JIT-compiled) languages are languages that are quickly compiled when programs written in them need to be run (usually with very little optimization), offering a balance between performance and portability.
  • High or Low Level Level, in this case, refers to how much the nature of the language reflects the underlying system. In other words, a programming language’s level refers to how similar the language is to a computer’s native language. The higher the level, the less similar it is.
    low-level language is generally quite similar to machine code, and thus is more suitable for programs like device drivers or very high performance programs that really need access to the hardware. Generally, the term is reserved for machine code itself and assembly languages, though many languages offer low-level elements. Since a low-level language is subject to all the nuances of the hardware it’s accessing, however, a program written in a low-level language is generally difficult to port to other platforms. Low level languages are practically never interpreted, as this generally defeats the purpose.
    high-level language focuses more on concepts that are easy to understand by the human mind, such as objects or mathematical functions. A high-level language usually is easier to understand than a low-level language, and it usually takes less time to develop a program in a high-level language than it does in a low-level language. As a trade-off one generally needs to sacrifice some degree of control over what the resulting program actually does. It is not, however, impossible to mix high-level and low-level functionality in a language.
  • Type System
    type system refers to the rules that the different types of variables of a language have to follow. Some languages (including most assembly languages) do not have types and thus this section does not apply to them. However, as most languages (including C++) have types, this information is important.

    • Type Strength: Strong or Weak
      A strong typing system puts restrictions on how different types of variables can be converted to each other without any converting statements. An ideal strong typing system would forbid implicit “casts” to types that do not make any sense, such as an integer to a Fruit object. A weak typing system would try to find some way to make the cast work.
    • Type Expression: Manifest or Inferred
      This deals with how the compiler/interpreter for a language infers the types of variables. Many languages require variables’ types to be explicitly defined, and thus rely on manifest typing. Some however, will infer the type of the variable based on the contexts in which it is used, and thus use inferred typing.
    • Type Checking: Static or Dynamic
      If a language is statically typed, then the compiler/interpreter does the type checking once before the program runs/is compiled. If the language is dynamically type checked, then the types are checked at run-time.
    • Type Safety: Safe or Unsafe
      These refer to the degree to which a language will prohibit operations on typed variables that might lead to undefined behavior or errors. A safe language will do more to ensure that such operations or conversions do not occur, while an unsafe language will give more responsibility to the user in this regard.

    These typing characteristics are not necessarily mutually exclusive, and some languages mix them.

  • Supported paradigms
    A programming paradigm is a methodology or way of programming that a programming language supports. Here is a summary of a few common paradigms:

    • Declarative
      A declarative language will focus more on specifying what a language is supposed to accomplish rather than by what means it is supposed to accomplish it. Such a paradigm might be used to avoid undesired side-effects resulting from having to write one’s own code.
    • Functional
      Functional programming is a subset of declarative programming that tries to express problems in terms of mathematical equations and functions. It goes out of its way to avoid the concepts of states and mutable variables which are common in imperative languages.
    • Generic
      Generic programming focuses on writing skeleton algorithms in terms of types that will be specified when the algorithm is actually used, thus allowing some leniency to programmers who wish to avoid strict strong typing rules. It can be a very powerful paradigm if well-implemented.
    • Imperative
      Imperative languages allow programmers to give the computer ordered lists of instructions without necessarily having to explicitly state the task. It can be thought of being the opposite of declarative programming.
    • Structured
      Structured programming languages aim to provide some form of noteworthy structure to a language, such as intuitive control over the order in which statements are executed (if X then do Y otherwise do Z, do X while Y is Z). Such languages generally deprecate “jumps”, such as those provided by the goto statement in C and C++.
    • Procedural
      Although it is sometimes used as a synonym for imperative programming, a procedural programming language can also refer to an imperative structured programming language which supports the concept of procedures and subroutines (also known as functions in C or C++).
    • Object-Oriented
      Object-Oriented programming (sometimes abbreviated to OOP) is a subset of structured programming which expresses programs in the terms of “objects”, which are meant to model objects in the real world. Such a paradigm allows code to be reused in remarkable ways and is meant to be easy to understand.
  • Standardization
    Does a language have a formal standard? This can be very important to ensure that programs written to work with one compiler/interpreter will work with another. Some languages are standardized by the American National Standards Institute (ANSI), some are standardized by the International Organization for Standardization (ISO), and some have an informal but de-facto standard not maintained by any standards organization.
[mai mult...]

Check if a number is positive in c ++

Computers are some of the most versatile tools that we have available. They are capable of performing stunning feats of computation, they allow information to be exchanged easily regardless of their physical location, they simplify many every-day tasks, and they allow us to automate many processes that would be tedious or boring to perform otherwise. However, computers are not “intelligent” as we are. They have to be told in no uncertain terms exactly what they’re supposed to do, and their native languages are quite unlike anything we speak. Thus, there’s a formidable language barrier between a person who wishes a computer to do something, and the computer that typically requires instructions in its native language, machine code, to do anything. So far, computers cannot figure out what they are supposed to do on their own, and thus they rely on programs which we create, which are sets of instructions that the computer can understand and follow.

An Overview of Programs and Programming Languages

In order to better communicate to our computers what exactly it is we want them to do, we’ve developed a wide range of programming languages to make the communication process easier.

Depending on the type of project, there are many factors that have to be considered when choosing a language. Here is a list of some of the more noteworthy ones:

  • Compiled, interpreted, or JIT-compiled
    Compiled languages are translated to the target machine’s native language by a program called a compiler. This can result in very fast code, especially if the compiler is effective at optimizing, however the resulting code may not port well across operating systems and the compilation process may take a while.
    Interpreted languages are read by a program called an interpreter and are executed by that program. While they are as portable as their interpreter and have no long compile times, interpreted languages are usually much slower than an equivalent compiled program.
    Finally, just-in-time compiled (or JIT-compiled) languages are languages that are quickly compiled when programs written in them need to be run (usually with very little optimization), offering a balance between performance and portability.
  • High or Low Level Level, in this case, refers to how much the nature of the language reflects the underlying system. In other words, a programming language’s level refers to how similar the language is to a computer’s native language. The higher the level, the less similar it is.
    low-level language is generally quite similar to machine code, and thus is more suitable for programs like device drivers or very high performance programs that really need access to the hardware. Generally, the term is reserved for machine code itself and assembly languages, though many languages offer low-level elements. Since a low-level language is subject to all the nuances of the hardware it’s accessing, however, a program written in a low-level language is generally difficult to port to other platforms. Low level languages are practically never interpreted, as this generally defeats the purpose.
    high-level language focuses more on concepts that are easy to understand by the human mind, such as objects or mathematical functions. A high-level language usually is easier to understand than a low-level language, and it usually takes less time to develop a program in a high-level language than it does in a low-level language. As a trade-off one generally needs to sacrifice some degree of control over what the resulting program actually does. It is not, however, impossible to mix high-level and low-level functionality in a language.
  • Type System
    type system refers to the rules that the different types of variables of a language have to follow. Some languages (including most assembly languages) do not have types and thus this section does not apply to them. However, as most languages (including C++) have types, this information is important.

    • Type Strength: Strong or Weak
      A strong typing system puts restrictions on how different types of variables can be converted to each other without any converting statements. An ideal strong typing system would forbid implicit “casts” to types that do not make any sense, such as an integer to a Fruit object. A weak typing system would try to find some way to make the cast work.
    • Type Expression: Manifest or Inferred
      This deals with how the compiler/interpreter for a language infers the types of variables. Many languages require variables’ types to be explicitly defined, and thus rely on manifest typing. Some however, will infer the type of the variable based on the contexts in which it is used, and thus use inferred typing.
    • Type Checking: Static or Dynamic
      If a language is statically typed, then the compiler/interpreter does the type checking once before the program runs/is compiled. If the language is dynamically type checked, then the types are checked at run-time.
    • Type Safety: Safe or Unsafe
      These refer to the degree to which a language will prohibit operations on typed variables that might lead to undefined behavior or errors. A safe language will do more to ensure that such operations or conversions do not occur, while an unsafe language will give more responsibility to the user in this regard.

    These typing characteristics are not necessarily mutually exclusive, and some languages mix them.

  • Supported paradigms
    A programming paradigm is a methodology or way of programming that a programming language supports. Here is a summary of a few common paradigms:

    • Declarative
      A declarative language will focus more on specifying what a language is supposed to accomplish rather than by what means it is supposed to accomplish it. Such a paradigm might be used to avoid undesired side-effects resulting from having to write one’s own code.
    • Functional
      Functional programming is a subset of declarative programming that tries to express problems in terms of mathematical equations and functions. It goes out of its way to avoid the concepts of states and mutable variables which are common in imperative languages.
    • Generic
      Generic programming focuses on writing skeleton algorithms in terms of types that will be specified when the algorithm is actually used, thus allowing some leniency to programmers who wish to avoid strict strong typing rules. It can be a very powerful paradigm if well-implemented.
    • Imperative
      Imperative languages allow programmers to give the computer ordered lists of instructions without necessarily having to explicitly state the task. It can be thought of being the opposite of declarative programming.
    • Structured
      Structured programming languages aim to provide some form of noteworthy structure to a language, such as intuitive control over the order in which statements are executed (if X then do Y otherwise do Z, do X while Y is Z). Such languages generally deprecate “jumps”, such as those provided by the goto statement in C and C++.
    • Procedural
      Although it is sometimes used as a synonym for imperative programming, a procedural programming language can also refer to an imperative structured programming language which supports the concept of procedures and subroutines (also known as functions in C or C++).
    • Object-Oriented
      Object-Oriented programming (sometimes abbreviated to OOP) is a subset of structured programming which expresses programs in the terms of “objects”, which are meant to model objects in the real world. Such a paradigm allows code to be reused in remarkable ways and is meant to be easy to understand.
  • Standardization
    Does a language have a formal standard? This can be very important to ensure that programs written to work with one compiler/interpreter will work with another. Some languages are standardized by the American National Standards Institute (ANSI), some are standardized by the International Organization for Standardization (ISO), and some have an informal but de-facto standard not maintained by any standards organization.
[mai mult...]

Sa se scrie un program care calculeaza valoarea expresiei: P=1*(1/2)*3*(1/4)*5*(1/6)*…n

Operatorii aritmetici binari in C++ sunt reprezentati de multimea formata din caracterele: {+,-,*,/,%}. In tabelul de mai jos putem vedea ce rol indeplineste fiecare din ele:

Operator Denumire Semnificatie
+ adunare determina adunarea a doua variabile sau valori
scadere determina scadere a doua variabile sau valori
* inmultire determina inmultirea a doua variabile sau valori
/ impartire determina impartirea a doua variabile sau valori
% modulo determina restul impartirii a doua variabile sau valori

Cu ajutorul acestor operatori putem face diverse operatii aritmetice in C++. In tabelul de mai jos regasim cateva exemple de operatii realizate cu ajutorul operatorilor aritmetici:

Expresie matematica Rezultat
(presupunem ca avem declarate 2 variabile int a=14 si int b=4)  
a+b 14+4=18
a-b 14-4=10
a*b 14*4=56
a/b 14/4=3
a%b 14%4=2
(b+a)/b 18/4=4
(a+b)%b 18%4=2
(a+b)/3 18/3=6

Observatii:

  1. Impartirea a doua numere returneaza o valoare de tip intreg (catul impartirii) doar daca valorile impartite sunt de tip intreg. Exemplu: int a=10; int b=3; atunci a/b=3 (10/3=10)
  2. In cazul in care impartitorul sau deimpartitul sunt de tipul float sau double (de tip real adica), atunci expresia matematica a/b va intoarce rezultatul impartirii. Exemplu: float a=10; int b=3; atunci a/b=3.33333(3) ( 10.0/3=3.3333(3) )
[mai mult...]

Sa se scrie un program care calculeaza x la puterea y (folosind functia pow)

funcție este un ansamblu de instrucțiuni care prelucrează un set de date de intrare, numite parametri sau argumente și obține un rezultat. Când folosim funcțiile, acestea apar în expresii ca operand, valoarea operandului fiind de fapt rezultatul funcției, obținut în urma prelucrării valorilor curente ale parametrilor.

De exemplu, în C++ nu există nicio operație prin care să calculăm rădăcina pătrată a unui număr real, de exemplu 5–√5. Acest lucru poate fi realizat folosind funcția sqrt, prin apelul sqrt(5); acesta trebuie realizat într-o expresie, de exemplu o afișare:

[mai mult...]

Contorizare consoane si vocale din text

Se citeste un text format din cuvinte ce pot fi despartite prin spatiu sau virgula. Textul citit se termina cu punct sau enter. Sa se contorizeze vocalele si consoanele din acel text. Sa se rezolve problema folosind o bucla repetitiva conditionata posterior.

Forma unei funcții

Despre funcția sqrt (și de fapt despre orice funcții), trebuie cunoscute niște informații specifice, pentru a ști cum și când o putem folosi:

  • numele funcției
  • numărul parametrilor
  • tipul parametrilor
  • tipul rezultatului

Aceste informații sunt precizate printr-un mecanism de declarare a funcției, numit prototip. De exemplu funcția sqrt determină rădăcina pătrată dintr-un număr real (nenegativ) iar rezultatul său este de asemenea număr real. Prototipul său este:

double sqrt(double);

Prototipurile funcțiilor din aceeași categorie sunt grupate într-un fișier header. Acesta trebuie inclus în programul nostru, prin directiva #include. De exemplu, dacă folosim operațiile de de citire/scriere vom include header-ul iostream, iar dacă folosim funcțiile matematice vom include header-ul cmath.

Funcții cu caracter matematic

Denumire Header Prototip Rezultat
abs cstdlib int abs(int x) Valoarea absolută a argumentului, |x||x|, număr întreg
abs, fabs cmath double abs(double x), double fabs(double x) Valoarea absolută a argumentului, |x||x|, număr real
sqrt cmath double sqrt(double x) Rădăcina pătrată a argumentului, x−−√x
pow cmath double pow(double x, double y) Ridicarea la putere, xyxy
sin cmath double sin(double x) Funcția trigonometrică sinus, sinxsin⁡x
cos cmath double cos(double x) Funcția trigonometrică cosinus,cosxcos⁡x
tan cmath double tan(double x) Funcția trigonometrică tangentă,tanxtan⁡x
floor cmath double floor(double x) Cel mai mare întreg mai mic sau egal cu x
ceil cmath double ceil(double x) Cel mai mic întreg mai mare sau egal cu x
[mai mult...]

DEZACTIVARE PAROLA DE LOGARE

Sistemul de operare Windows necesită introducerea parolei la fiecare pornire a calculatorului, ceea ce poate deveni iritant si un timp pierdut, dacă nu exista și un alt utilizator, insa vrem să ocrotim datele sensibile de alții.

Începând cu sistemul de operare Windows 8, echipa Microsoft acordă mai multă atenție asupra siguranței. Una dintre aceste funcții de siguranță este parola de logare. Sistemul de operare Windows 10 cere introducerea parolei la fiecare pornire a calculatorului. Dacă vreți să dezactivați, procedați în felul următor:

[mai mult...]

C++ for loop

for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.

The syntax of a for loop in C++ is −

for ( init; condition; increment ) {
   statement(s);
}

Here is the flow of control in a for loop −

  • The init step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears.
  • Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and flow of control jumps to the next statement just after the for loop.
  • After the body of the for loop executes, the flow of control jumps back up to the increment statement. This statement can be left blank, as long as a semicolon appears after the condition.
  • The condition is now evaluated again. If it is true, the loop executes and the process repeats itself (body of loop, then increment step, and then again condition). After the condition becomes false, the for loop terminates.

 

[mai mult...]

Criptare fișiere Android sau ascunde fișiere pe telefon

De multe ori pe telefonul Android, ar putea exista multe fișiere care ar putea fi personale și nu doriți ca alții să le acceseze. În cazul în care telefonul este furat, aceste fișiere personale ar putea fi vizibile. Deci, este întotdeauna bine să aveți fișierele securizate, ascunse sau criptate, astfel încât acestea să nu fie accesibile.

În cea mai recentă versiune de Android Marshmallow, telefonul este criptat obligatoriu de către producători de telefoane mobile. Dar nu există nicio opțiune care să ascundă fișierele în Android. În acest articol vom vorbi despre o aplicație simplă care poate cripta și ascunde fișierele din Android.

[mai mult...]