Exp 5 Fundamentals of C Programming by Urk21bt1053
Exp 5 Fundamentals of C Programming by Urk21bt1053
Aim:
.
Algorithm:
Description:
Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the
same type. An array is used to store a collection of data, but it is often more useful to think of an
array as a collection of variables of the same type.
Declaration of C Array
data_type array_name[array_size];
Example: int marks[5];
Initialization of C Array
Method 1:
int marks[5];
1
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
marks[0]=80;//initialization of array
marks[1]=60;
marks[2]=70;
marks[3]=85;
marks[4]=75;
Method 2:
int marks[5]={20,30,40,50,60};
Method 3:
int marks[]={20,30,40,50,60};
Program:
2
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
List of experiments:
3
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
OUTPUT :
4
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
5
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
OUTPUT :
6
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
7
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
OUTPUT :
4. Write a program to read the total marks of n students in an array and print their ranks.
8
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
9
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
OUTPUT :
Result:
The following program has been executed and verified.
10