Mudanças entre as edições de "PR1022804 2021 1 AULA06b"
Ir para navegação
Ir para pesquisar
Linha 107: | Linha 107: | ||
printf("\nResultado: E"); | printf("\nResultado: E"); | ||
return 0; | return 0; | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ;Questão 8 | ||
+ | |||
+ | ;Execute o código e observe o resultado: | ||
+ | |||
+ | <syntaxhighlight lang=c> | ||
+ | #include <stdio.h> | ||
+ | |||
+ | void main() | ||
+ | { | ||
+ | int i=0, a=10, b=1,aux=0; | ||
+ | |||
+ | while(i<10){ | ||
+ | if (i>=9){ | ||
+ | aux=a+b; | ||
+ | a=b; | ||
+ | } | ||
+ | b++; | ||
+ | i++; | ||
+ | } | ||
+ | aux=a+b; | ||
+ | printf("Valor: aux=%d i=%d b=%d ",aux, i, b); | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Edição das 13h27min de 15 de julho de 2021
Correção da AT1
Gabarito: https://wiki.sj.ifsc.edu.br/index.php/Arquivo:Gabarito_-_PR1022804_2021_1_AT1.pdf
- Por que as questões são FALSAS?
- Questão 1
- a) O texto diz respeito a pseudocódigo não a fluxograma.
- d) Uma receita é um algoritmo.
- Questão 2
- b) O texto se refere a entradas não a saídas.
- d) O computador não faz tudo sozinho.
- Questão 3
- a), b) e c) Não são a ordem correta.
- Questão 4
- Execute o código:
#include <stdio.h>
int main()
{
int x=5, y=3, z=1;
printf("\n (x*(y+z)/2)==%d", (x*(y+z)/2) );
printf("\n (x%%y+(11%%y))==%d", (x%y+(11%y)) );
printf("\n (5-(x/(z+1)-y))==%d", (5-(x/(z+1)-y)) );
printf("\n (x/y/z*-1)==%d", (x/y/z*-1) );
return 0;
}
- a) (x*(y+z)/2)==10 verdadeiro
- b) (x%y+(11%y))==4 verdadeiro
- c) (5-(x/(z+1)-y))==6 falso
- d) (x/y/z*-1)==-1 falso
- Questão 5
- Execute o código e observe o resultado:
- 1 - verdadeiro
- 0 - falso
#include <stdio.h>
int main()
{
int x=1, y=-1, z=0;
printf("\n (z-x)!==y => %d", (z-x)!=y );
printf("\n (x>=y)&&(y>=z)||(1) => %d", (x>=y)&&(y>=z)||(1) );
printf("\n (!(y+x)==z) => %d", (!(y+x)==z) );
printf("\n (z<y)||(z==0) => %d", (z<y)||(z==0) );
return 0;
}
- a) (z-x)!==y => 0
- b) (x>=y)&&(y>=z)||(1) => 1
- c) (!(y+x)==z) => 0
- d) (z<y)||(z==0) => 1
- Questão 6
a) Se A=3, B=1 e C=2 vai exibir A. c) Se A=1, B=2 e C=2 vai exibir C.
- Questão 7
- a) O programa tem 4 variáveis.
- d) Se NUM1=5, NUM2=6, NUM3=7 o resultado vai ser “S”.. porque a média é 6.
Teste o código abaixo:
#include <stdio.h>
int main()
{
int NUM1;
int NUM2;
int NUM3;
float MEDIA;
printf("\nDigite NUM1: ");
scanf("%d",&NUM1);
printf("\nDigite NUM2: ");
scanf("%d",&NUM2);
printf("\nDigite NUM3: ");
scanf("%d",&NUM3);
MEDIA=(NUM1+NUM2+NUM3)/3.0; // ".0" para garantir que o resultado seja real.
if (MEDIA<6)
printf("\nResultado: I");
else
if (MEDIA<=7)
printf("\nResultado: S");
else
if (MEDIA<9)
printf("\nResultado: P");
else
printf("\nResultado: E");
return 0;
}
- Questão 8
- Execute o código e observe o resultado
#include <stdio.h>
void main()
{
int i=0, a=10, b=1,aux=0;
while(i<10){
if (i>=9){
aux=a+b;
a=b;
}
b++;
i++;
}
aux=a+b;
printf("Valor: aux=%d i=%d b=%d ",aux, i, b);
}