C program to calculate average of a class using array - My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Friday, January 31, 2020

C program to calculate average of a class using array - My CS Tutorial

C program to find average of a class.

In this tutorial we will learn how to write a simple c language program to find or calculate the average of a class using array.

In the first user will enter number of students that are available in a class.
After it user will enter marks of students then compiler print the average of class.


C PROGRAM CODE



#include<stdio.h>
#include<conio.h>
void main()
{
    int x,num,sum=0;
    float avg;
    int marks[100];
    clrscr();
 
    printf("\n ENTER NUMBER OF STUDENTS:\n ");
 
    scanf("%d",&num);
 
    printf("\n ENTER ALL STUDENTS MARKS:\n ");
    for(x=0;x<num;x++)
    {
        scanf("%d",&marks[x]);
        sum+=marks[x];
    }
    avg=(float)sum/num;
 
    printf("\n AVERAGE OF THIS CLASS IS:\n %f\n",avg);

getch();
}

OUTPUT:




Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com

Created by-- HARSH CHAUHAN

No comments:

Post a Comment