Posts

Showing posts from 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;  ...

C Programs to practice -Fahrenheit to Celsius and Celsius to Fahrenheit conversions

  Fahrenheit to Celsius conversion: This is a simple temperature conversion program. In this program ,the given temperature is in Fahrenheit. This program converts it to Celsius by using a simple formula. Program: “Fahrentocelsius.c” #include<stdio.h> #include<conio.h> void main() { /* variable declaration statement. Fa- Fahrenheit, ce- Celsius */   float fa, ce;                      printf(“ Enter the temperature value in Fahrenheit”); /* read the Fahrenheit value */ scanf(“%f”,&fa);       / * formula for converting Fahrenheit to Celsius value */ ce=(fa-32)*5/9; /* The converted celsius   value*/ printf(“The temperature value in celsius is: %f”,ce); getch(); } Try it : In the same way, you can try the Celsius to Fahrenheit conversion in   your own. Steps for converting Celsius to Fahrenheit...

How to install turbo c++ in your pc/Laptop?

C is a structured programming language. It was developed by Dennis Ritchie in AT&T bell laboratories. It is the base language of all programming language. Bcpl and B languages are the previous languages. Features: C has lot of features. ·        C is a middle level language. It supports system level functions and high level programming. ·        It is portable. The user can run in any machine. It is machine independent language. ·        It is a Structured programming language. It supports functions. ·        The compilation and execution speed is fast because it has many inbuilt functions. ·        It is extensible language.   How to  Install turbo C++?        C programming starts from installing turbo c++ compiler in your system. It has the following steps:   First, Download the ...

How to create DTD for book details in a bookstore?

DTD(Document Type Declaration) is mainly used to describe xml.  The purpose of DTD is  to check vocabulary of the xml. It also checks the validity of the structure of XML documents. It has the syntax given below. Syntax: <!DOCTYPE element DTD identifier [   Declaration 1   Declaration 2     ………………   Declaration n   ]>   It has two types listed as follows. ·        ->  Internal DTD ·        -> External DTD First, how the internal DTD is created and used in XML is shown below… Internal DTD: This type of DTD is defined inside the XML file. We can use the above syntax here. In the XML declaration, set the standalone attribute to “yes”. The sample XML code for book store is given below.   <?xml version=”1.0” encoding=”UTF-8” standalone=”yes”?> <! DOCTYPE book [ <!ELEMENT book(name,author,publisher)> <!ELEMENT   name(#PC...

How to write your first XML program?

XML is Extensible Markup Language. It is used to create user defined tags. This is derived from SGML(Standard Generalized Markup Language). Do you like to create your own tags?? If the answer is yes, you try XML. A simple XML code is given below. It is a simple birthday message for your beloved one. < Birthday>   <Wishes>  Happy birthday  </Wishes> </Birthday>     Here, the root tag is <Birthday>. <Wishes>   is the user defined tag. This basic xml program shows you to create a root tag with elements. To create a basic program, follow the below syntax. Syntax: < ?xml version=”1.0”?> <root tag>   <element1>   </element1>                     .                     .   <elem...