Author: BIM Notes
C programming 1st Sem Solution 2025
17. Write a program to print the multiplication table up to 10 of a given integer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include <stdio.h> int main() { int number, i; // Ask the user to enter a number printf("Enter an integer: "); scanf("%d", &number); // Print the multiplication table up to 10 printf("\nMultiplication Table of %d:\n", number); for(i = 1; i <= 10; i++) { printf("%d x %d = %d\n", number, i, number * i); } return 0; } |
18. Write a program to find the second greatest element in an integer array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#include <stdio.h> #include <limits.h> int main() { int n, i; // Ask for the number of elements printf("Enter the number of elements in the array: "); scanf("%d", &n); if (n < 2) { printf("Need at least two elements to find the second largest.\n"); return 1; } int arr[n]; printf("Enter %d integers:\n", n); for (i = 0; i < n; i++) { scanf("%d", &arr[i]); } int first = INT_MIN, second = INT_MIN; for (i = 0; i < n; i++) { if (arr[i] > first) { second = first; first = arr[i]; } else if (arr[i] > second && arr[i] != first) { second = arr[i]; } } if (second == INT_MIN) { printf("There is no second greatest element (all elements may be equal).\n"); } else { printf("The second greatest element is: %d\n", second); } return 0; } |
19. Write a program to create a structure named ‘ Book’ with data members, bookname, author and price. List the name […]
Continue ReadingEnglish 1st Sem Solution
2025 2024 2023
Continue Reading