How to create XML file for employee management system and display it using CSS?

    Employees are working for many organizations. For maintaining the details,we need to collect the name,employee id,designation and salary details.

Here,  we use CSS(Cascading Style sheets) to display XML files. For doing this,we need to open any text editor like notepad.

Create two files  and name that as “employee.xml” and “employee.css”

Add the following code.

employee.xml

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/css" href="employee.css"?>

<payroll>

  <Heading> Welcome to the Employee management system </Heading>

     <employee>

          <name> adhav </name>

           <id> Emp01  </id>

           <Designation> Executive </Designation>

          <salary > 35000 </salary>

      </employee>

<employee>

          <name> chitra </name>

           <id> Emp02  </id>

           <Designation> Executive </Designation>

          <salary > 36,500 </salary>

      </employee>

<employee>

          <name> chandar </name>

           <id> Emp03 </id>

           <Designation> Senior Executive </Designation>

          <salary > 45000 </salary>

      </employee>

<employee>

          <name> Deepan </name>

           <id> Emp04  </id>

           <Designation> Executive </Designation>

          <salary > 36500 </salary>

      </employee>

<employee>

          <name> varun </name>

           <id> Emp05  </id>

           <Designation> Manager </Designation>

          <salary > 55000 </salary>

  </employee>

</payroll>


”employee.css”

employee{

                 background-color: yellow;

                  Width:100%;

               }

Heading {

                 color : black;

                 font-size : 35pt;

                 background-color : skyblue;

                }

Heading,name,id,Designation,salary {

                display : block;

                 }

name {

          color: brown;

          font-weight: BOLD;

          font-size: 25pt;

     }

 

Once you have saved this two files in same folder in same directory, just open the xml file in web browser.

You will get the output like this……

Welcome to the Employee management system

Adhav

Emp01

Executive

35000

Chitra

Emp02

Executive

36500

Chandar

Emp03

Senior Executive

45000

Deepan

Emp04

Executive

36500

Varun

Emp05

Manager

55000


Thus, the way to display xml file using css is easily  implemented.

  


C programs to practice -Find the factorial of given number by recursion

     Factorial is the continuous multiplication of the number from 1,2,…upto the number. Using recursion concept, this can be achieved easily.

Program :”factrec.c”

#include<stdio.h>

#include<conio.h>

int factorial(int n)

{

if (n<=1)

 return(1);

else

 return(n*factorial(n-1));

}

void main()

{

 int  n,fact=0;

printf(“ Enter the number”);

scanf(“%d”,&n);

fact= factorial(n);

printf(“The factorial of %d is : %d”,n,fact);

getch();

}

 

Output:

Enter the number 5

The factorial of 5 is 120

 

Now,let us try some interesting number series called Fibonacci series….

First,get the number of elements for the series as ‘n’. 

Using a loop, repeat the process until the number reaches to n.

Add the last two number and print the number.

Once the loop is finished, close the program.

Now, the program begins….

“Fibonacci.c”

#include <stdio.h>

int fibonacci(int x)

{

  if (x==0) { return(0); }

  else if(x==1) { return( 1);}

 return fibonacci(x-1)+fibonacci(x-2);

}

void main()

{

  int n,x;

  printf("Enter the number of elements");

  scanf("%d",&n);

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

  {

   printf("%d \t \n" ,fibonacci(x);

  }

  getch();

}


the output is given below....

Enter the number of elements  7

0

1

1

2

3

5

8



C Programs to practice- Sum of the digits and count the number of digits in a number

 To find the sum of the digits of a given number, follow the steps given below.

Get the input as integer.

Check whether the number is greater than zero, repeat the below steps.

Use modulation operator, separate the digit and store it to a variable

Add the variable value to sum.

Divide the number by 10

Finally, print the sum value.

 The program begins....

Program: sum.c

#include<stdio.h>

#include<conio.h>

void main()

{

 int a,sum=0,n;

 printf("Enter the number");

 scanf("%d",&a);

 while(a>0)

 {

  n=a%10;

  sum=sum+n;

  a=a/10;

 }

 printf("The sum of the digit is:%d",sum);

 getch();

 }

 

 Output :

 Enter the number 456

The sum of the digit is: 15

Try this:

How to count the number of digits in the given number.

Tip: Use the same logic(sum of the digit) with simple change.

Think about it.

 

Program: “Count.c”

#include<stdio.h>

#include<conio.h>

void main()

{

 int a,count=0,n;

 printf("Enter the number");

 scanf("%d",&a);

 while(a>0)

 {

  n=a%10;

  count++;

  a=a/10;

 }

 printf("The number of the digit is:%d",count);

 getch();

 }

The output is shown below....

Enter the number 234

The number of the digit is: 3


C programs to practice - To check the given number is odd or even by using conditional operator

 First, let us know the logic behind this problem. To check the given number is odd or even,just  use %(modulation) operator. It will give you the reminder.

 If the reminder is zero,it is even number. Otherwise, the given number is odd number.

Now, the coding snippet begins....

Program “oddoreven.c”

#include<stdio.h>

#include<conio.h>

void main()

{

int a;

printf(“Enter the number”);

scanf(“%d”,&a);

(a%2==0)? printf(“Given number is even”): printf(“Given number is odd”);

getch();

}

 

Output:

 Enter the number 5

Given number is odd


Now, try this....

 Write a c program to find which number is greater among the given two numbers using conditional operator.

Program: “great2.c”

#include <stdio.h>

#include<conio.h>

void main()

{

 int c,d;

 printf("enter the two numbers");

 scanf("%d %d",&c,&d);

 (c>d)? printf("c is greater than d"): printf("d is greater than c");

 getch();

 }

C Programs to practice- Find the sum of the digits of a given number

 

To find the sum of the digits of a given number, follow the steps given below.

  • Get the input as integer.
  • Check whether the number is greater than zero, repeat the below steps.
  • Use modulation operator, separate the digit and store it to a variable
  • Add the variable value to sum.
  • Divide the number by 10
  • Finally, print the sum value.

The program is given below....

Program: sum.c

#include<stdio.h>

#include<conio.h>

void main()

{

 int a,sum=0,n;

 printf("Enter the number");

 scanf("%d",&a);

 while(a>0)

 {

  n=a%10;

  sum=sum+n;

  a=a/10;

 }

 printf("The sum of the digit is:%d",sum);

 getch();

 }

 

 Output : 

Enter the number 567

The sum of the digit is: 18


Try this:

How to count the number of digits in the given number.

Tip: Use the same logic(sum of the digit) with simple change.

Think about it.

 

Program: “Count.c”

#include<stdio.h>

#include<conio.h>

void main()

{

 int a,count=0,n;

 printf("Enter the number");

 scanf("%d",&a);

 while(a>0)

 {

  n=a%10;

  count++;

  a=a/10;

 }

 printf("The number of the digit is:%d",count);

 getch();

 }

C Programs to practice - Biggest of three numbers


  This program is used to find the biggest number among three number. The program reads 3 numbers and check each number and find the biggest number.

Program: “Big3.c”

#include<stdio.h>

#include<conio.h>

void main()

{

 int a,b,c;

 printf("Enter the three numbers");

 scanf("%d %d %d",&a,&b,&c);

 if(a>b && a>c)

  printf("%d is the biggest number",a);

  else if(b>c)

   printf(" %d is the biggest number",b);

   else

   printf("%d is the biggest number",c);

   getch();

}

Output:

Enter the three numbers 2 3 5

5 is the biggest number


Try:

Write a c program to exchange two numbers.

How to do it???

Still thinking…

Here is the program

#include<stdio.h>

#include<conio.h>

void main()

{

 int x,y;

 printf("enter the numbers");

 scanf("%d %d",&x,&y);

 x=x+y;

 y=x-y;

 x=x-y;

 printf("The two numbers after exchange");

 printf("%d %d",x,y);

 getch();

 }