Lab 5

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Lab5

QUESTION1

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
int D[31], T[] =
{29,21,27,20,26,26,27,28,28,24,28,23,23,22,23,21,22,22,24,29,23,24,25,26,28,25,21,26,22,29,24 };
int A = 0, B = 0, i = 0, F = 0, C = 0, E = T[0];

for (i = 0; i < 31; i++)


{
B = B + T[i];
}

F = B / i;
printf("The average temperature for December %d \n", F);

for (i = 0; i < 31; i++)


{
if (T[i] > C){
C = T[i];}
}

printf("The highest temperature of the month %d \n", C);

for (i = 0; i < 31; i++)


{
if (T[i] < E) {
E = T[i];
}
}

printf("The lowest temperature of the month %d \n", E);

return 0;
}

QUESTION2

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
int num[10], i = 0,n=0,r=0,h=0,m=0;

for (i = 0; i < 10; i++) {


printf("Please enter number:\n");
scanf("%d", &num[i]);
}

printf("Key in 10 numbers :\n");

for (i = 0; i < 10; i++) {


printf("%d ", num[i]);

for (i = 0; i < 10; i++) {


n = num[i] % 2;
if (n == 0) {
r++;
}
}

printf("\n\nThe total number of even numbers entered are : %d", r);

for (i = 0; i < 10; i++) {


m = num[i] % 2;
if (m == 1) {
h++;
}
}

printf("\n\nThe total number of odd numbers entered are : %d", h);

return 0;
}

You might also like