C Programming Tutorial

 
 
 
 
#include <stdio.h>
#include <conio.h>

void main( )
{
    struct emp
    {
        char empid[7] ;
        char name[25] ;
        int age ;
        float sal ;
    } ;

    int i, j ;
    struct emp e[5] ;
    char id[5][7], temp[7] ;
    float ff ( float ) ;

    clrscr( ) ;
    printf ( \"Enter empid, name, age and salary :-\\n\") ;
    for ( i = 0 ; i <= 4 ; i++ )
    {
        scanf ( \"%s %s %d %f\", e[i].empid, e[i].name, &e[i].age, &e[i].sal ) ;
        strcpy ( id[i], e[i].empid ) ;
    }

    for ( i = 0 ; i <= 3 ; i++ )
    {
        for ( j = 0 ; j <= 3 - i ; j++ )
        {
            if ( strcmp ( id[j], id[j + 1] ) > 0 )
            {
                strcpy ( temp, id[j] ) ;
                strcpy ( id[j], id[j + 1] ) ;
                strcpy ( id[j + 1], temp ) ;
            }
        }
    }

    printf ( \"\\nRecords after sorting\") ;
    printf ( \"\\nName, age and salary after sorting :-\\n\") ;
    for ( i = 0 ; i <= 4 ; i++ )
    {
        for ( j = 0 ; j <= 4 ; j++ )
        {
            if ( strcmp( id[i], e[j].empid ) == 0 )
                printf ( \"%s %s %d %f\\n\", e[j].empid, e[j].name, e[j].age, e[j].sal ) ;
        }
    }

    getch( ) ;
}

float ff ( float f )
{
    float *f1 = &f ;
    return *f1 ;
}

    Related Post:
  1. Program to find volume of sphere

  2. Program to find whether the given number is a palindrome number or not

  3. PROGRAM TO FIND SUM OF ALL INTEGER WHICH IS &gt; 100 AND&lt; 200 AND WHICH IS DIVISIBLE BY 7

  4. Example 2 of structure

  5. Program of matrix transpose and matrix multiplication

  6. A shopkeeper wants to have a general program for his personal computer that will prepare bills for each customer as and when he sells goods of them

  7. Program to do sum of the elements of the array by loop splitting and each process adds its partial sum to the final sum

  8. program to read the price of an item in decimal form and print the output in paisa

  9. PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBORD SUM =12-32+52-72+.....

  10. Simple program to assign values to many variables in one line

  11. Program that accepts a string in an array and prints the reverse of the string

  12. Memory allocation with malloc

  13. Implement a multi-access threaded queue with multiple threads inserting and multiple threads extracting from the queue

  14. Use of continue statement

  15. Write a function to print following : e.g. space paces acesp cespa espac

  16. Program to calculate bonus, commission and gross salary as per description formula

  17. Program to merge and display 2 files

  18. Basic GAUSS ELIMINATION METHOD, GAUSS ELIMINATION WITH PIVOTING, GAUSS JACOBI METHOD, GAUSS SEIDEL METHOD

  19. PROGRAM TO READ AGE OF N PERSONS AND DISPLAY ONLY THOSE PERSONS WHOSE BETWEEN 50 AND 60

  20. PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBOARD. 1 + 2 + 6 + 24 + 120 + ......

 
 
Didn't find what you were looking for? Find more on Sorting of a structure on names using bubble sort