Mudanças entre as edições de "PRG122804 2019 1 AULA13b"
Ir para navegação
Ir para pesquisar
(2 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
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> | ||
+ | |||
+ | ==Questão 6== | ||
+ | |||
+ | <syntaxhighlight lang=c> | ||
+ | #include <stdio.h> | ||
+ | |||
+ | void main () | ||
+ | { | ||
+ | char alfa[100]="Vila Bela da Santissima Trindade"; | ||
+ | |||
+ | int y=0; | ||
+ | |||
+ | while(alfa[y]!=0) | ||
+ | y++; | ||
+ | printf ("Valor de y: %d\n", y); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==Questão 7== | ||
+ | |||
+ | Em sala de aula. | ||
+ | |||
+ | ==Questão 8== | ||
+ | |||
+ | <syntaxhighlight lang=c> | ||
+ | #include <stdio.h> | ||
+ | |||
+ | void main() | ||
+ | { | ||
+ | char TabCidades[5][20] ={"Sao Jose","Alfredo Wagner", | ||
+ | "Jaragua do Sul","Sao Joao Batista","SC"}; | ||
+ | printf("Resultado: %c%c%c%s\n",TabCidades[0][4],TabCidades[3][12], | ||
+ | TabCidades[1][2],TabCidades[4]); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==Questão 9== | ||
+ | |||
+ | <syntaxhighlight lang=c> | ||
+ | #include <stdio.h> | ||
+ | |||
+ | struct TDepartamento{ | ||
+ | char sigla[5]; | ||
+ | char nome[20]; | ||
+ | }; | ||
+ | |||
+ | struct TSetor{ | ||
+ | char sigla[5]; | ||
+ | char nome[20]; | ||
+ | struct TDepartamento depto; | ||
+ | }; | ||
+ | |||
+ | struct TPessoa{ | ||
+ | char nome[50]; | ||
+ | struct TSetor setor; | ||
+ | int num_filhos; | ||
+ | } Funcionario = {"Maria dos Santos",{"RH","Recursos Humanos",{"COM","Comercial"}},3}; | ||
+ | |||
+ | void main() | ||
+ | { | ||
+ | // Em sala de aula | ||
+ | |||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==Questão 10== | ||
+ | |||
+ | <syntaxhighlight lang=c> | ||
+ | #include <stdio.h> | ||
+ | |||
+ | main() | ||
+ | { | ||
+ | int x,y,w,*p1,*p2; | ||
+ | x = 3; | ||
+ | w = 5; | ||
+ | p1 = &x; | ||
+ | p2 = &w; | ||
+ | y = *p1 + w; | ||
+ | p1 = &y; | ||
+ | *p2 = *p1 + 7; | ||
+ | y = *p1 + *p2; | ||
+ | printf("Valor de y: %d",y); | ||
+ | } | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
----- | ----- | ||
− | [[Imagem:icone_voltar.png|link= | + | [[Imagem:icone_voltar.png|link=PRG122804_2019_1_AULA13]] |
[[Imagem:icone_menu.png|link=PRG122804_2019_1#Aulas]] | [[Imagem:icone_menu.png|link=PRG122804_2019_1#Aulas]] | ||
[[Imagem:icone_prox.png|link=PRG122804_2019_1_AULA14]] | [[Imagem:icone_prox.png|link=PRG122804_2019_1_AULA14]] |
Edição atual tal como às 14h45min 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);
}
Questão 6
#include <stdio.h>
void main ()
{
char alfa[100]="Vila Bela da Santissima Trindade";
int y=0;
while(alfa[y]!=0)
y++;
printf ("Valor de y: %d\n", y);
}
Questão 7
Em sala de aula.
Questão 8
#include <stdio.h>
void main()
{
char TabCidades[5][20] ={"Sao Jose","Alfredo Wagner",
"Jaragua do Sul","Sao Joao Batista","SC"};
printf("Resultado: %c%c%c%s\n",TabCidades[0][4],TabCidades[3][12],
TabCidades[1][2],TabCidades[4]);
}
Questão 9
#include <stdio.h>
struct TDepartamento{
char sigla[5];
char nome[20];
};
struct TSetor{
char sigla[5];
char nome[20];
struct TDepartamento depto;
};
struct TPessoa{
char nome[50];
struct TSetor setor;
int num_filhos;
} Funcionario = {"Maria dos Santos",{"RH","Recursos Humanos",{"COM","Comercial"}},3};
void main()
{
// Em sala de aula
}
Questão 10
#include <stdio.h>
main()
{
int x,y,w,*p1,*p2;
x = 3;
w = 5;
p1 = &x;
p2 = &w;
y = *p1 + w;
p1 = &y;
*p2 = *p1 + 7;
y = *p1 + *p2;
printf("Valor de y: %d",y);
}