Need code for declaring a structure

Asked By 240 points N/A Posted on -
qa-featured

Write a program that declares a structure, to store data of a student. The program should define a structure variable, input the values and then display these.

SHARE
Best Answer by MRobert
Answered By 0 points N/A #90758

Need code for declaring a structure

qa-featured

Struct student

{

            int RNo;

            int marks;

            float avg;

            char grade;

}

Answered By 240 points N/A #90759

Need code for declaring a structure

qa-featured

How we will define a structure variable and how  will it work?

Answered By 0 points N/A #90760

Need code for declaring a structure

qa-featured

You can create the structure variable as you can create the data member or variable of a class. The process will be like:

Student s;

s.rno;

s.marks;

and etc

Answered By 240 points N/A #90761

Need code for declaring a structure

qa-featured

I am very much confused about the concept you are describing. Can you please provide me a simple code in step wise format?

Best Answer
Best Answer
Answered By 0 points N/A #90762

Need code for declaring a structure

qa-featured

#include<iostream.h>

#include<conio.h>

struct student

{

int RNo;

            int marks;

            float avg;

            char grade;

};

void main()

{

            clrscr();

            student s;

            cout<<”Enter Roll No”;

            cin>>s.rno;

            cout<<”Enter Marks”;

            cin>>s.marks;

            cout<<”Enter Average”;

            cin>>s.avg;

            cout<<”Enter Grade”;

            cin>>s.grade;

            cout<<”you entered the following details”;

            cout<<”Roll No :”<<s.rno<<endl;

            cout<<”Marks:”<<s.marks<<endl;

cout<<”Average :”<<s.avg<<endl;

cout<<”Grade :”<<s.grade<<endl;

getch();

}

Answered By 240 points N/A #90763

Need code for declaring a structure

qa-featured

Thanks a lot dear experts. Regards.

Answered By 0 points N/A #90765

Need code for declaring a structure

qa-featured

hello Baigsb,

        Here I am subitting a Program regarding your problem ….

#include<iostream.h>

#include<conio.h>

struct student

{

int roll_no;

char name[100];

char clas[3];

}s;

void main()

{

 clrscr();

 int n;

 cout<<"n Enter Roll no.

of student";

 cin>>s.roll_no;

 cout<<"n Enter name of

the student";

 cin>>s.name;

 cout<<"n Enter class of

the student";

 cin>>s.clas;

 cout<<"n n1.Roll no is

"<<s.roll_no;

  cout<<"n n2.Name is

"<<s.name;

   cout<<"n n3.class is

"<<s.clas;

   getch();

}

you can run this program …and you will get your perfect output.

Related Questions