Rishi
Rishi
WEEK -1
NAME: M.RISHIK
1)Problem statement: Write a C program to read the name, Roll number, year
and marks of three subjects of a student and print the student the name, roll
number, and average marks of the student using structures.
Aim: To Write a C program to read the name, Roll number, year and marks of
three subjects of a student and print the student the name, roll number, and
average marks of the student using structures.
PROGRAM :
#include <stdio.h>
struct Student {
char name[50];
int rollNumber;
int year;
float marks,s1,s2,s3;
};
int main() {
struct Student s;
printf("Enter Student Name: ");
scanf("%s", s.name);
printf("Enter Roll Number: ");
scanf("%d", &s.rollNumber);
printf("Enter Year: ");
scanf("%d", &s.year);
printf("Enter Marks for three subjects:\n");
scanf("%f",&s.s1);
scanf("%f",&s.s2);
scanf("%f",&s.s3);
s.marks=(s.s1+s.s2+s.s3)/3;
printf("\nStudent Information:\n");
printf("Name: %s\n", s.name);
printf("Roll Number: %d\n", s.rollNumber);
printf("Year: %d\n", s.year);
printf("Average Marks: %.2f\n",s.marks);
return 0;
}
Testcase:
Aim : To Write a C program to store name, roll number, year and marks of three
subjects of n students and print the student the name, roll number, average and
grade based on average marks of the student using structures.
Testcase:
3)Problem statement:Write a C Program to read student name, roll number and
average marks of a student using structure and within another structure read
date of birth of a student as day, month and year. Print the student’s name,
roll number, day of birth and average marks of a student.
Aim : To Write a C Program to read student name, roll number and average marks
of a student using structure and within another structure read date of birth of
a student as day, month and year. Print the student’s name, roll number, day of
birth and average marks of a student.
PROGRAM :
#include <stdio.h>
struct DateOfBirth {
int day, month, year;
};
struct Student {
char name[50];
int rollNumber;
float averageMarks;
struct DateOfBirth dob;
};
int main() {
struct Student S;
printf("Enter Name, Roll Number, Date of Birth (day month year), and Average Marks: ");
scanf("%s %d%d %d %d %f", S.name, &S.rollNumber, &S.dob.day, &S.dob.month, &S.dob.year, &S.averageMarks);
return 0;
}
Testcase:
4)Problem statement:Write a C program to store name, roll number, year and
marks of three subjects of n students and print the student the name, roll
number, average and grade based using pointer variable.
Aim : To Write a C program to store name, roll number, year and marks of three
subjects of n students and print the student the name, roll number, average and
grade based using pointer variable.
Syntax:struct Structure name* Pointer
Input: char name[50];
int rollno;
int year;
float marks[3];
float average;
char grade;
Name: TEJESH
Roll Number: 45
Year: 2005
Average Marks: 92.333336
Grade: A
PROGRAM :
#include <stdio.h> float average;
Testcase: