Differentiate between source code and object code.

 Differentiate between source code and object code. Create a structure named Book with members Book_Name, Price and Author_Name, then take input for 10 records of Book and print the name of authors having the price of book greater than 1000.

  1. Source Code:

    • Source code is the human-readable form of a program written in a programming language like C, C++, Java, Python, etc.
    • It contains instructions written by a programmer using syntax and conventions of the chosen programming language.
    • Source code is understandable by humans and can be modified easily.
    • It typically has file extensions like .c, .cpp, .java, .py, etc.
  2. Object Code:

    • Object code is the machine-readable form of a program generated after compiling the source code.
    • It is not human-readable and consists of binary digits (0s and 1s) or machine code.
    • Object code is specific to the architecture of the computer and cannot be easily modified by humans.
    • It is generated by a compiler or an assembler from the source code.
    • Object code files usually have extensions like .obj, .o, .exe, etc.

Program:

#include <stdio.h> #include <string.h> #define MAX_BOOKS 10 // Structure definition for Book struct Book { char Book_Name[100]; float Price; char Author_Name[100]; }; int main() { struct Book books[MAX_BOOKS]; int i, count = 0; // Input for 10 records of Book for (i = 0; i < MAX_BOOKS; i++) { printf("Enter details for Book %d:\n", i + 1); printf("Book Name: "); scanf("%s", books[i].Book_Name); printf("Price: "); scanf("%f", &books[i].Price); printf("Author Name: "); scanf("%s", books[i].Author_Name); } // Printing the name of authors having the price of book greater than 1000 printf("\nAuthors with books priced greater than 1000:\n"); for (i = 0; i < MAX_BOOKS; i++) { if (books[i].Price > 1000) { printf("%s\n", books[i].Author_Name); count++; } } if (count == 0) printf("No authors have books priced greater than 1000.\n"); return 0; }

This code defines a structure named Book with members Book_Name, Price, and Author_Name, takes input for 10 records of books, and prints the name of authors having the price of the book greater than 1000.