Skip to main content

Featured Post

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

C Language: How to Store Multiple values in Array

One data item can only be stored in one variable, in the context of computer programming. If programmer want to store more information in the memory, he/she should have more variables. Programmer can choose another option that is an Array.

Suppose that a student has scored 90 marks. These marks can be stored in a variable in c programming language as shown below:
int marks=90;

After executing this statement, the value 90 will be stored in the variable marks. Suppose there programmer needs to store marks of 10 students. In such case, we have to use 10 variables like marks1, marks2, marks3, …, marks10. But, if it is required to store the marks of 100 students, definitely it is not feasible to use 100 variables marks1, marks2, marks3, …, marks100. In mathematics, we use sets to group the items of similar kind. For example, consider the set shown below:

Marks = {75, 76, 78, 79, 86, 56, 98, 89, 56, 89}

This is a set of 10 students. Note that every item can be accessed by prefixing marks along with the position of marks in the sheet. The first item 75 corresponds to the marks of first student, 76 corresponds to the marks of second student and so on i.e., marks1=75, marks2=76, marks3=78, ….., marks10=89. In C language, this is where; the concept of arrays is used. Since all the marks are of the same type, we can group and refer all the marks with a common name using arrays.

An array is defined as an ordered set of similar data items. All the data items of an array are stored in consecutive memory locations in main memory. The elements of an array are of same data type and each item can be accessed using the same name. e.g., consider an array of marks of 5 students as shown below:

How to Store Multiple values in Computer Programming: Array

To refer an item in the array, we specify the name of the array along with position of the item. The position of the item must be written within square brackets '[ ]'. The position of the item enclosed within square brackets is called 'subscript' or 'index'. For example, the above figure represents an integer array called marks where marks of 5 students are stored. The marks of each student can be accessed as shown below:

  • Marks[0] i.e. 75 – represents marks of first student
  • Marks[0] i.e. 76 – represents marks of second student
  • Marks[0] i.e. 78 – represents marks of third student
  • Marks[0] i.e. 79 – represents marks of fourth student
  • Marks[0] i.e. 86 – represents marks of fifth student

Note: Using Marks[0] through Marks[n-1] we can access the marks of n students in general.

In an array it is not possible to have a group of items with different data types. For example,

How to Store Multiple values in Computer Programming: Array

This is an invalid way of storing the elements in an array. This is because, it is a collection of multiple datatypes, so we have to classify the array. The classification will be done in next article.

Comments

Popular Post

Polynomial representation using Linked List for Data Structure in 'C'

Polynomial representation using Linked List The linked list can be used to represent a polynomial of any degree. Simply the information field is changed according to the number of variables used in the polynomial. If a single variable is used in the polynomial the information field of the node contains two parts: one for coefficient of variable and the other for degree of variable. Let us consider an example to represent a polynomial using linked list as follows: Polynomial:      3x 3 -4x 2 +2x-9 Linked List: In the above linked list, the external pointer ‘ROOT’ point to the first node of the linked list. The first node of the linked list contains the information about the variable with the highest degree. The first node points to the next node with next lowest degree of the variable. Representation of a polynomial using the linked list is beneficial when the operations on the polynomial like addition and subtractions are performed. The resulting polynomial can also

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

Memory representation of Linked List Data Structures in C Language

                                 Memory representation of Linked List              In memory the linked list is stored in scattered cells (locations).The memory for each node is allocated dynamically means as and when required. So the Linked List can increase as per the user wish and the size is not fixed, it can vary.                Suppose first node of linked list is allocated with an address 1008. Its graphical representation looks like the figure shown below:       Suppose next node is allocated at an address 506, so the list becomes,   Suppose next node is allocated with an address with an address 10,s the list become, The other way to represent the linked list is as shown below:  In the above representation the data stored in the linked list is “INDIA”, the information part of each node contains one character. The external pointer root points to first node’s address 1005. The link part of the node containing information I contains 1007, the address of