
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

796 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]

619 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() − Live Demo#include /* count lines in input */ main(){ int count, num; printf("enter multiple statements and Press cntrl+z:"); num = ... Read More

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

11K+ Views
In C programming, a union is a memory location shared by multiple variables of different data types. While we can define multiple members in a union, only one member can hold a value at any given time. This makes unions an efficient way to use the same memory space for different purposes. Declaration of Union Variable A union is a user-defined datatype in the C programming language. This allows the storage of different types of variables in the same location. A union can have multiple members, and only a single member can hold a value at any given time. Declaring ... Read More

939 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. Live Demo#include struct{ char name[20]; int age; int salary; ... Read More

8K+ 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 us understand how to pass the address of structure as an argument to function.The address of the structure is passed as an argument to the function.It is collected in a pointer to structure in function header.AdvantagesThe advantages of passing the address of structure as an argument to function are as follows −No wastage of ... Read More

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

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 − Live Demo#include struct date{ int ... Read More

5K+ Views
Pointer to structure holds the add of the entire structure.It is used to create complex data structures such as linked lists, trees, graphs and so on.The members of the structure can be accessed using a special operator called as an arrow operator ( -> ).DeclarationFollowing is the declaration for pointers to structures in C programming −struct tagname *ptr;For example: struct student *s;AccessingIt is explained below how to access the pointers to structures.Ptr-> membername;For example − s->sno, s->sname, s->marks;ExampleFollowing is a C program that explains the dynamic memory allocation of structure in C programming − Live Demo#include #include struct person ... Read More

5K+ Views
An array of structure in C programming is a collection of different datatype variables, grouped together under a single name.General form of structure declarationThe structural declaration is as follows −struct tagname{ datatype member1; datatype member2; datatype member n; };Here, struct is the keyword.tagname specifies the name of structure.member1, member2 specifies the data items that make up structure.ExampleThe following example shows the usage of array within a structure in C programming −struct book{ int pages; char author [30]; float price; };ExampleFollowing is the C program to demonstrate the use of an array within a structure ... Read More