Bhanu Priya

Bhanu Priya

1,060 Articles Published

Articles by Bhanu Priya

Page 10 of 106

How to pass the individual members as arguments to function using structure elements?

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 2K+ Views

There are three ways by which the values of structure can be transferred from one function to another. They are as follows −Passing individual members as arguments to function.Passing entire structure as an argument to function.Passing the address of structure as an argument to function.Now let’s see how to pass an individual member of structure elements as arguments to function.Each member is passed as an argument in the function call.They are collected independently in ordinary variables in function header.ExampleGiven below is a C program to demonstrate passing individual arguments of structure to a function −#include struct date{    int day; ...

Read More

How to pass an entire structure as an argument to function in C?

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 4K+ Views

There are three ways by which the values of structure can be transferred from one function to another. They are as follows −Passing individual members as arguments to function.Passing entire structure as an argument to function.Passing the address of structure as an argument to function.Now let’s see how to Pass an entire structure as an argument to function.Name of the structure variable is given as argument in function call.It is collected in another structure variable in function header.The disadvantage is that a copy of an entire structure is created again by wasting the memory.ExampleThe following program shows how to pass ...

Read More

Matrix row sum and column sum using C program

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 3K+ Views

ProblemLet’s write a C program to compute the row sum and column sum of a 5 x 5 array using run time compilation.SolutionIn this program, we are entering the values of array which is of size 5X5 matrix during runtime in the console, with the help of for loops we are trying to add rows and columns.Logic for doing row sum is given below −for(i=0;i

Read More

What is a structure at local scope in C language?

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 993 Views

Structure is a collection of different datatype variables, grouped together under a single name.General form of structure declarationThe structure declaration is as follows −struct tagname{    datatype member1;    datatype member2;    datatype member n; };Here, struct is the keyword.tagname specifies name of structure.member1, member2 specifies the data items that make up structure.ExampleThe following example shows the usage of the structure at a local scope.struct book{    int pages;    char author [30];    float price; };ExampleThe following program shows the usage the structure at a local scope.#include struct{    char name[20];    int age;    int salary;    char ...

Read More

Explain the pointers to unions in C language

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 4K+ Views

A union is a memory location that is shared by several variables of different data types.SyntaxThe syntax for the pointers to unions in C programming is as follows −union uniontag{    datatype member 1;    datatype member 2;    ----    ----    datatype member n; };ExampleThe following example shows the usage of union of structure.union sample{    int a;    float b;    char c; };Declaration of union variableFollowing is the declaration for union variable. It is of three types as follows −Type 1union sample{    int a;    float b;    char c; }s;Type 2union{    int a; ...

Read More

Explain the Character operations in C language

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 697 Views

Character can be (A-Z(or) a- z), digit (0-9), a white space, or a special symbol in C programming language.DeclarationFollowing is the declaration for character operations in C programming −char a= ‘A’; using a character constant.Character input / output functionsThe character input/output functions are explained below −Example − char a;scanf("%c", &a); printf ("%c", &a); a = getchar ( ); putchar (a); a = getch ( ); putch (a);ExampleFollowing is the C program for line counting using getchar() −#include /* count lines in input */ main(){    int count, num;    printf("enter multiple statements and Press cntrl+z:");    num = 0; ...

Read More

Write a C Program to count the frequency of each character

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 935 Views

Follow the algorithm to write a C program which enables to count the frequency of each character.AlgorithmStep 1: Define MAX size. Step 2: Declare char and integer variables. Step 3: Read the string from console. Step 4: Find length of the string. Step 5: Initialize frequency of each character to 0. Step 6: Find total number of occurrences of each character. for(i=0; i='a' && string[i]='A' && string[i]

Read More

Post and Pre incremented of arrays in C language

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 5K+ Views

ProblemExplaining the array post and pre incremented concept with the help of C program.SolutionIncrement operator (++) −It is used to increment the value of a variable by 1There two types of increment operators − pre increment and post increment.Increment operator is placed before the operand in preincrement and the value is first incremented and then operation is performed on it.eg: z = ++a; a= a+1 z=aIncrement operator is placed after the operand in post increment and the value is incremented after the operation is performed.eg: z = a++; z=a a= a+1Let’s consider an example to access particular elements in memory ...

Read More

C Program to calculate the difference between two time periods

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 4K+ Views

Enter the start and stop time with hours, minutes and seconds. Finally, we need to find the difference between start and stop time.The logic to find the difference between start and stop time is given below −while (stop.sec > start.sec){    --start.min;    start.sec += 60; } diff->sec = start.sec - stop.sec; while (stop.min > start.min) {    --start.hrs;    start.min += 60; } diff->min = start.min - stop.min; diff->hrs = start.hrs - stop.hrs;ExampleFollowing is the program to find difference between start and stop time −#include struct time {    int sec;    int min;    int hrs; }; ...

Read More

Explain dynamic memory allocation in C with an example

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 13K+ Views

ProblemFind the sum of n numbers entered by user using dynamically allocated memory using C programming.SolutionThe Dynamic memory allocation enables the C programmers to allocate memory at runtime.The different functions that we used to allocate memory dynamically at run time are −malloc () − allocates a block of memory in bytes at runtime.calloc () − allocating continuous blocks of memory at run time.realloc () − used for reduce (or) extend the allocated memory.free () − deallocates previously allocated memory space.Following C program is to display the elements and calculate sum of n numbers.Using dynamic memory allocation functions, we are trying ...

Read More
Showing 91–100 of 1,060 articles
« Prev 1 8 9 10 11 12 106 Next »
Advertisements