[ create a new paste ] login | about

Link: http://codepad.org/hXMzQkva    [ raw code | output | fork ]

C, pasted on Apr 15:
*/
#include <stdio.h>
main()
{

int sel[10], i, j, k;

//função para indicar se um número é par
int eh_par(int n) {

if( (n%2) == 0 )
return 1;

else
return 0;

}

//função para imprimir os números selecionados
void imprime_sel() {

printf(&quot;Numeros selecionados:\n&quot;);
for (i = 0;i < 10; i++)

printf(&quot;%i\n&quot;,sel[i]);
}

//função para imprimir a soma solicitada
void imprime_soma_sel() {

int soma = 0;
printf(&quot;Soma dos numeros selecionados:\n&quot;);
for (i = 0; i<10;i++)

soma = soma + sel[i];
printf(&quot;%i\n&quot;,soma);

}

k = 0;
for(j=1;j<=100;j++) {

if (eh_par(j)==1){
sel[k] = j;
k++;
if (k==10)

break;
}

}

imprime_sel();
printf(&quot;\n&quot;);
imprime_soma_sel();

}


Output:
1
2
3
4
5
6
Line 1: error: expected identifier or '(' before '/' token
Line 22: error: stray '\' in program
Line 25: error: stray '\' in program
Line 32: error: stray '\' in program
Line 36: error: stray '\' in program
Line 54: error: stray '\' in program


Create a new paste based on this one


Comments: