Mudanças entre as edições de "PRG122804 2019 1 AULA13b"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
Linha 56: Linha 56:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
==Questão 3==
 +
 +
 +
<syntaxhighlight lang=c>
 +
#include <stdio.h>
 +
#include <math.h>
 +
 +
void main()
 +
{
 +
 +
  float y,a,b;
 +
 +
  a=25;
 +
  b=9;
 +
 +
  y = sqrt(sqrt(pow(a,2)*pow(b,2)));
 +
  printf ("%0.1f", y);
 +
}
 +
</syntaxhighlight>
 +
 +
==Questão 4==
 +
 +
<syntaxhighlight lang=c>
 +
#include <stdio.h>
 +
 +
void main()
 +
{
 +
  int y,x[10] = {2,4,7,-5,3,2,3,4,9,10};
 +
  y=x[1]+x[9]/2;
 +
  printf("Valor de y: %d\n",y);
 +
}
 +
</syntaxhighlight>
 +
 +
==Questão 5==
 +
 +
<syntaxhighlight lang=c>
 +
#include <stdio.h>
 +
 +
void montar_vet(int aux[5])
 +
{
 +
  int i,tmp;
 +
 +
  for (i=0;i<5;i++) {
 +
    tmp=aux[i];
 +
    aux[i]=aux[5-i];
 +
    aux[5-i]=tmp;
 +
  }
 +
}
 +
 +
void main()
 +
{
 +
  int y,vet[5]={-1,2,4,8,-16};
 +
 +
  montar_vet(vet);
 +
  y=vet[1]+vet[3];
 +
 +
  printf("Valor de y: %d\n",y);
 +
}
 +
</syntaxhighlight>
 +
  
 
-----
 
-----

Edição das 14h40min de 29 de maio de 2019

Correção da AT2

Em sala de aula!!!

Questão 1

#include <stdio.h>

void funcA()
{
    printf("Esta é a função funcA()\n");
}
void funcB()
{
    funcA();
    printf("Esta é a função funcB()\n");
    funcD();
}
void funcC()
{

    printf("Esta é a função funcC()\n");
    funcB();
}
void funcD()
{
    printf("Esta é a função funcD()\n");

}
void main()
{
    funcC();
}

Questão 2

#include <stdio.h>

int i=100;

void func()
{
    int i=1;
    i=i+100;
    printf( "Valor de i = %d na função func()\n", i );
}

void main()
{
    i=i+10;
    func();
    printf( "Valor de i = %d \n", i );
}


Questão 3

#include <stdio.h>
#include <math.h>

void main()
{

  float y,a,b;

  a=25;
  b=9;

  y = sqrt(sqrt(pow(a,2)*pow(b,2)));
  printf ("%0.1f", y);
}

Questão 4

#include <stdio.h>

void main()
{
  int y,x[10] = {2,4,7,-5,3,2,3,4,9,10};
  y=x[1]+x[9]/2;
  printf("Valor de y: %d\n",y);
}

Questão 5

#include <stdio.h>

void montar_vet(int aux[5])
{
  int i,tmp;

  for (i=0;i<5;i++) {
     tmp=aux[i];
     aux[i]=aux[5-i];
     aux[5-i]=tmp;
  }
}

void main()
{
   int y,vet[5]={-1,2,4,8,-16};

   montar_vet(vet);
   y=vet[1]+vet[3];

   printf("Valor de y: %d\n",y);
}



Icone voltar.png Icone menu.png Icone prox.png