Write a C program to read Roll number,Name and Marks of 3 subjects of a student using structure

Salem commented: Show some effort first, instead of demanding an answer on a plate -4
sergent commented: . -1

Recommended Answers

All 12 Replies

Show me yours and I'll show you mine.

Show me yours and I'll show you mine.

Totally worth it.

Suppose you have a structure named data as follows:

struct data{
     int roll_no;
     char name[200];
     int marks;
};

Now you can read the input from user by creating an instance of this struct:
data d;

scanf("%d%s%d",&d.roll_no,&d.name,&d.marks);

Hope this will help you...:)

Add this in the starting of your code, if you have written any.

#include < stdio.h >
int main()
{
  char a[25]={68,79,' ',89,79,85,82,' ',79,87,78,' ',72,79,77,69,87,79,82,75,33};
  printf( a );
}
commented: Nice +17

what's your making anyway?

#include<stdio.h>
struct stud
{
int roll;
ch name[20];
int m1,m2,m3;
};

main()
{
int a;
printf("Enter no of students:");
scanf("%d",&a);
int j;
for(j=1;j<=a;j++)
{
pritnf("enter name");
scanf("%c",stud.j[name]);
pritnf("enter roll");
scanf("%c",stud.j[roll]);
pritnf("enter sub1");
scanf("%c",stud.j[sub1]);
pritnf("enter sub2");
scanf("%c",stud.j[sub2]);
pritnf("enter sub3");
scanf("%c",stud.j[sub3]);
}

printf("printing the stud info:");
for(j=1;j<a;j++)
{
printf("%c",stud.name);
printf("%d",stud.roll);
printf("%d",stud.m1);
printf("%d",stud.m2);
printf("%d",stud.m3);

}

}
commented: Spoonfeeding answer with no code tags, saved only by being completely broken code to begin with -4
commented: Terrible! -2

aHHH!!!,,i see...its the answer,,,

Show me yours and I'll show you mine.

Am I the only one who keeps misinterpreting that?

commented: lol +4

Am I the only one who keeps misinterpreting that?

I would be shocked if you are. Dirty minds like to write code, I hear. ;)

I would be shocked if you are. Dirty minds like to write code, I hear. ;)

Nahh, your code is just way better. ;)

Member Avatar for MonsieurPointer

I would be shocked if you are. Dirty minds like to write code, I hear. ;)

I thought dirty minds write the best code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.