0% found this document useful (0 votes)
9 views4 pages

C Lab 2

The document outlines a lab report for a program that inputs a student's name, roll number, and marks in five subjects to calculate and display their percentage score. It includes objectives, problem analysis, an algorithm, source code in C, and a conclusion stating the program's effectiveness in achieving its goals. The program successfully captures and computes the required student details and percentage score.

Uploaded by

46prashant46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

C Lab 2

The document outlines a lab report for a program that inputs a student's name, roll number, and marks in five subjects to calculate and display their percentage score. It includes objectives, problem analysis, an algorithm, source code in C, and a conclusion stating the program's effectiveness in achieving its goals. The program successfully captures and computes the required student details and percentage score.

Uploaded by

46prashant46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Lab Report 2:

Title: Write a program to take input of name, roll number, and marks obtained by a student in 5
subjects each having 100 full marks and display the name, roll number, and percentage score secured.

Objectives: To input and display student details including their name, roll number, and percentage
score calculated from marks obtained in five subjects.

Problem Analysis: To calculate the percentage score of a student, we need to take inputs for the
student's name, roll number, and marks obtained in five subjects. We will then calculate the total marks
obtained, compute the percentage, and display the name, roll number, and percentage score.

Algorithm:

1. Start

2. Declare variables for the student's name, roll number, and marks in five subjects.

3. Declare a variable for the total marks and percentage.

4. Take input for the student's name and roll number.

5. Take input for the marks obtained in each of the five subjects.

6. Calculate the total marks obtained by summing up the marks of the five subjects.

7. Calculate the percentage using the formula: Percentage = (Total Marks / 500) * 100

8. Display the student's name, roll number, and percentage score.

9. End
Flowchart:

Source Code:

#include <stdio.h>
int main()
{
char name[50];
int roll;
float sub1, sub2, sub3, sub4, sub5, percentage, totalMarks;
printf("Enter your name: ");
scanf("%s", name);
printf("Enter your roll number: ");
scanf("%d", &roll);
printf("Enter marks in 5 subjects respectively: ");
scanf("%f \n %f \n %f \n %f \n %f", &sub1, &sub2, &sub3, &sub4, &sub5);
totalMarks= sub1 + sub2 + sub3 + sub4 + sub5;
percentage =(totalMarks/500)* 100;
printf("Name: %s\nRoll number: %d\n Total Marks: %.2f \n Percentage: %.2f\n", name,
roll, totalMarks, percentage);
return 0;
}

Output
Conclusion & Discussion:
The provided C program successfully takes input for a student's name, roll number, and marks

obtained in five subjects. It then calculates the total marks and percentage score, which are
displayed along with the student's details. The program accurately meets its objective by
implementing the necessary input operations and arithmetic calculations to determine the
student's percentage score. The code is simple and ensures that all necessary details are
captured and displayed correctly.

You might also like