Posts

Showing posts from December, 2022

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>     ...

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) { ...

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 cha...

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, t ry 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)?...

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” ...

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;  ...