Skip to content

Instantly share code, notes, and snippets.

@pvpassos
Created January 13, 2023 23:33
Show Gist options
  • Select an option

  • Save pvpassos/60711e87dff7ee2f9708e0e4366a88d9 to your computer and use it in GitHub Desktop.

Select an option

Save pvpassos/60711e87dff7ee2f9708e0e4366a88d9 to your computer and use it in GitHub Desktop.
Exercício 3 - 13-01-2023
#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