Paisen

norma_vec_escalar

Sep 27th, 2020
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. /*7) Dado un arreglo llamado vector(Vn) con n componentes,
  2.  realizar los siguiente: Norma del vector y mult. por escalar*/
  3.  
  4. #include<stdio.h>
  5. #include<stdlib.h>
  6. #include<math.h>
  7.  
  8. int A,E,i,z,q,r,B[50];
  9. double norm;
  10.  
  11. int main(){
  12.    
  13.     printf("Define el tamaño de tu vector:\n");
  14.     scanf("%d",&A);
  15.    
  16.     printf("Introduce un vector\n");
  17. for(i<0;i<A; i++){
  18.     printf("Introduce la cordenada de V%d\n",i+1);
  19.     scanf("%d",&B[i]);
  20. }
  21.     printf("\nIntroduce un escalar\n");
  22.     scanf("%d",&E);
  23.  
  24. for(z=0; z<i; z++){
  25.     q=B[z]*B[z];
  26.     r=r+q;
  27. }
  28. norm=sqrt(r);
  29.     printf("La norma de este vector es de: %lf\n",norm);
  30.  
  31.     printf("El vector por el escalar %d, es:", E);
  32. for(z=0; z<i; z++){
  33.     printf("  %d  ",B[z]*E);
  34. }
  35.    
  36.     printf("\n\n");
  37.     system("pause");
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment