Created
January 13, 2023 23:33
-
-
Save pvpassos/60711e87dff7ee2f9708e0e4366a88d9 to your computer and use it in GitHub Desktop.
Exercício 3 - 13-01-2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main() | |
| { | |
| int i, n; | |
| printf("\nQuantos numeros?\n"); | |
| scanf("%d", &n); | |
| double *ptr = (double *) malloc(n*sizeof(double)); | |
| if (ptr == NULL) | |
| { | |
| printf("Foi mal!"); | |
| exit(1); | |
| } | |
| for (i=0; i<n; i++) | |
| { | |
| printf("\nEntre com o %do. numero, por favor:\n", i+1); | |
| scanf("%e", ptr + i); | |
| } | |
| printf("\nImprimindo os valores da entrada:\n"); | |
| for (i=0; i<n; i++) | |
| printf("%d %.1e\n", ptr+i, *(ptr+i)); | |
| // printf("%d\n", *(ptr+i)); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment