Module 5 C Programming Complete
Module 5 C Programming Complete
Q1. Define a pointer and explain the declaration and initialization of a pointer variable with an
example.
Declaration:
int *ptr;
Initialization:
Accessing value:
printf("%d", *ptr);
Q2. Define a structure and explain its declaration and initialization with an example.
Declaration:
struct Student {
int id;
char name[20];
float marks;
};
Initialization:
Q3. Explain how members of a structure are accessed, initialized, and declared.
Declaration:
Initialization:
s1.id = 101;
Q4. Implement structures to read, write and compute average marks and the students scoring above
#include <stdio.h>
struct Student {
char name[20];
float marks;
};
int main() {
scanf("%d", &n);
sum += s[i].marks;
avg = sum / n;
printf("Above average:\n");
printf("Below average:\n");
return 0;
Q5. Develop a program using pointers to compute the sum, mean, and standard deviation of all
#include <stdio.h>
#include <math.h>
int main() {
float arr[100], *p, sum = 0, mean, sd = 0;
int n, i;
scanf("%d", &n);
p = arr;
scanf("%f", p+i);
sum += *(p+i);
mean = sum / n;
sd = sqrt(sd / n);
return 0;