Mudanças entre as edições de "Exercícios Preparação para Avaliação I"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
(Criou página com 'Exercício 1 <syntaxhighlight lang=c> →‎indicar o valor impresso das variáveis: #include <stdio.h> main () { int x,y,z; x = !( 5 || 0 ); printf ("x=%d\n",x); y = !( 1 ||...')
 
Linha 35: Linha 35:
 
   printf ("z=%d\n",z);  
 
   printf ("z=%d\n",z);  
 
}
 
}
<code>
+
</syntaxhighlight>
  
 
Exercício 3
 
Exercício 3
Linha 55: Linha 55:
 
}
 
}
  
<code>
+
</syntaxhighlight>
 +
 
 +
Exercício 4
 +
 
 +
<syntaxhighlight lang=c>
 +
/* indicar o valor impresso das variáveis */
 +
#include <stdio.h>
 +
 +
main ()
 +
{
 +
int x;
 +
float w,y;
 +
 
 +
x=90000;
 +
w=x/2;
 +
y=y/2.0;
 +
printf("Valor de w=%.2f e y=%.2f\n",w,y);
 +
}
 +
</syntaxhighlight>
 +
 
 +
Exercício  5
 +
 
 +
<syntaxhighlight lang=c>
 +
#include <stdio.h>
 +
 +
main ()
 +
{
 +
int x;
 +
float w,y,z,v;
 +
 
 +
 +
x=5;
 +
w=2.5;
 +
y=(x*10)+(w>1)*2*x;
 +
z=(x*10)+(w>1*5*x);
 +
v=x*10+w>1*5*x;
 +
printf("w=%.2f y=%.2f z=%.2f v=%.2f \n",w,y,z, v);
 +
}
 +
</syntaxhighlight>
 +
 
 +
Exercício  6
 +
 
 +
<syntaxhighlight lang=c>
 +
#include <stdio.h>
 +
 +
main ()
 +
{
 +
int x,y;
 +
 
 +
x=5;
 +
y=0;
 +
if (x==5)
 +
    y=x+1;
 +
else
 +
    y=y-x;
 +
printf("x=%d e y=%d\n",x,y);
 +
}
 +
</syntaxhighlight>
 +
 
 +
Exercício  7
 +
 
 +
<syntaxhighlight lang=c>
 +
#include <stdio.h>
 +
 +
main ()
 +
{
 +
int x,y;
 +
 
 +
x=5;
 +
y=0;
 +
if (x==5) y=x+2; else y=x-y;
 +
printf("x= %d e y=%d\n",x,y);
 +
}
 +
 
 +
</syntaxhighlight>
 +
 
 +
Exercício  8
 +
 
 +
<syntaxhighlight lang=c>
 +
#include <stdio.h>
 +
 +
main ()
 +
{
 +
int x,y;
 +
 
 +
x=5;
 +
y=0;
 +
if (x=0)
 +
    y=x+y;
 +
else
 +
    y=x+2;
 +
printf("x= %d e y=%d\n",x,y);
 +
}
 +
 
 +
</syntaxhighlight>
 +
 
 +
Exercício  9
 +
 
 +
<syntaxhighlight lang=c>
 +
#include <stdio.h>
 +
 +
main ()
 +
{
 +
int x,y;
 +
 
 +
x=1;
 +
y=0;
 +
if (x>=1); { y=x+y;    x++;  }
 +
printf("x= %d e y=%d\n",x,y);
 +
}
 +
</syntaxhighlight>

Edição das 08h30min de 4 de novembro de 2015

Exercício 1

/* indicar o valor impresso das variáveis */
#include <stdio.h>
 
main ()
{
  int x,y,z;

  x = !( 5 || 0 );   
  printf ("x=%d\n",x);      
  y = !( 1 || 0 && 0 );
  printf ("y=%d\n",y);     
  z = !( ( 20 || 0 ) && 0 );
  printf ("z=%d\n",z); 
}

Exercício 2

/* indicar o valor impresso das variáveis */
#include <stdio.h>
 
main ()
{
  int x,y,z;
     
  x=10;
  y=6;
  printf("x=%d\n y=%d\n", x, y=!y);
  y=x+y+5;
  z = ( ( x-6 && y>5 ) || !0 ) * 50;
  printf ("z=%d\n",z); 
}

Exercício 3

/* indicar o valor impresso das variáveis */
#include <stdio.h>
 
main ()
{
  int x,y,z;
     
  x=10;
  y=6;
  printf("x=%d\n y=%d\n", x, y=y==x);
  y=x+y+5;
  z = ( ( x<=y && y>!(x=9) ) || z ) * x;
  printf ("z=%d\n",z); 
}

Exercício 4

/* indicar o valor impresso das variáveis */
#include <stdio.h>
 
main ()
{
 int x;
 float w,y;

 x=90000;
 w=x/2;
 y=y/2.0;
 printf("Valor de w=%.2f e y=%.2f\n",w,y);
}

Exercício 5

#include <stdio.h>
 
main ()
{
 int x;
 float w,y,z,v;

 
 x=5;
 w=2.5;
 y=(x*10)+(w>1)*2*x;
 z=(x*10)+(w>1*5*x);
 v=x*10+w>1*5*x;
 printf("w=%.2f y=%.2f z=%.2f v=%.2f \n",w,y,z, v);
}

Exercício 6

#include <stdio.h>
 
main ()
{
 int x,y;

 x=5;
 y=0;
 if (x==5)
    y=x+1;
 else
    y=y-x;
 printf("x=%d e y=%d\n",x,y);
}

Exercício 7

#include <stdio.h>
 
main ()
{
 int x,y;

 x=5;
 y=0;
 if (x==5) y=x+2; else y=x-y;
 printf("x= %d e y=%d\n",x,y);
}

Exercício 8

#include <stdio.h>
 
main ()
{
 int x,y;

 x=5;
 y=0;
 if (x=0) 
     y=x+y; 
 else 
     y=x+2;
 printf("x= %d e y=%d\n",x,y);
}

Exercício 9

#include <stdio.h>
 
main ()
{
 int x,y;

 x=1;
 y=0;
 if (x>=1); { y=x+y;     x++;  }
 printf("x= %d e y=%d\n",x,y);
}