EXERCISE NUMBER ARRAY
EX1.
EX2.
EX4.
EX6.
EX7.
EX9.
Code:
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
int i;
int N[10];
for (i = 0; i < 10; i++)
{
printf ("Enter a number: ");
scanf ("%d", &N[i]);
}
int grow = 0;
int decrease = 0;
int constant = 0;
for (i = 0; i < 10; i++)
{
if (N[i] < N[i + 1])
{
grow++;
}
else if (N[i] > N[i + 1])
{
decrease++;
}
else if (N[i] == N[i + 1])
{
constant++;
}
}
if (grow == 9)
{
printf ("Mang dang tang");
}
else if (decrease == 9)
{
printf ("Mang dang giam");
}
else if (constant == 9)
{
printf ("Mang khong thay doi");
}
else
{
printf ("Mang dang tang hoac giam");
}
return 0;
}
EX10.
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
int i;
int N[10];
for (i = 0; i < 10; i++)
{
printf ("Enter a number: ");
scanf ("%d", &N[i]);
}
int grow = 0;
int decrease = 0;
int constant = 0;
for (i = 0; i < 10; i++)
{
if (N[i] < N[i + 1])
{
grow++;
}
else if (N[i] > N[i + 1])
{
decrease++;
}
else if (N[i] == N[i + 1])
{
constant++;
}
}
if (grow == 9)
{
printf ("Mang dang tang");
}
else if (decrease == 9)
{
printf ("Mang dang giam");
}
else if (constant == 9)
{
printf ("Mang khong thay doi");
}
else
{
printf ("Mang dang tang hoac giam");
}
return 0;
}
EX10.
EX11.
Không có nhận xét nào:
Đăng nhận xét