0% found this document useful (0 votes)
20 views

Pointers Program-F

This document contains C code that defines functions to grade student marks. It defines arrays to store student names and marks. It prints the names, marks and grades, allows changing a mark, then reprints the updated information. Functions are defined to display an integer array, change a mark, convert a mark to a letter grade, and convert a mark to a text grade. The main function calls these functions to demonstrate the grading functionality.

Uploaded by

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

Pointers Program-F

This document contains C code that defines functions to grade student marks. It defines arrays to store student names and marks. It prints the names, marks and grades, allows changing a mark, then reprints the updated information. Functions are defined to display an integer array, change a mark, convert a mark to a letter grade, and convert a mark to a text grade. The main function calls these functions to demonstrate the grading functionality.

Uploaded by

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

/****************************************************************************

**

Welcome to GDB Online.


GDB online is an online compiler and debugger tool for C, C++, Python, PHP,
Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*****************************************************************************
**/
#include <stdio.h>
#define SIZE 3
char gradeToC (float);
void gradeToS(float);
void changeMark(float *);
void resetMark(float *aPtr);
void display(int *aPtr);

int main ()
{
char *name[SIZE] = { "Marwa", "Lama", "Rahaf" };
float mark[SIZE] = { 89.5, 92.3, 40.5 };
char code[]={'A','B','C'};

int nom[]={100,200,300};
int i;
display(nom);

printf ("%10s%10s%10s\n", "Names", "Marks", "Grades");


printf ("------------------------------------------\n");
for(i = 0;i<SIZE;i++)
{ printf ("%10s%10.1f\t", name[i], mark[i]);
gradeToS(mark[i]);
}

printf("Enter index to change grade:>");


scanf("%d", &i);

changeMark(&mark[i]);

printf ("%10s%10s%10s\n", "Names", "Marks", "Grades");


printf ("------------------------------------------\n");
for(i = 0;i<SIZE;i++)
{ printf ("%10s%10.1f\t", name[i], mark[i]);
gradeToS(mark[i]);
}

return 0;
} // end main

void display(int *aPtr)


{
int i;
for(i = 0;i<SIZE;i++)
printf ("%d ", *aPtr++);

void changeMark(float *mPtr)


{
int mark;
printf("Enter new grade");
scanf("%d", &mark);
*mPtr=mark;
}

char gradeToC(float m)
{
char result = ' ';
if (m < 60)
result = 'P';
else
result = 'F';

return result;
}

void gradeToS(float m)
{

if (m < 60)
printf( "F\n");
else if (m >=60 && m < 70)
printf( "B\n");

else if (m >=70 && m < 80)


printf( "B+\n");

else if (m >=80 && m <= 100)


printf( "A+\n");

You might also like