Write a C program that defines and declares a pointer to a s

Write a C program that defines and declares a pointer to a structure containing three integer members. Then prompts the user to enter three integers that the program will store in the structure using the pointer variable. Also, displays the integers on the screen using the pointer variable.

Solution

#include<stdio.h>

typedef struct ex

{

int a;

int b;

int c;

};

int main()

{

printf(\"enter 3 integers :\");

struct ex *ptr;

scanf(\"%d%d%d\",&(*ptr).a,&(*ptr).b,&(*ptr).c);

printf(\" 3 integers are :%d %d %d\",(*ptr).a,(*ptr).b,(*ptr).c);

return 0;

}

Write a C program that defines and declares a pointer to a structure containing three integer members. Then prompts the user to enter three integers that the pr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site