Introduction to C Language
C is a general-purpose, high-level programming language that is widely used for developing software applications, operating systems, and embedded systems. It is a powerful language that is easy to learn, and it is widely used for both system programming and application development. In this article, we will be discussing how to take percentage of marks using C language and structure.
Introduction to Calculating Percentage of Marks using C Language and Structure
Calculating percentage of marks is a common task that is required in many educational systems. In order to calculate percentage of marks, we need to divide the total marks obtained by the total marks available and then multiply the result by 100. This will give us the percentage of marks obtained by the student. In this article, we will be discussing how to calculate percentage of marks using C language and structure.
The following code shows how to calculate percentage of marks using C language and structure.
In the above code, we have created a structure called “student” which contains four variables: roll_no, name, marks, and percent. The roll_no and name variables are used to store the roll number and name of the student respectively, while the marks variable is an array that stores the marks of the student in three subjects. The percent variable is used to store the percentage of marks obtained by the student.
We then use a for loop to take input from the user for the roll number, name, and marks of three students. We then calculate the percentage of marks obtained by each student by dividing the total marks obtained by the total marks available and then multiplying the result by 100. This is done by using the following formula:
We then use another for loop to print the roll number, name, total marks, and percentage of marks for each
student. The output will be displayed in a tabular format, making it easy to read and understand.
When the above code is executed, the user will be prompted to enter the roll number, name, and marks of three students. The program will then calculate the percentage of marks obtained by each student and display the results in a tabular format. The output will look something like this:
Roll Number Name Marks Percentage 1 John 300 100 2 Jane 285 95 3 Michael 277 92.3
In this article, we have discussed how to calculate the percentage of marks using C language and structure. We have seen how to use a structure to store the details of multiple students and how to use for loops to take input and display output. We have also seen how to use a simple mathematical formula to calculate the percentage of marks obtained by a student. This is a basic example of how to use C language and structure to perform a specific task, and it can be extended to more complex applications as needed. Overall, C language is a powerful tool that can be used to create a variety of software applications, and understanding how to use structures is an important step in mastering this language.
New to coding world or want to learn more about coding , Here are some of the book we highly recommend you should read once in your lifetime.
6 Best Coding Books for Beginners You Must Read in 2023