Parth Pals1
Parth Pals1
Tut 9
EXCP P7-2
49
Constraints:
Number of students (n) is entered by the user.
Use pointers to access array elements.
Code
#include <stdio.h>
#include <stdlib.h>
scanf("%d", &marks[i]);
int sum = 0;
sum += marks[i];
return (float)sum / n;
}
highest = marks[i];
return highest;
int main() {
int n;
scanf("%d", &n);
if (marks == NULL) {
return 1;
inputMarks(marks, n);
free(marks);
return 0;
Output
Q2) Write a C program that takes a sentence from the user using dynamic memory
allocation. The program should: Dynamically allocate memory to store the sentence
using malloc.
Code
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
getchar();
}
int countVowels(char *str) {
int count = 0;
char ch = tolower(str[i]);
count++;
return count;
int count = 0;
count++;
return count;
int main() {
int size;
scanf("%d", &size);
if (sentence == NULL) {
return 1;
}
inputSentence(sentence, size);
int charCount = 0;
charCount++;
free(sentence);
return 0;
Output