1d Array
1d Array
programmerdouts.blogspot.com/2019/06/1-d-array-in-c.html
One-dimensional Array
#include<stdio.h>
void main()
{
int student[10]; // array of 10 students.
Initialization of an Array.
1/5
As we declare a variable and assign a value to it ,the same thing is
also done with an array.
We use curly bracket to initialize the array.
Inside, that curly bracket we write all the element in an sequence.
Syntax:
#include<stdio.h>
void main()
{
int student_roll[5] = {21,32,65,78,98}; // assigning value to an array of roll no
of 5 student.
Syntax:
array_name[index_number]
Lets Access some element of an Array
2/5
#include<stdio.h>
void main()
{ int rollno, rollno2, rollno3, mark1, mark2,mark3; //declaring variables
float percent1, percent2,percent3;
// printing the marks ,roll no, percentage of accessed data from the arrays.
printf("\nStudent whose roll no is %d has %d marks in English and achieved %f
percentage",rollno,mark1,percent1);
printf("\nStudent whose roll no is %d has %d marks in English and achieved %f
percentage",rollno2,mark2,percent2);
printf("\nStudent whose roll no is %d has %d marks in English and achieved %f
percentage",rollno3,mark3,percent3);
3/5
Output:
Student whose roll no is 21 has 58 marks in English and achieved 56.56
percentage
Student whose roll no is 32 has 65 marks in English and achieved 65.5
percentage
Student whose roll no is 65 has 48 marks in English and achieved 59.65
percentage
Further Concepts:
Concept of Initializing One Dimensional Array
How to take array elements as input from the User
What is Two Dimensional Array ?
Concept of Two Dimensional Array
How to initialize Two Dimensional Array?
How to take Elements of Two dimensional array from the User?
How to display 2D Array As an Table?
Practice Program Regarding Arrays
Practice Programs
Programs regarding Arrays
Programs Regarding 2d arrays
Programs regarding matrix
And lot more
Further Topics:
4/5
5/5