CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 12:28:04 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=e97d9bb5a193dd5471bf67efad34b620969d21ef061dcc5535f2ef4085016939a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22ZRPquAhvEm__lRNfyMOjdUyb7nAPtTpK%22%3B%7D; HttpOnly; Path=/
cf-ray: 98ce5aef58d48cf1-BLR
C Lab - CGPA - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct Course {
- char code[16];
- double marks;
- double credits;
- };
- struct Student {
- char name[64];
- double cgpa;
- int course_count;
- Course courses[10];
- };
- double calc_grade(double marks) {
- if(marks >= 80) {
- return 4;
- } else if(marks >= 75) {
- return 3.75;
- } else if(marks >= 70) {
- return 3.5;
- } else if(marks >= 65) {
- return 3.25;
- } else if(marks >= 60) {
- return 3;
- } else if(marks >= 55) {
- return 2.75;
- } else if(marks >= 50) {
- return 2.5;
- } else if(marks >= 45) {
- return 2.25;
- } else if(marks >= 40) {
- return 2;
- } else {
- return 0;
- }
- }
- int main() {
- int n;
- printf("Enter number of students: ");
- scanf("%d", &n);
- Student students[n];
- for(int i=0; i<n; i++) {
- printf("Enter student %d details:\n", i+1);
- printf("Name: ");
- scanf("%s", &students[i].name);
- printf("Number of courses: ");
- scanf("%d", &students[i].course_count);
- double total_credits = 0, qp = 0;
- for(int j=0; j<students[i].course_count; j++) {
- printf("Enter course %d details:\n", j+1);
- printf("Course code: ");
- scanf("%s", &students[i].courses[j].code);
- printf("Course credits: ");
- scanf("%d", &students[i].courses[j].credits);
- printf("Obtained marks: ");
- scanf("%lf", &students[i].courses[j].marks);
- printf("\n");
- total_credits += students[i].courses[j].credits;
- qp += students[i].courses[j].credits*calc_grade(students[i].courses[j].marks);
- }
- students[i].cgpa = qp/total_credits;
- }
- for(int i=0; i<n; i++) {
- printf("Student %d detalis:\n",i+1);
- printf("Name: %s\n", students[i].name);
- printf("CGPA: %lf\n", students[i].cgpa);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
✅ Make $2500 in 20 minutes⭐⭐⭐ P
JavaScript | 4 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ 3
JavaScript | 8 sec ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 10 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ H
JavaScript | 15 sec ago | 0.24 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ 3
JavaScript | 19 sec ago | 0.24 KB
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 20 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ J
JavaScript | 27 sec ago | 0.24 KB
-
⭐✅ Swapzone Glitch ✅ Working⭐⭐⭐ L
JavaScript | 30 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand