Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GILMAR JUNIOR DOS PASSOS - PROF MALGARETE
- //ALGORITMOS 02 CENTRO TECNOLOGICO UNIVERSIDADE POSITIVO
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <iostream>
- #include <conio.h>
- #include <time.h>
- #define controle 100
- //Faça um algoritmo para gerar um vetor de 30 posições, onde cada
- //elemento corresponde ao quadrado de sua posição. Escreva depois o
- //vetor resultante.
- int main()
- {
- float vetor[controle],quadrado[controle];
- int cont;
- srand(time(NULL));
- for (cont=1;cont<=controle;cont++)
- {
- vetor[cont] = rand() % 30;
- quadrado[cont] = sqrt (vetor[cont]);
- printf ("sqrt(%.0f) = %.2f\n", vetor[cont], quadrado[cont]);
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment