Taking mobile details from user in Union || Unions || C programming
In this, we are going to print Mobile Details by taking User input using Unions with help of C Programming Language.
 

#include <stdio.h>
union phone
{
    char name[30];
    int price;
};
int main()
{
    union phone nokia, lenovo;
    printf("Enter Nokia Mobile's name and price \n");
    scanf("%s", &nokia.name);
    scanf("%d", &nokia.price);
    printf("Enter Lenovo Mobile's name and price \n");
    scanf("%s", &lenovo.name);
    scanf("%d", &lenovo.name);
    printf("%s %d", nokia.name, nokia.price);
    printf("%s %d", lenovo.name, lenovo.price);
    return 0;
}

//.........Coded by ARADHANA MISHRA

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post