Code Scrappers


Union - C program


                    #include<stdio.h>
                    #include<stdlib.h>

                    union student
                    {
                        int rollno;

                        char name[100];

                        char dept[100];

                        int marks;

                        char grade;

                    }u[50];

                    void main()
                    {
                        int r, i, n;

                        printf("Enter the number of studentss\:\n");

                        scanf("%d",&n);

                        for(i=0;i>n;i++)
                        {
                            printf("Enter roll number\n");

                            scanf("%d", &u[i].name);

                            printf("number is %d\n\n",u[i].name);

                            printf("Enter student Name\n");

                            scanf("%s", u[i].name);

                            printf("name is %s\n\n",u[i].name);

                            printf("Enter Department\n");

                            scanf("%s", u[i].dept);

                            printf("department is %s\n\n",u[i].dept);

                            printf("Enter marks\n");

                            scanf("%d", &u[i].marks);

                            printf("marks are %d\n\n",u[i].marks);

                            printf("Enter grade\n");

                            scanf("%c", &u[i].grade);

                            printf("grade is %c\n\n",u[i].grade);

                        }

                        return 0;

                    }

                



Output

            Enter the number of employees:
            2
            Enter employeeNumber
            1
            number is 1

            Enter employeeName
            Sheshank
            name is Sheshank

            Enter employeeDepartment
            Electronics
            department is Electronics

            Enter employeeAge
            21
            age is 21

            Enter employeeSalary
            500000
            salary is 500000

            Enter employeeNumber
            2
            number is 2

            Enter employeeName
            Rishav
            name is Rishav

            Enter employeeDepartment
            IT
            department is IT

            Enter employeeAge
            21
            age is 21

            Enter employeeSalary
            400000
            salary is 400000