Mudanças entre as edições de "PRG29002-2015-2-Aval1A"
Ir para navegação
Ir para pesquisar
Linha 108: | Linha 108: | ||
soma=______ | soma=______ | ||
+ | |||
+ | =Questão 5= | ||
+ | |||
+ | <syntaxhighlight lang=c> | ||
+ | /* indicar o valor impresso das variáveis */ | ||
+ | #include <stdio.h> | ||
+ | |||
+ | main () | ||
+ | { | ||
+ | int i,x,soma=0; | ||
+ | |||
+ | for (x=0,i=0;i<5;i++) { | ||
+ | switch(i) { | ||
+ | case 2: | ||
+ | soma += i; | ||
+ | break; | ||
+ | case 1: | ||
+ | i++; | ||
+ | case 4: | ||
+ | soma = i++; | ||
+ | default: | ||
+ | soma=0; | ||
+ | break; | ||
+ | } | ||
+ | x = x + i; | ||
+ | } | ||
+ | printf("Valor de soma = %d x=%d\n", soma,x); | ||
+ | } | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | |||
+ | x=_____ | ||
+ | |||
+ | soma=_______ | ||
+ | |||
+ | =Questão 6= | ||
+ | |||
+ | <syntaxhighlight lang=c> | ||
+ | /* indicar o valor impresso das variáveis */ | ||
+ | #include <stdio.h> | ||
+ | |||
+ | main () | ||
+ | { | ||
+ | int i,j,soma=10; | ||
+ | |||
+ | for (i=0;i<2;i++) { | ||
+ | j=1; | ||
+ | while(j<3) { | ||
+ | soma = soma + 1; | ||
+ | j++; | ||
+ | if(j==2) break; | ||
+ | } | ||
+ | } | ||
+ | printf("Valor de soma = %d\n", soma); | ||
+ | } | ||
+ | |||
+ | </syntaxhighlight> |
Edição das 22h50min de 17 de novembro de 2015
Nome:_____________________________________________
Questão 1
#include <stdio.h>
main ()
{
int x,y,z;
x=2;
y=6;
y=y%x;
z = ( ( x-1 || y>5 ) && !0 ) * 10;
printf ("z=%d\n",z);
}
Z = ______
Questão 2
#include <stdio.h>
main ()
{
int x,y;
x=8;
y=2;
if (x>5 && !(y==1)){
y=x+y;
x++;
if (x>30) y++;
else y--;
y=y+5;
if (y>2) {
if (y==0)
x=0;
else
x=9;
x=x+1;
}
x=x*3;
} else {
y=y*2;
x=y+1;
}
printf("x= %d e y=%d\n",x,y);
}
X=____
y=____
Questão 3
/* indicar o valor impresso das variáveis */
#include <stdio.h>
main ()
{
int i,soma=0;
for (i=4;i>0;i=i-1)
soma = soma + i;
printf("Valor de soma = %d e i= %d\n", soma,i);
}
i=_____
soma=_______
Questão 4
/* indicar o valor impresso das variáveis */
#include <stdio.h>
main ()
{
int i,j,x=1,soma=1;
for (i=0;i<2;i++) {
for (j=0;j<3;j++)
x=j+i;
soma = soma + i;
}
printf("Valor de soma = %d x=%d i=%d j=%d\n", soma,x,i,j);
}
x=_____
soma=______
Questão 5
/* indicar o valor impresso das variáveis */
#include <stdio.h>
main ()
{
int i,x,soma=0;
for (x=0,i=0;i<5;i++) {
switch(i) {
case 2:
soma += i;
break;
case 1:
i++;
case 4:
soma = i++;
default:
soma=0;
break;
}
x = x + i;
}
printf("Valor de soma = %d x=%d\n", soma,x);
}
x=_____
soma=_______
Questão 6
/* indicar o valor impresso das variáveis */
#include <stdio.h>
main ()
{
int i,j,soma=10;
for (i=0;i<2;i++) {
j=1;
while(j<3) {
soma = soma + 1;
j++;
if(j==2) break;
}
}
printf("Valor de soma = %d\n", soma);
}