Q-1: Create a structure to specify data on students given
below:
Roll number, Name, Department, Course, Year of joining
Assume that there are not more than 450 students in the
college.

Answers were Sorted based on User's Feedback



Q-1: Create a structure to specify data on students given below: Roll number, Name, Department,..

Answer / shyam kumar thapa

/*Program to specify data of students*/
#include <stdio.h>
#include <conio.h>
struct student
{
char name[20],dept[20],course[20];
int roll, year_join;
}stud[450];
void main ()
{
int i,n;
printf("Enter the number of student(s)");
scanf("%d",&n)
printf("Enter the record of student(s)\n");
for(i=0;i<n;i++)
{
printf("Enter name");
scanf("%s",&stud[i].name);
printf("Enter Department");
scanf("%s",&stud[i].dept);
printf("Enter Roll no");
scanf("%d",&stud[i].roll);
printf("Enter year of joining");
scanf("%d", &stud[i].year_join);
printf("Enter course");
scanf("%s",&stud[i].course);
}
printf("Data of students are");
for(i=0;i<n;i++)
{
printf("Name of student is %s\t",stud[i].name);
printf("Departemt of student is %s\t",stud[i].dept);
printf("Roll no of student is %d\t";stud[i].roll);
printf("Year of joining is %d\t",stud[i].year_join);
printf("Course of student is %s\t",stud[i].course);
}
getch();
}

Is This Answer Correct ?    122 Yes 56 No

Q-1: Create a structure to specify data on students given below: Roll number, Name, Department,..

Answer / mrityunjay yadav

#include<stdio.h>
struct students
{
int Roll_no;
char name[50];
char deptt[20];
char course[30];
int year_of_passing;
};
void main()
{
struct students s[500];
int n,i,year,rollno,ccy,found=0;

clrscr();

printf("\nEnter number of students : ");
scanf("%d",&n);
printf("\nEnter the course completion period(in years) : ");
scanf("%d",&ccy);

printf("\nEnter student details : \n");
for(i=0;i<n;i++)
{
printf("\n\nEnter details for student : %d",i+1);
printf("\nRoll No : ");
scanf("%d",&s[i].Roll_no);
printf("\nName : ");
scanf("%s",s[i].name);
printf("\nDepat. : ");
scanf("%s",s[i].deptt);
printf("\nCourse : ");
scanf("%s",s[i].course);
printf("\nYear of Passing : ");
scanf("%d",&s[i].year_of_passing);
}
printf("\nQuestion 1 -> Enter the year of joining : ");
scanf("%d",&year);
printf("\nName of the Students\n------------------------------…
for(i=0;i<n;i++)
{
if(s[i].year_of_passing==(ccy+year))
{
printf("\n%s",s[i].name);
found=1;
}
}
if(found==1);
else printf("\nNo record Found\n");
found=0;
printf("\nQuestion 2 -> Enter the roll no : ");
scanf("%d",&rollno);

if(s[i].Roll_no==rollno)
{
found=1;
printf("\nName : %s\nDept. : %s\nCourse :
%s\n",s[i].name,s[i].deptt,s[i].course);
}
if(found==1);
else printf("\nNo record Found\n");

getchar();
}

Is This Answer Correct ?    29 Yes 25 No

Q-1: Create a structure to specify data on students given below: Roll number, Name, Department,..

Answer / prathmesh dewade

#include<stdio.h>
struct stud{
int roll;
char name[50];
int dep;
char c[50];
int year;

};
main()
{
struct stud st[5];
int i;
for(i=0;i<5;i++)
{
printf("
enter student record %d
",i+1);
printf("enter Roll no
");
scanf("%d",&st[i].roll);

printf("enter Name ");
scanf(" %s",&st[i].name);

printf("
enter department ");
scanf("%d",&st[i].dep);

printf("
enter Course ");
scanf(" %s",&st[i].c);

printf("
enter Year of joining");
scanf(" %d",&st[i].year);
}
for(int i=0;i<5;i++)
{
printf("Roll:%d, Name:%s, DepNo:%d,Course:%s, YearOfJoin:%d
",st[i].roll,st[i].name,st[i].dep,st[i].c,st[i].year);
}

}

Is This Answer Correct ?    2 Yes 0 No

Q-1: Create a structure to specify data on students given below: Roll number, Name, Department,..

Answer / taqi haider

#include <stdio.h>
#include <conio.h>
struct student{
char name[20],dept[20],course[20];
int roll, year_join;
}stud[450];
void main (){
int i,n,year;
printf("Enter the number of student(s):");
scanf("%d",&n);
printf("Enter the record of student(s)
");
for(i=0;i<n;i++){
printf("Enter name:");
scanf("%s",&stud[i].name);
printf("Enter Department:");
scanf("%s",&stud[i].dept);
printf("Enter Roll no:");
scanf("%d",&stud[i].roll);
printf("Enter year of joining:");
scanf("%d", &stud[i].year_join);
printf("Enter course:");
scanf("%s",&stud[i].course);
}
printf("
Enter the year of joining:");
scanf("%d",&year);
printf("The Name of the students
------------------
");
for(i=0;i<n;i++){
if(stud[i].year_join==year){
printf("%s
",stud[i].name);
}
}
printf("
-------------------
");
printf("
Data of all students
");
for(i=0;i<n;i++){
printf("
Name of student is %s
",stud[i].name);
printf("Departemt of student is %s
",stud[i].dept);
printf("Roll no of student is %d
",stud[i].roll);
printf("Year of joining is %d
",stud[i].year_join);
printf("Course of student is %s
",stud[i].course);
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

Q-1: Create a structure to specify data on students given below: Roll number, Name, Department,..

Answer / dolly kushwah

#include <stdio.h>
struct student
{
int rn;
char name[20];
char course[20];
char dept[20];
int yoj;

} s[450];

displaydata (int rn, int n)
{
for (int i = 0; i < n; i++)
{
(rn == s[i].rn) ? printf ("%s %d %s %s %d
", s[i].name, s[i].rn,
s[i].course, s[i].dept,
s[i].yoj) : printf ("roll no not found..
");
}

}

displayname (int yoj, int n)
{
for (int i = 0; i < n; i++)
{
(yoj ==
s[i].yoj) ? (printf ("%s
",
s[i].
name))
: (printf ("no students who are joinig in year %d
", yoj));
}

}

int
main ()
{
int rn, yoj, n, i = 0;

printf ("Enter the no of students...
");

scanf ("%d", &n);
printf ("Enter the name , roll no.,couse, dept , year of joining....
");
for (int i = 0; i < n; i++)
{
scanf ("%s%d%s%s%d", &s[i].name, &s[i].rn, &s[i].course, &s[i].dept,
&s[i].yoj);
}

printf ("Enter the year of joining of students...
");
scanf ("%d", &yoj);
displayname (yoj, n);

printf ("Enter the roll no of students...
");
scanf ("%d", &rn);
displaydata (rn, n);


return 0;
}

Is This Answer Correct ?    4 Yes 5 No

Q-1: Create a structure to specify data on students given below: Roll number, Name, Department,..

Answer / gaurav

#include <stdio.h>
#include <conio.h>
struct student
{
char name[20],dept[20],course[20];
int roll, year_join;
}stud[450];
void main ()
{
int i,n;
printf("Enter the number of student(s)");
scanf("%d",&n);
printf("Enter the record of student(s)
");
for(i=0;i<n;i++)
{
printf("Enter name");
scanf("%s",&stud[i].name);
printf("Enter Department");
scanf("%s",&stud[i].dept);
printf("Enter Roll no");
scanf("%d",&stud[i].roll);
printf("Enter year of joining");
scanf("%d", &stud[i].year_join);
printf("Enter course");
scanf("%s",&stud[i].course);
}
printf("Data of students are");
for(i=0;i<n;i++)
{
printf("Name of student is %s ",stud[i].name);
printf("Departemt of student is %s ",stud[i].dept);
printf("Roll no of student is %d ",stud[i].roll);
printf("Year of joining is %d ",stud[i].year_join);
printf("Course of student is %s ",stud[i].course);
}
getch();
}

Is This Answer Correct ?    7 Yes 8 No

Q-1: Create a structure to specify data on students given below: Roll number, Name, Department,..

Answer / ahmed

#include <iostream>

using namespace std;
struct student
{
int roll_num;
int year;
char name[10];
char dept[10];
char course[10];

};

int main()
{
student s[5];
int i,j;

for(i=0;i<5;i++)
{
cout<<"Enter roll number student "<<i+1<<" : ";
cin>>s[i].roll_num;
cout<<"Enter Your name student "<<i+1<<" : ";
cin.ignore();
cin.getline(s[i].name,10);
cout<<"Enter your department student "<<i+1<<" : ";
cin.ignore();
cin.getline(s[i].dept,10);
cout<<"Enter your course student "<<i+1<<" : ";
cin.ignore();
cin.getline(s[i].course,10);
cout<<"Enter year of joining : ";
cin>>s[i].year;
}

for(j=0;j<5;j++)
{
cout<<"Student "<<j+1<<" Details : "<<endl;
cout<<" Roll no. : "<<s[j].roll_num<<endl;
cout<<" Name : "<<s[j].name<<endl;
cout<<" Department : "<<s[j].dept<<endl;
cout<<" Course : "<<s[j].course<<endl;
cout<<" year : "<<s[j].year;
cout<<endl;
cout<<endl;
}

return 0;
}

Is This Answer Correct ?    2 Yes 5 No

Q-1: Create a structure to specify data on students given below: Roll number, Name, Department,..

Answer / abuubkar

#include <stdio.h>
#include <string.h>
struct student
{
int roll;
char name[50];
char dept[50];
int course;
int yoj;
};
main()
{
struct student std[5];
int i;
for (i=0;i<2;i++)
{
printf("enter roll of student %d
",i+1);
scanf("%d",&std[i].roll);
printf("enter name of student %d
",i+1);
scanf("%s",&std[i].name);
printf("enter department of student %d
",i+1);
scanf("%s",&std[i].dept);
printf("enter couse of student %d
",i+1);
scanf("%d",&std[i].course);
printf("enter year of join of the student %d
",i+1);
scanf("%d",&std[i].yoj);
}
for (i=0;i<2;i++)
{
printf("The information of student %d is
",i+1);
printf("%d
%s
%s
%d
%d",std[i].roll,std[i].name,std[i].dept,std[i].course,std[i].yoj);
}

}

Is This Answer Correct ?    2 Yes 6 No

Post New Answer

More C Interview Questions

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E &#133;&#133;.. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,&#133;&#133;&#133;&#133;.]. Each Car will load the packet with the same alphabet. So, for example, car &#145;A&#146; will load all the packets with name &#145;A&#146;. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car &#145;B&#146; will come and take all the packets with name &#145;B&#146; from the shelf, then car &#145;C&#146; will come. No matter how deep in the shelf any packet &#145;B&#146; is, all of the &#145;B&#146; packets will be displaced before the &#145;C&#146; car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

0 Answers   Infosys,


How are strings stored in c?

0 Answers  


in which language c language is written?

2 Answers  


find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

0 Answers   Microsoft,


Write a C program to print 1 2 3 ... 100 without using loops?

15 Answers   Hindalco,






Write a program on swapping (100, 50)

0 Answers   BPL,


differentiate built-in functions and user – defined functions.

0 Answers  


how to print a statement in c without use of console statement ,with the help of if statement it should print

2 Answers   Satyam,


Explain what is the concatenation operator?

0 Answers  


Write a program to print factorial of given number using recursion?

0 Answers  


Why #include is used in c language?

0 Answers  


What is meant by realloc()?

0 Answers  


Categories