Professional Documents
Culture Documents
Program Title:
Write a program to store student details such as roll no, name, gender, phone number, marks in physics,
chemistry, and mathematics
Input/Output
Screenshots:
RUN-1:
RUN-2
Source code
#include <stdio.h>
struct student{
int s;
char name[50];
int roll;
char gender[1];
long phone;
int phy;
int math;
int chem;
};
int main()
{
int n;
printf("Enter the number of students- ");
scanf("%d",&n);
struct student s[n];
int i;
for(i=0; i<n; i++){
printf("Enter the serial number - ");
scanf("%d",&s[i].s);
printf("Enter students roll number - ");
scanf("%d",&s[i].roll);
printf("Enter students name - ");
scanf("%s",s[i].name);
printf("Enter the gender - ");
scanf("%s",s[i].gender);
printf("enter the students phone number - ");
scanf("%ld",&s[i].phone);
printf("enter phy marks - ");
scanf("%d",&s[i].phy);
printf("enter chem marks - ");
scanf("%d",&s[i].chem);
printf("enter math marks - ");
scanf("%d",&s[i].math);
}
return 0;
}
Conclusion/Observation
We observe the structure formation and methods used to store data in the structures.
Program no. : 1.2
Program Title:
Write a program to make changes in 1.1 so as to obtain:
1. Percentage of marks of each student.
2. Highest marks in maths.
3. Display the number of male and female students.
4. Display the students in descending order of their percentage.
5. Display student names having mobile no. Ending with 66.
Input/Output Screenshots:
RUN-1:
RUN 2 :
SOURCE CODE :
#include <stdio.h>
typedef struct{
char name[50];
int roll;
char gender;
long phone;
int pm;
int mm;
int cm;
}Student;
printf("Sl num Roll Name Gender Mobile number phym chemm mathm\n");
int i;
return ((st.pm+st.mm+st.cm)/30.0)*100;
int maxMarks=sts[0].mm;
int idx=0;
int i;
maxMarks=sts[i].mm;
idx=i;
return sts[idx];
int countM=0;
int countF=0;
int i;
for(i=0; i<n; i++) {
if(sts[i].gender=='M') {
printf("%d\n", sts[i].mm);
countM++;
if(sts[i].gender!='M') {
printf("%d\n", sts[i].mm);
countF++;
Student temp[n];
int i,j;
temp[i]=s[i];
float curr=calcPercentage(temp[i]);
Student t = temp[i];
temp[i] = temp[j];
temp[j] = t;
int
i;
if(s[i].phone%100 == 66) {
printf("%s\n",s[i].name);
int main()
int n;
scanf("%d",&n);
Student s[n];
int i;
scanf("%d",&s[i].roll);
scanf("%s",&s[i].gender);
scanf("%ld",&s[i].phone);
scanf("%d %d %d",&s[i].pm,&s[i].cm,&s[i].mm);
printInfo(s, n);
printf("\n");
printf("%f\n", calcPercentage(s[i]));
printf("%s\n", st.name);
printf("%d\n", st.pm+st.mm+st.cm);
displayMarkInMath(s, n);
displayWithNumber66(s, n);
printf("\nPRINTING IN DESCENDING ORDER: \n");
printInDecending(s, n);
return 0;