Found 26504 Articles for Server Side Programming

What are the inserting elements in queue in C language?

Bhanu Priya
Updated on 20-Jun-2024 21:43:55

5K+ Views

Data structure is collection of data organized in a structured way. It is divided into two types as explained below − Linear data structure − Data is organized in a linear fashion. For example, arrays, structures, stacks, queues, linked lists. Nonlinear data structure − Data is organized in a hierarchical way. For example, Trees, graphs, sets, tables. Read Also: Data Structures and Types Queue Queue is a linear data structure, where the insertion is done at rear end ... Read More

C program to sort names in alphabetical order with string functions.

Bhanu Priya
Updated on 26-Mar-2021 06:43:54

974 Views

ProblemSort the names given by the user at runtime in an alphabetical order by using the bubble sort technique.SolutionThe logic used to print the names in alphabetical order is as follows −for (i=1; i < ITEMS; i++){    for (j=1; j 0){ /* Exchange of contents */          strcpy (dummy, string[j-1]);          strcpy (string[j-1], string[j]);          strcpy (string[j], dummy );       }    } }ExampleFollowing is the C program to sort the names in an alphabetical order by using the string functions − Live Demo#define ITEMS 5 #define MAXCHAR ... Read More

C program to calculate the standard deviation

Bhanu Priya
Updated on 25-Mar-2021 11:48:20

6K+ Views

Standard deviation is used to measure deviation of data from its mean. The mathematical formula to calculate the standard deviation is as follows −$$s=\sqrt{Variance}$$whereVariance$$=\frac{1}{n}\:\:\displaystyle\sum\limits_{i=1}^n (x_{i}-m)^{2}$$and$$m=mean=\frac{1}{n}\:\displaystyle\sum\limits_{i=1}^n x_{i}$$AlgorithmRefer an algorithm given below to calculate the standard deviation for the given numbers.Step 1 − Read n items.Step 2 − Calculate sum and mean of the items.Step 3 − Calculate variance.Step 4 − Calculate standard deviation.The logic used in the program for calculating standard deviation is as follows −for (i = 1 ; i

C program to find the median of a given list.

Bhanu Priya
Updated on 25-Mar-2021 11:39:46

19K+ Views

If the elements of the list are arranged in order, then, the middle value which divides the items into two parts with equal number of items on either side is called the median.Odd numbers of items have just one middle value whereas; even numbers of items have two middle values.The median for even number of items is therefore, designated as the average of the two middle values.AlgorithmRefer an algorithm given below to calculate the median.Step 1 − Read the items into an array while keeping a count of the items.Step 2 − Sort the items in increasing order.Step 3 − ... Read More

C Program to represent a multiplication table.

Bhanu Priya
Updated on 25-Mar-2021 11:35:48

893 Views

ProblemWrite a program to print the multiplication table from 1 x 1 to 12 x 10 as given below −1 2 3 4 5 6 7 8 9 10 2 4 6 8 ……………….20 3 6 9…………………….30 4 8 12 16……………..40 - - - 12 24……………………..120SolutionUse two do while loops in nested form to display the multiplication table.The logic used to display the multiplication table is as follows −Inner loop is controlled by the variable column and is executed 10 times, whenever each time the outer loop is executed.Outer loop is executed 12 times and controlled by variable row.do /*......OUTER LOOP BEGINS........*/{    column = 1;    do /*.......INNER LOOP BEGINS.......*/{       y = row * column;       printf("%4d", y);       column = column + 1;    }    while (column

C program to calculate range of values and an average cost of a personal system.

Bhanu Priya
Updated on 25-Mar-2021 11:31:49

729 Views

ProblemA personal system is sold at different costs by the vendors.Let’s take the list of costs (in hundreds) quoted by some vendors −25.00, 30.50, 15.00, 28.25, 58.15, 37.00, 16.65, 42.00 68.45, 53.50SolutionCalculate the average cost and range of values.The difference between the highest and the lowest values in the series is called range Hence, Range = highest value - lowest value.Now, find the highest and the lowest values in the series.ExampleFollowing is the C program to calculate the range of values and average cost of a personal system − Live Demo#include main(){    int count;    float value, high, low, sum, ... Read More

C program to print characters and strings in different formats.

Bhanu Priya
Updated on 25-Mar-2021 11:22:17

16K+ Views

An algorithm is given below to explain the process which is included in the C programming language to print the characters and strings in different formats.Step 1: Read a character to print.Step 2: Read a name at compile time.Step 3: Output of characters in different formats by using format specifiers.printf("%c%3c%5c", x, x, x);printf("%3c%c", x, x);printf("");Step 4: Output of strings in different formats by using format specifiers.printf("%s", name);printf("%20s", name);printf("%20.10s", name);printf("%.5s", name);printf("%-20.10s", name);printf("%5s", name);ExampleFollowing is the C program to print the characters and strings in different formats − Live Demo#include main(){    char x = 'T';    static char name[20] = "Tutorials Point"; ... Read More

C Program to calculate the salesmen salary with macro functions.

Bhanu Priya
Updated on 25-Mar-2021 11:18:21

2K+ Views

ProblemA laptop manufacturing company has the monthly compensation policy for their salespersons as mentioned below −Minimum base salary: 3000.00Bonus for every computer sold: 200.00Commission on the total monthly sales: 5 per centSince the prices of laptops are changing, the sales price of each laptop is fixed at the beginning of every month.SolutionThe logic for finding the bonus and commission is as follows −bonus = BONUS_RATE * quantity ; commission = COMMISSION * quantity * price ;The gross salary is calculated by using the formula given below −Gross salary = basic salary + (quantity * bonus rate) + (quantity * Price) ... Read More

C program to find out cosine and sine values using math.h library.

Bhanu Priya
Updated on 25-Mar-2021 11:15:44

6K+ Views

ProblemTo find the cosine and sine values for every 10 degrees from 0 to 150.SolutionThe logic used to find the cosine values is as follows −Declare MAX and PI value at the starting of a programwhile(angle

How to multiply two matrices using pointers in C?

Bhanu Priya
Updated on 25-Mar-2021 11:11:05

14K+ Views

Pointer is a variable that stores the address of another variable.Features of PointersPointer saves the memory space.The execution time of a pointer is faster because of the direct access to a memory location.With the help of pointers, the memory is accessed efficiently i.e. memory is allocated and deallocated dynamically.Pointers are used with data structures.Pointer declaration, initialization and accessingConsider the following statement −int qty = 179;In the memory, the variable can be represented as shown below −DeclarationDeclaring a pointer can be done as shown below −Int *p;It means ‘p’ is a pointer variable which holds the address of another integer variable.InitializationThe ... Read More

Advertisements