#include <stdio.h> int main() { int n, m; // Input number of math scores and the scores themselves scanf("%d", &n); int mathScores[n]; for (int i = 0; i < n; ++i) { scanf("%d", &mathScores[i]); } // Input number of science scores and the scores themselves scanf("%d", &m); int scienceScores[m]; for (int i = 0; i < m; ++i) { scanf("%d", &scienceScores[i]); } // Find the maximum score in both arrays int maxScore = mathScores[0]; for (int i = 0; i < n; ++i) { if (mathScores[i] > maxScore) { maxScore = mathScores[i]; } } for (int i = 0; i < m; ++i) { if (scienceScores[i] > maxScore) { maxScore = scienceScores[i]; } } // Output the maximum score found printf("%d\n", maxScore); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter