Posts

Showing posts from March 25, 2018

Differences between Structure and Union in C | C programming

STRUCTURE IN C A structure is a user-defined data type available in C that allows to combining data items of different kinds. Structures are used to represent a record. Defining a structure:  To define a structure, you must use the  struct  statement. The struct statement defines a new data type, with more than one member. The format of the struct statement is as follows:    struct [structure name]    {        member definition;        member definition;        ...        member definition;    }; UNION IN C A union is a special data type available in C that allows storing different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple purposes. Defining a Union:  To define a union, you must use the  union  statement in the same way as you did while defining a structure. The union stateme

C Program to Store Information in Structure and Display it | C Programming

Structure    Arrays are used to store large set of data and manipulate them, but the disadvantage is that all the elements stored in an array are to be of the same data type. If we need to use a collection of different data type items, it is not possible using an array. When we require using a collection of different data items of different data types, we can use a structure.  Structure is a method of grouping data of different types.  A structure is a convenient method of handling a group of related data items of different data types.  

C Program for Fibonacci Series | C Programming

C Programming | Fibonacci Series The phrase, “ the  Fibonacci sequence” usually refers to a set of numbers that starts as {0, 1, 1, 2, 3, 5, 8, 13, 21…}. At least, “The Life and Numbers of Fibonacci” starts with “zero and one”. Many others would skip the zero and simply start with “one and one”, but that does not matter.

C Program to change the address of entered number using pointer and function | C programming

Introduction To Pointer A Pointer in C language is a variable which holds the address of another variable of same data type. Pointers are used to access memory and manipulate the address. Pointers are one of the most distinct and exciting features of C language. It provides power and flexibility to the language. Although pointers may appear a little confusing and complicated in the beginning, but trust me, once you understand the concept, you will be able to do so much more with C language. C Program to change the address of entered number using pointer and function #include <stdio.h> #include <string.h> void exchange ( int * , int * ); int main () {     int num1 , num2 ;     printf ( "Enter the number to be exchanged \n " );     scanf ( " %d%d " , & num1 , & num2 );     printf ( "Before exchanging: \n num1= %d num2= %d \n " , num1 , num2 );     exchange (& num1 , & num2 ); } void exchange ( int * num1 , int * num2 )

C program to transpose the matrix

C program to transpose the matrix #include <stdio.h< int main () {     int a [ 10 ][ 10 ], i, j, row, col, trans [ 10 ][ 10 ];     printf ( "Enter no. of rows:" );     scanf ( " %d " , &row);     printf ( "Enter no. of columns:" );     scanf ( " %d " , &col);     printf ( "Enter elements of matrix:" );     for (i = 0 ; i < row; i++)     {         for (j = 0 ; j < col; j++)         {             scanf ( " %d " , & a [i][j]);         }     }     printf ( " \n The given matrix is : \n " );     for (i = 0 ; i < row; i++)     {         for (j = 0 ; j < col; j++)         {             printf ( " %d \t " , a [i][j]);         }         printf ( " \n " );     }     printf ( " \n The matrix after transpose is : \n " );     for (i = 0 ; i < row; i++)     {         for (j = 0 ; j < col; j++)         {             trans [i][j] = a [j][i];             pri