c conversions arrys pointers code example
Example 1: how to print a pointer array in c
#include <stdio.h>
int main() {
int data[5];
printf("Enter elements: ");
for (int i = 0; i < 5; ++i)
scanf("%d", data + i);
printf("You entered: \n");
for (int i = 0; i < 5; ++i)
printf("%d\n", *(data + i));
return 0;
}
Example 2: how to use a pointer as a parameter in c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void add(int* a, int* b, int* c)
{
*c = *a + *b;
}
int main()
{
int a, b, c;
a = 3;
b = 5;
add(&a, &b, &c);
printf("%d", c);
}