May 28, 2021

C program to display user details using id

EX: Write a C program to display user details using id. How to  write a C program to display user details. C program to display student details using their id.


We use switch case in this program to print user details....


Program:


#include<stdio.h>

int main()
{
    int id;
    //Accept id from user
    printf("Enter your id: ");
    scanf("%d",&id);
    //Switch the value of id
    switch(id) {
        //Match id with cases
        case 11:
        printf("Information of id %d is:\n",id);
        printf("Name: Omkar Lokhande\nContact: 123456***\nAdd: kalamb");
        break;

        case 12:
        printf("Information of id %d is:\n",id);
        printf("Name: Akash Sutar\nContact: 1234***\nAdd: kalamb");
        break;

        case 13:
        printf("Information of id %d is:\n",id);
        printf("Name: Rusty Shackleford \nContact: 12456***\nAdd: California");
        break;

        default:
        printf("Please Enter Valid Id");   
    }
    return 0;
}
Above program will show the following output:

Enter your id: 13
Information of id 13 is:
Name: Rusty shackleford
Contact: 123456***
Add: California


Share This:    Facebook Twitter

0 comments:

Post a Comment

If you have any doubts, please discuss here...