Write a program to take the values of two integers and use pointers to add 10 to the value of each integer.
#include <stdio.h>
int main()
{
int a, b;
int* ptrA = &a;
int* ptrB = &b;
printf("Enter 2 integers: ");
if(scanf("%d %d", ptrA, ptrB) != 2)
{
printf("Bad input\n");
return 1;
}
*ptrA += 10;
*ptrB += 10;
printf("Result values: %d %d\n", *ptrA, *ptrB);
return 0;
}
Comments
Leave a comment