Found 26504 Articles for Server Side Programming

C program to sort an array of ten elements in an ascending order

Bhanu Priya
Updated on 15-Mar-2021 09:53:00

17K+ Views

An array is a group of related data items that are stored with single name.For example, int student[30];Here, student is an array name which holds 30 collection of data items, with a single variable name.OperationsThe operations of an array are explained below −Searching − It is used to find whether a particular element is present or not.Sorting − Helps in arranging the elements in an array either in ascending or descending order.Traversing − Processing every element in an array, sequentially.Inserting − Helps in inserting the elements in an array.Deleting − Helps in deleting an element in an array.In this program, ... Read More

C program to find if the given number is perfect number or not

Bhanu Priya
Updated on 15-Mar-2021 09:50:23

6K+ Views

Perfect number is the number; whose sum of factors is equal to 2*number.AlgorithmAn algorithm is explained below −START Step 1: declare int variables and initialized result=0. Step 2: read number at runtime. Step 3: for loop i=1;i

Explain the characteristics and operations of arrays in C language

Bhanu Priya
Updated on 15-Mar-2021 09:45:42

10K+ Views

An array is a homogeneous sequential collection of data items over a single variable name.For example, int student[30];Here, student is an array name holds 30 collection of data item, with a single variable name.CharacteristicsThe characteristics of arrays are as follows −An array is always stored in consecutive memory location.It can store multiple value of similar type, which can be referred with single name.The pointer points to the first location of memory block, which is allocated to the array name.An array can either be an integer, character, or float data type that can be initialised only during the declaration.The particular element ... Read More

Explain monolithic and modular programming in C language

Bhanu Priya
Updated on 15-Mar-2021 09:41:44

4K+ Views

The difference between monolithic programming and modular programming along with the advantages and disadvantage are explained below in detail.Monolithic programmingIf, we write an entire program in a single function that is in main function then, you call it as a monolithic type of programming. But, it is not a good style of writing entire logic in a single function.DisadvantagesThe disadvantages of monolithic programming include −Program seems to be very large and complex.Debugging, testing and maintenance of a program is very difficult.Modular ProgrammingIf the program is divided into number of functional parts, then we use to call it as modular programming.If ... Read More

How to display the complete text one word per line in C language?

Bhanu Priya
Updated on 08-Mar-2021 10:06:44

1K+ Views

First, open the file in write mode. Later on, enter the text until it reaches the End Of File (EOF) i.e. press ctrlZ to close the file.Again, open in reading mode. Then, read words from the file and print each word in a separate line and close the file.The logic we implement to print one word per line is as follows −while ((ch=getc(fp))!=EOF){    if(fp){       char word[100];       while(fscanf(fp, "%s", word)!=EOF) // read words from file{          printf("%s", word); // print each word on separate lines.       }     ... Read More

Explain the accessing of structure variable in C language

Bhanu Priya
Updated on 08-Mar-2021 10:05:00

1K+ Views

The structure is a user-defined data type, which is used to store a collection of different data types of data.The structure is similar to an array. The only difference is that an array is used to store the same data types whereas, the structure is used to store different data types.The keyword struct is for declaring the structure.Variables inside the structure are the members of the structure.A structure can be declared as follows −Struct structurename{    //member declaration };ExampleFollowing is the C program for accessing a structure variable − Live Demostruct book{    int pages;    float price;    char author[20]; ... Read More

Demonstrate the concept of pointers using C language

Bhanu Priya
Updated on 08-Mar-2021 06:43:58

617 Views

The pointer is a variable that stores the address of another variable.The syntax for the pointer is as follows −pointer = &variable;ExampleFollowing is the C program for the concept of pointers using C language − Live Demo#include void main(){    //Declaring variables and pointer//    int a=2;    int *p;    //Declaring relation between variable and pointer//    p=&a;    //Printing required example statements//    printf("Size of the integer is %d", sizeof (int));//4//    printf("Address of %d is %d", a, p);//Address value//    printf("Value of %d is %d", a, *p);//2//    printf("Value of next address location of %d is %d", a, ... Read More

Example program on Dynamic memory allocation function in C language

Bhanu Priya
Updated on 08-Mar-2021 10:36:21

731 Views

ProblemHow to display and calculate the sum of n numbers by using dynamic memory allocation function in C language?SolutionFollowing is the C program to display the elements and calculate the sum of n numbers by the user by using dynamic memory allocation functions. Here, we also try to reduce the wastage of memory.Example Live Demo#include #include void main(){    //Declaring variables and pointers, sum//    int numofe, i, sum=0;    int *p;    //Reading number of elements from user//    printf("Enter the number of elements : ");    scanf("%d", &numofe);    //Calling malloc() function//    p=(int *)malloc(numofe*sizeof(int));    /*Printing O/p - ... Read More

Write a C Program to delete the duplicate numbers in an array

Bhanu Priya
Updated on 15-Mar-2021 09:41:04

1K+ Views

Let the user enter the numbers in an array, which contains duplicate elements.Now, let’s write a code to delete the repeated numbers or elements in an array and make an array with unique elements without duplicatesFor example, An example is explained below −User input is 12, 30, 12, 45, 67, 30.Output is 12, 30, 45, 67 (after deleting duplicates).ProgramFollowing is the C program to delete the duplicate numbers in an array − Live Demo#include #define MAX 100 // Maximum size of the array int main(){    int array[MAX]; // Declares an array of size 100    int size;    int ... Read More

C program to convert upper case to lower and vice versa by using string concepts

Bhanu Priya
Updated on 15-Mar-2021 09:39:55

2K+ Views

Converting upper to lower and lower to upper is generally termed as toggle.Toggle each character means, in a given string, the lower letter is print in upper form and upper case is print in lower letter respectively.ProgramThe C program to convert upper case to lower and lower case to upper is given below − Live Demo#include #define MAX 100 void toggle(char * string); int main(){    char string[MAX];    printf("enter the string need to be toggle :");    gets(string);    toggle(string);    printf("final string after toggling is:");    printf("%s", string);    return 0; } void toggle(char * string){    int ... Read More

Advertisements