HOME

Start

Control Statements

Array

Function

Structure

Pointer

File

Projects

 

 

 

 

 

 

C programing

Ckalari.com is the No.1 website to get the best of C programs, free source codes, projects in c language……  

A C program to print in accending ordrer of total mark using structure

#include<stdio.h>

#include<conio.h>

struct student

{

  int regno;

  int m[3];

  int total;

  char name[30];

};

void main()

     {

    struct student s[100],temp1;

    int n,i,j;

    clrscr();

    printf("\nHow many students\n");

    scanf("%d",&n);

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

    {

      printf("\nEnter the name of student");

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

      printf("\nEnter the Regno of student\n");

      scanf("%d",&s[i].regno);

      printf("\nEnter three marks student\n");

      s[i].total=0;

      for(j=0;j<3;j++)

      {

        scanf("%d",&s[i].m[j]);

        s[i].total=s[i].m[j]+s[i].total;

      }

    }

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

      for(j=i+1;j<n;j++)

        if(s[i].total<s[j].total)

        {

          temp=s[i];      

          s[i]=s[j];

          s[j]=temp;

        }

    clrscr();

    printf("\nregno\tname\tmark\tTotal mark\n");

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

    {

      printf("\n%d\t%s\t",s[i].regno,s[i].name);

 

      for(j=0;j<3;j++)

      {                                                        

        printf("%d ",s[i].m[j]);

      }                                    

      printf("\t%d",s[i].total);

    }

    getch();

     }

Copyright © 2007-2008 www.ckalari.com