fork download
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main() {
  5.  
  6. int N, M, i;
  7. int *v;
  8.  
  9. printf ("Entre com N: ");
  10. scanf ("%d", &N);
  11.  
  12. v = (int *)malloc(N * sizeof (int));
  13.  
  14. printf ("Entre com os valores do vetor (M): ");
  15. for(i=0; i<N;i++){
  16. scanf ("%d \n", &M);
  17. v[i] = M;
  18. }
  19.  
  20. for (i=0; i < N; ++i){
  21. v[i] = v[i] + 1;
  22. printf ("Vetor[%d]=%d ",i, v[i]);
  23. }
  24. }
Success #stdin #stdout 0s 2304KB
stdin
2
3
5
stdout
Entre com N: Entre com os valores do vetor (M): Vetor[0]=4 Vetor[1]=6