Category: Arrays and Structures

Multi-Dimensional Arrays in C Programming Language 3

Multi-Dimensional Arrays in C Programming Language

Let’s understand the concept of multi-dimensional arrays in C programming language. Although arrays with more than two dimensions are not commonly used, C does allow any number of dimensions to be declared. This is done by listing maximum size of all dimensions of the array. For example, the declaration: int a[4][10][6]; declares a three-dimensional array. The first element in the array is designated as a[0][0][0] and the last element as a[3][9][5]. Thus, generally speaking, multidimensional arrays in C programming language are defined in much the same manner as one-dimensional arrays, except that a separate pair of square brackets are required...

Structures in C Programming Language 32

Structures in C Programming Language

Structure is a special type of C data type. Structures contains a number of data types grouped together. Structures in C is one of the excellent functionality provided in C. Structures makes C Programming language easy and simpler up to certain extent. Structure is most widely used in Programming. Structures in C allows multiple data types to be grouped together. As a programmer I have used structures in C a lot and find this feature interesting too. Just go through this article and you too will find structures in C interesting. Let us suppose you want to store basic information...

Demo on Structures in C 12

Demo on Structures in C

The Structure is a special type of C data type. A structure contains a number of data types grouped together. Structure in C allows multiple data types to be grouped together. The below mentioned program is to demonstrate structures in C Programming Language. #include #include void main(){ struct animal{ int age; char name[10]; char gender; }a[10]; int no,i; clrscr(); printf(“Enter the number of animals: “); scanf(“%d”,&no); for(i=0;i<no;i++){ printf(“\nEnter the age of animal %d: “, i+1); scanf(“%d”,&a[i].age); printf(“\nEnter the name of animal %d: “,i+1); scanf(“%s”,&a[i].name); printf(“\nEnter the gender(M/F) of animal %d: “,i+1); scanf(“%s”,&a[i].gender); } for(i=0;i<no;i++){ printf(“\n%d”,a[i].age); printf(“\t%s”,a[i].name); printf(“\t%c”,a[i].gender); } getch(); }...

Search first occurrence of element in an array 9

Search first occurrence of element in an array

Write a program in C language that will accepts n of integer values from the user, accepts the integer element to be searched and displays the position of the element in the array. #include #include #include void main() { int arr[100],i,element,no; clrscr(); printf(“\nEnter the no of Elements: “); scanf(“%d”, &no); for(i=0;i

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet