Informática, perguntado por Gretto, 9 meses atrás

na linguagem c/c++ o que significa float tab[2][3] e dar um exemplo

Soluções para a tarefa

Respondido por Cl4ytonP3reira
1

Resposta:

Significa a declaração de uma variável. No caso uma variável bidimensional em forma de matriz 2x3 do tipo float (decimal).

- float= Tipo da Variável ---- (se decimal(float), se inteira (int), se caracter(char) e etc...)

- tab= Nome da variável

- [2][3]= Dimensão 2x3

O video abaixo é bem interessante:

https://www.youtube.com/watch?time_continue=198&v=5oQrDq8qqfg&feature=emb_logo

Explicação:

Segue dois Códigos para seus estudos:

** Use o onlinegdb (só googlar) para testar o código ou qualquer compilado de "Linguagem C"

1- Matriz Declarada e Inicializada (Tipo Float: Número Decimal)

/******************************************************************************

Welcome to GDB Online.

GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,

C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.

Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/

#include <stdio.h>

int main()

{

   /*Declarando as Variáveis de Linhas "i" e Coluna "j"*/

   int i, j;

   /*Declarando a Variável MATRIZ 2X3*/

   float matriz[2][3] = {{1,2.5,3},{4,5.9,6}}; /*observe o 2.5 e 5.9 são decimais, portanto, tipo foat*/

   

   /*Lendo as Linhas "i" e Colunas "j" da variável Matriz com o FOR*/

   printf("\n------------------------------------");

   printf("\nEXIBINDO OS VALORES DA MATRIZ");

   printf("\n------------------------------------\n\n");

   for (i=0; i<2; i++) //Litura da Linha "i"

     for (j=0; j<3; j++) //Litura da Coluna "j"

    {

       printf("Exibindo o Elemento [%d][%d]: %.1f\n", i, j, matriz[i][j]);

    }

   printf("\n------------------------------------");

   printf("\n     Por Cl4yton P3reira");

   printf("\n------------------------------------");

   return 0;

}

2- Matriz apenas declarada (Tipo Int: Número Inteiro) com entrada de dados por teclado.

/******************************************************************************

Welcome to GDB Online.

GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,

C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.

Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/

#include <stdio.h>

int main()

{

   /*Declarando as Variáveis de Linhas "i" e Coluna "j" */

   int i, j;

   /*Declarando a Variável MATRIZ 2X3*/

   int matriz[2][3];

   

   /*Capturando os Elementos da MATRIZ 2X3*/

   printf("------------------------------------");

   printf("\nCAPTURANDO OS ELEMENTOS DA MATRIZ");

   printf("\n------------------------------------\n\n");

   for (i=0; i<2; i++) //Litura da Linha "i"*/

     for (j=0; j<3; j++) //Litura da Coluna "j"*/

    {

       printf("Entre com o Elemento Inteiro [%d][%d]: ", i, j);

       scanf("%d", &matriz[i][j]);

    }

   

   /*Lendo as Linhas "i" e Colunas "j" da variável Matriz com o FOR*/

   printf("\n------------------------------------");

   printf("\nEXIBINDO OS VALORES DA MATRIZ");

   printf("\n------------------------------------\n\n");

   for (i=0; i<2; i++) /*Litura da Linha "i"*/

     for (j=0; j<3; j++) /*Litura da Coluna "j"*/

    {

       printf("Exibindo o Elemento [%d][%d]: %d\n", i, j, matriz[i][j]);

    }

   printf("\n------------------------------------");

   printf("\n     Por Cl4yton P3reira");

   printf("\n------------------------------------");

   return 0;

}

Anexos:
Perguntas interessantes