function and structure

function and structure - for(int i=0;i<k;i st[i.av =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Q :write a C++ function and main program to read structure that contain student name ,3 degree and average for n student? #include<iostream.h> #include<stdio.h> struct student { int d[3]; int av; char name[30]; }st1[3]; void read(student st[],int k) { for(int i=0;i<k;i++) { cout<<"name: ";cin>>st[i].name ; cout<<"enter 3 degree"; cin>>st[i].d[0]>>st[i].d[1]>>st[i].d[23] ; }} void av(student st[],int k )
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { for(int i=0;i<k;i++) st[i].av =( st[i].d[0]+st[i].d[1]+st[i].d[23])/3; } void print(student st,int k) { for(int i=0;i<k;i++) { printf("\t%s /t%d /t%d /t%d /t%d",st[i].name ,st[i].d[0],st[i].d[1],st[i].d[2],st[i].av ); }} void main() { int n; //n= No. of student cout<<"enter no. of student"; cin>>n; read(st1,n); av(st1,n); print(st1,n); }...
View Full Document

This note was uploaded on 10/16/2010 for the course ENG 2266e taught by Professor Aliraqi during the Spring '10 term at 4.1.

Page1 / 2

function and structure - for(int i=0;i<k;i st[i.av =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online