mini Dictionary with the main terms and commands in C programming logic

devcpp
devcpp

Small dictionary with simple explanation of the main commands in programming logic.

Data Types

  • Integer %d int - (Ex: 1, -1): When you want to store numeric information of positive or negative integers.
  • Real %f float - (Ex: 5.50, 1.57): When you want to store numeric information that belongs to the set of real numbers, but in this case it accepts decimal numbers.
  • Character %c char - (Ex: 1, 2, A, B, C): When you want to store Alphanumeric information, but with this type you cannot perform arithmetic operations, but only work on information.
  • String %s str (Ex: 1, 2, 3, A, B, C): In programming and in formal languages, a string (also known as a sample or string) is an ordered sequence of characters (symbols) chosen from a predetermined set. In programming, each symbol stored in memory is represented by a numerical value. A variable declared with a string data type usually stores a predetermined number of characters.
  • Logical - True or False: Of logical type, accepts only two values, True or False.

Variable

  • It is an abstract type of data that is stored and can be changed at some point over a period of time while processing data on the computer.

Constant

  • It is an abstract type of data that is stored, but this data cannot be changed, that is, there is no variation over time.

Identifiers

  • These are the names we give the variables.

flowchart

  • They are ways of expressing logic through symbols.

pseudocode

  • A way to imitate the programming language through a natural language.

Algorithm

  • An algorithm is a finite sequence of well-defined and unambiguous instructions, each of which can be mechanically executed in a finite period of time and with a finite amount of effort.

Operators

  • ! – Denial
  • ++ – Increment (Ex: 1++ is equal to 1+1. OBS: x++ gets the value of x then increments. NOTE: ++x Increases the value of X)
  • – Decrement
  • && – And or AND operator
  • || – OR or OR operator
  • % – mod, that is, returns the remainder of a division. (Ex: 4 % 2 == 0)
  • +, -, *, / – Arithmetic operators
  • > - Bigger then
  • < - Less than
  • >= – Greater than or equal to
  • <= – Less than or equal to
  • == Equal to
  • = – Assign a value to

decision structures

  • IF (or SE) – Logical condition structure. Checks whether a condition is True or False and makes a decision. If the condition is true it executes one set of instructions, if it is false it executes another set of instructions.
  • Else (So) – Exiting a condition IF
  • Elseif  (Else if) - Structure decision logic within another logical decision structure

Multiple Choice Decision Structures

  • Switch (means choice) - Evaluates the value of variable X and if X is equal to 1, executes instruction 1, if equals to 2, executes instruction 2, if equal to 3, executes instruction 3, and so on.

Example using C procedural language:

#include #include main(){ int op;
printf("\tChoose option:\n"); printf("1: option 1\n"); printf("2: option 2\n"); printf("3: option 3\n"); scanf("%d",&op);
switch (op){
case 1: printf("option 1\n"); break;
case 2: printf("option 2\n"); break;
case 3: printf("option 3\n"); break;
default: printf("incorrect option\n"); break; } system("pause"); }

Loops in programming language – Loops mean repetition.

  • while (while loop) – As long as a condition is true it keeps repeating the instruction.

Example:

#include #include main(){ int op;
while(1){
printf("\tChoose option:\n"); printf("1: option 1\n"); printf("2: option 2\n"); printf("3: option 3\n"); scanf("%d",&op); switch (op){ case 1: printf("option 1\n"); break; case 2: printf("option 2\n"); break; case 3: printf("option 3\n"); break; default: printf("incorrect option\n"); break; }
}
system("pause"); }

 

  • do while (repeat loop) – Repeat an instruction until a condition defined at the end of the loop of be true.

Example:

#include #include main(){ int i=0; printf("Sequence of numbers from 1 to 10\n\n");
of{
printf(" %d ",i); i++;
} while(i<10);
printf("\n\n"); system("pause"); }

 

  • for (tie to) – This loop contains a initial condition, one final condition it is a step.

See an example writing for counting numbers from 1 to 10: 

#include #include main(){ int i=0; printf("Sequence of numbers from 1 to 10\n\n");
for(i>0; i<=10; i++){
printf(" %d ",i);
}
printf("\n\n"); system("pause"); }

Note that in this example above we have a initial condition (i>0), one final condition (i<=10) it is a step (i++).

 

 3,570 Total Visualizações,  4 Visualizações Hoje

3 comments

  1. Hi, I'm looking for a list of all commands with an explanation of what each command does, if I had something similar please let me know.obg

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.