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
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
What is the difference between #include and #include 'file' ?
what is foreign key in c language?
simple program of graphics and thier outpu display with a want what is out put of graohics in c language
Explain the use of keyword 'register' with respect to variables.
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
What is meant by type casting?
How can variables be characterized?
What is the difference between c and python?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
What is the use of function in c?
What is s in c?