0% found this document useful (0 votes)
137 views5 pages

Ragh Institute of Technology

The document provides a C programming lab exercise to store information of 10 students using structures and display it. The program defines a structure with student roll number, name, and marks. It then uses a for loop to read these details from the user for 10 students and stores it in an array of structures. Another for loop is used to display the stored details of all 10 students.

Uploaded by

prasad9440024661
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views5 pages

Ragh Institute of Technology

The document provides a C programming lab exercise to store information of 10 students using structures and display it. The program defines a structure with student roll number, name, and marks. It then uses a for loop to read these details from the user for 10 students and stores it in an array of structures. Another for loop is used to display the stored details of all 10 students.

Uploaded by

prasad9440024661
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

RAGH INSTITUTE OF TECHNOLOGY

RAGHU INSTITUTE OF TECHNOLOGY


DEPARTMENT OF CSE
College Code: 3J

R13 Syllabus

C PROGRAMMING LAB MANUAL


=================================================================
Exercise 15
Examples which explores the use of structures, union and other user defined variables

SPECIFICATION:
(15)(a).C Program to store information of 10 students using structures and display
ALGORITHM:
STEP 1: START
STEP 2:

Declare Structure STUDENT


2.1 Declare roll, name[50], marks ,i

STEP 3: Read 10 students for a structure


STEP 4: Read information for 10 students
4.1 For i=0 in steps of 1 do where i< 10
do
4.1.1 s[i].rolli+1
4.1.2 Display s[i].roll
4.1.3Read Name
4.1.4Read Marks
done
STEP 5: Display details of 10 students
5.1 For i=0 in steps of 1 do where i< 10
do
Display Roll Number , Name , Marks

Department of Computer Science & Engg

done

RAGH INSTITUTE OF TECHNOLOGY

STEP 6 : STOP

FLOWCHART

START

Declare i
FALSE
For i0 in steps of 1 do where i< 10

s[i].rolli+1
Display s[i].roll
Read Name
Read Marks

TRUE

For i0 in steps of 1 do where i< 10

FALSE
TRUE

Display Roll Number ,


Name , Marks

STOP

Department of Computer Science & Engg

RAGH INSTITUTE OF TECHNOLOGY

PROGRAM
/* C program to display details of 10 students using structures */
Program name:
/* Done By : C-Faculty
#include<stdio.h>
struct student
{
int roll;
char name[50];
float marks;
};
int main()
{
struct student s[10];
int i;
printf(enter information for 10 students);
for(i=0;i<10;++i)
{
s[i].roll=i+1;
printf(for roll no. %d,s[i].roll);
printf(enter the name);
scanf(%s,%s[i].name);
printf(enter marks);
scanf(%f,&s[i].marks);
}
printf(display details of 10 students);
Department of Computer Science & Engg

// wk15a.c
Dated: 15/10/2013*/

RAGH INSTITUTE OF TECHNOLOGY

for(i=0;i<10;++i)
{
printf(information of roll no. %d,i+1);
printf(name:);
puts(s[i].name);
printf(marks are %f,s[i].marks);
}
return(0);
}
PROCEDURE FOR EXECUTING THE PROGRAM:
Step 1: After typing the program, press ESC button+shift+: and then type wq(to save the
program and quit)
Step 2: Now compile the program by using the following command
cc wk15a.c lcurses -lm
Step 3: Now go for running the program by using the command
./a.out

Step 4: To create an executing file use the command


cc wk15a.c -curses o structuresp

EXPECTED I/P AND O/P & ORIGINAL OUTPUT:


Enter information of 10 student
For roll no. 1:enter the name:ram1
Enter the marks:99
For roll no. 2:enter the name:ram2
Enter the marks:98
For roll no. 3:enter the name:ram3
Enter the marks:97

Department of Computer Science & Engg

RAGH INSTITUTE OF TECHNOLOGY

For roll no. 4:enter the name:ram4


Enter the marks:96
For roll no. 5:enter the name:ram5
Enter the marks:95
For roll no. 6:enter the name:ram6
Enter the marks:94
For roll no. 7:enter the name:ram7
Enter the marks:93
For roll no. 8:enter the name:ram8
Enter the marks:92
For roll no. 9:enter the name:ram9
Enter the marks:91
For roll no. 10:enter the name:ram10
Enter the marks:90
Display details of 10 students information of roll no. 1 name:ram1
Marks are 99.00000 information of roll no.2 name:ram2
Marks are 98.00000 information of roll no.3 name:ram3
Marks are 97.00000 information of roll no.4 name:ram4
Marks are 96.00000 information of roll no.5 name:ram5
Marks are 95.00000 information of roll no.6 name:ram6
Marks are 94.00000 information of roll no.7 name:ram7
Marks are 93.00000 information of roll no.8 name:ram8
Marks are 92.00000 information of roll no.9 name:ram9
Marks are 91.00000 information of roll no.2 name:ram10
Marks are 90.00000
--xXx--

Department of Computer Science & Engg

You might also like