Code Scrappers


Structure - C program


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

                    struct stud
                    {
                        char name[50];

                        int roll;

                        char dept[50];

                        int marks;

                        char grade;


                    }str[10];

                    void main()

                    {
                    	int r, i, n;

                    	printf("Enter the no. of students:\n");

                    	scanf("%d",&n);

                    	for(i=0;i<n;i++)
                    	{
                    		  printf("Enter student's name, rollnumber, department, marks & grade :\n");

                          scanf("%s%d%s%d %c", str[i].name, &str[i].roll, str[i].dept, &str[i].marks, &str[i].grade);
                    	}

                    	printf("\nThe details are: \n");

                    	printf("\nName\t\tRollno\t\tDept\t\tMarks\t\tGrade\n");

                    	for(i=0;i<n;i++)

                    	{
                    		  printf("%s\t%d\t\t%s\t\t%d\t\t%c\n", str[i].name, str[i].roll, str[i].dept, str[i].marks, str[i].grade);
                    	}

                    	for(i=0;i<n;i++)
                    	{

                    		  if(r == str[i].roll)
                    		  {
                    			     printf("\nName\t\tRollno\t\tDept\t\tMarks\t\tGrade\n");

                    			     printf("%s\t%d\t\t%s\t\t%f\t\t%c\n", str[i].name, str[i].roll, str[i].dept, str[i].marks, str[i].grade);
                      	   }
                    	}

                    }
                



Output

            Enter the number of students:
            2

            Enter student's Name, Rollnumber, Department, Marks, Grade :
            Sheshank
            1452
            ECE
            88
            A

            Enter student's Name, Rollnumber, Department, Marks, Grade :
            Saarthak
            1745
            CSE
            85
            A

            Student details are

            Name            Rollno          Dept            Marks           Grade
            Sheshank        1452            ECE             88              A
            Saarthak        1745            CSE             85              A