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

Comments
.
Show some effort first, instead of demanding an answer on a plate

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...:)

Edited 5 Years Ago by peter_budo: Keep It Clear - Please use code tags

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 );
}

Edited 5 Years Ago by Arbus: n/a

Comments
Nice
#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);

}

}

Edited 5 Years Ago by peter_budo: Keep It Clear - Please use code tags

Comments
Terrible!
Spoonfeeding answer with no code tags, saved only by being completely broken code to begin with

Am I the only one who keeps misinterpreting that?

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

This article has been dead for over six months. Start a new discussion instead.