Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Difference between Array and Structures in C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 431
    Comment on it


    1). An array is a collection of homogeneous elements.
    2. An array is a derived data type.
    3) Any array is like a built-in data types. All we have to do is to declare an array variable so that we can use it.

    Example of Array to find the sum marks of n students

    #include <stdio.h>
    int main(){
         int marks[10],i,n,sum=0;
         printf("Enter number of students: ");
              printf("Enter marks of student%d: ",i+1);
         printf("Sum= %d",sum);
    return 0;

    1) An array is a collection of hetrogeneous elements.
    2) A structure is a user-defined data type.
    3) In the case of structure, first we have to design and declare a data structure and then we declare the variable of that type.
    Example of Structure which stores record of a student for e.g. name,roll no and marks

    #include <stdio.h>
    struct student{
        char name[50];
        int roll;
        float marks;
    int main(){
        struct student s;
        printf("Enter information of students:\n\n");
        printf("Enter name: ");
        printf("Enter roll number: ");
        printf("Enter marks: ");
        printf("\nDisplaying Information\n");
        printf("Name: %s\n",;
        printf("Roll: %d\n",s.roll);
        printf("Marks: %.2f\n",s.marks);
        return 0;

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: