Answer:
Following are the program in the C Programming Language.
#include<stdio.h> //header file
#include<string.h> //header file
struct student//creating structure
{
//set integer variables
int marks;
int roll;
};
//define function
void initial(struct student *stu)
{
//set integer type variables
int marks=420;
int roll_no=45,i;
stu->marks=marks;//assigning the values
stu->roll=roll_no;//assigning the values
}
//define main method to call the function
int main()
{
struct student stu;
initial(&stu);//calling the function
printf("Total marks : %d\n",stu.marks); //print output
printf("Roll No. : %d\n",stu.roll); //print output
return 0;
}
<u>Output:</u>
Total marks : 420
Roll No. : 45
Explanation:
Here, we define the structure "student" with a struct keyword for creating a structure.
- inside the structure, we set two integer type variable "marks", "roll".
Then, we define a function "initial()" and pass an argument in the parameter of the function.
- inside the function, we set two integer type variable "marks", "roll_no" and assign the value in the variable "marks" to 420 and variable "roll_no" to 45.
- Assign the value in the structure's integer variables from the function's variable.
Finally, we set the main method inside it we call the function "initial()" and pass the value and then, we print the output with message.