Answer to Question #194609 in C for Muhammad Haris

Question #194609

Write a program to take the values of two integers and use pointers to add 10 to the value of each integer. 


1
Expert's answer
2021-05-17T16:27:20-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS