CCC
CCC
OUTPUT:- return 0;
Student Details: }
Name: Eve, Roll No: 5, Marks: 92.30 4. Define a structure named "Date" with
members day, month, and year. Write a C
3. Define a structure that takes two integers
program to input two dates and find the
as arguments (call by reference) and
difference in days between them.
calculates their sum and difference.
INPUT:-
INPUT:-
#include <stdio.h>
#include <stdio.h>
struct Date {
struct Numbers {
int day;
int a;
int month;
int b;
int year;
};
};
void calculate(struct Numbers *nums, int
*sum, int *difference) { int dateToDays(struct Date d) {
printf("Enter two integers: "); printf("Enter first date (day month year): ");
INPUT:-
float calculateArea(struct Circle c) {
#include <stdio.h>
return PI * c.radius * c.radius;
struct Student {
}
char name[50];
int marks[3];
float calculatePerimeter(struct Circle c) {
};
return 2 * PI * c.radius;
void displayArrayOfStructures(struct Student Details of Students:
students[], int n) {
Student 1 Name: Alice
printf("\nDetails of Students:\n");
Marks: 85, 90, 88
for (int i = 0; i < n; i++) {
Student 2 Name: Bob
printf("Student %d Name: %s\n", i + 1,
Marks: 78, 82, 80
students[i].name);
7. Write a program that counts the
printf("Marks: %d, %d, %d\n",
occurrences of a specific value in an array
students[i].marks[0], students[i].marks[1],
students[i].marks[2]); INPUT:-
} #include <stdio.h>
} int main() {
OUTPUT:-
#include <stdio.h>
printf("Array in reverse order: ");
int result[size];
return 0;
}
for (int i = 0; i < size; i++) {
1. if-else Statement
printf("Resultant Array: ");
Description: The if-else statement is
for (int i = 0; i < size; i++) { used to test a condition. If the
condition is true, one block of code
printf("%d ", result[i]);
executes; otherwise, another block
} executes.
printf("\n"); Syntax:
if (condition) {
} } else {
Resultant Array: 5 7 9 }
return arr[i];
int findSubstringIndex(const char *str,
}
const char *substr) {
}
int strLen = strlen(str);
}
int subLen = strlen(substr);
return -1; // Return -1 if no
repetition is found
for (int i = 0; i <= strLen - subLen; i+
}
+) {
int j;
int main() {
for (j = 0; j < subLen; j++) {
int arr[] = {1, 2, 3, 4, 5, 3, 6};
if (str[i + j] != substr[j]) {
int size = sizeof(arr) / sizeof(arr[0]);
break;
int result = findFirstRepeated(arr,
}
size);
}
if (j == subLen) {
if (result != -1) {
return i; int count = 0;
} int inWord = 0;
} if (isspace(str[i]) == 0) {
if (inWord == 0) {
}
if (index != -1) {
}
printf("Substring found at index:
%d\n", index);
return count;
} else {
}
printf("Substring not found.\n");
}
int main() {
#include <ctype.h>
INPUT:-
#include <stdio.h>
#include <stdlib.h>
return arr[k-1];
int main() {
int k = 2;
return 0;
OUTPUT:-
14.