GJPassos

VETORES 02

May 20th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1.  //GILMAR JUNIOR DOS PASSOS - PROF MALGARETE
  2.  //ALGORITMOS 02 CENTRO TECNOLOGICO UNIVERSIDADE POSITIVO
  3.  
  4.  #include <stdio.h>
  5.  #include <stdlib.h>
  6.  #include <math.h>
  7.  #include <iostream>
  8.  #include <conio.h>
  9.  #include <time.h>
  10.  #define controle 100
  11.  
  12. //Faça um algoritmo para gerar um vetor de 30 posições, onde cada
  13. //elemento corresponde ao quadrado de sua posição. Escreva depois o
  14. //vetor resultante.
  15.  
  16. int main()
  17. {
  18.  
  19.     float vetor[controle],quadrado[controle];
  20.     int cont;
  21.     srand(time(NULL));
  22.        
  23.     for (cont=1;cont<=controle;cont++)
  24.     {
  25.     vetor[cont] = rand() % 30;
  26.     quadrado[cont] = sqrt (vetor[cont]);
  27.     printf ("sqrt(%.0f) = %.2f\n", vetor[cont], quadrado[cont]);
  28.    
  29. }
  30. getch();
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment