Write a program to sort a list of strings in alphabetical order, using an array of pointers. 10m Jun2006
#include<stdio.h>
void main()
{
char *T;
int I,J,K;
char *ARRAY[5]={“SUNIL”,”ANIL”,”DILIP”,”JAY”,”BHARAT”};
clrscr();
for(I=0;I<5;I++)
{
printf(“%s \t”,ARRAY[I]);
}
printf(“\n”);
for(I=0;I<4;I++)
{
for(J=0;J<4-I;J++)
{
K=strcmp(ARRAY[J],ARRAY[J+1]);
if(K>0)
{
T=ARRAY[J];
ARRAY[J]=ARRAY[J+1];
ARRAY[J+1]=T;
}
}
}
for(I=0;I<5;I++)
{
printf(“%s \t”,ARRAY[I]);
}
getch();
}
[codesyntax lang=”c”]
#include<stdio.h> void main() { char *T; int I,J,K; char *ARRAY[5]={"SUNIL","ANIL","DILIP","JAY","BHARAT"}; clrscr(); for(I=0;I<5;I++) { printf("%s \t",ARRAY[I]); } printf("\n"); for(I=0;I<4;I++) { for(J=0;J<4-I;J++) { K=strcmp(ARRAY[J],ARRAY[J+1]); if(K>0) { T=ARRAY[J]; ARRAY[J]=ARRAY[J+1]; ARRAY[J+1]=T; } } } for(I=0;I<5;I++) { printf("%s \t",ARRAY[I]); } getch(); }
[/codesyntax]
Screen Shots:-
Write a program, using ‘structures’, to calculate the gross salary and net salary, if the details of an employee along with the basic, pay, attendance and deductions are given as input.10m Jun2006
Solved program can be found on this link http://cssimplified.com/assignments/an-interactive-c-program-to-generate-pay-slips-for-the-staff-of-size-12-employees-2-members-are-clerks-one-computer-operator-6-salesmen-3-helpers-working-in-a-small-chemist-retail-shop