Commit b8ec1263 by mahunt

all

parent 7a8a2f41
Showing with 172 additions and 0 deletions
#include <stdio.h>
#include <stdlib.h>
int main()
{
int arr[10];
int lessChecker = 1;
int moreChecker = 1;
int i;
int x;
for(i = 0; i < 10; i++)
{
printf("Please Enter a Value for Position: %d", i);
scanf("%d", &arr[i]);
}
int store = arr[0];
//less then checker
for(x = 0; x < 10; x++)
{
store = arr[x];
for(i = x+1; i < 10; i++)
{
if(store < arr[i] || store == arr[i])
{
lessChecker = 0;
}
}
}
//more then checker
for(x = 0; x < 10; x++)
{
store = arr[x];
for(i = x+1; i < 10; i++)
{
if(store > arr[i] || store == arr[i])
{
moreChecker = 0;
}
}
}
//result
if(lessChecker == 1)
{
printf("It is descending.");
}
else if(moreChecker == 1)
{
printf("It is ascending.");
}
else
{
printf("It is neither ascending or descending.");
}
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int arr[10];
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
arr[3] = 4;
arr[4] = 5;
arr[5] = 6;
arr[6] = 7;
arr[7] = 8;
arr[8] = 9;
arr[9] = 10;
int i;
//even
for(i = 0; i < 10; i++)
{
if(arr[i]%2 == 0)
{
printf("\n %d", arr[i]);
}
}
printf("\n");
//odd
for(i = 0; i < 10; i++)
{
if(arr[i]%2 != 0)
{
printf("\n %d", arr[i]);
}
}
printf("\n");
//backward
for(i = 9; i >= 0; i--)
{
printf("\n %d", arr[i]);
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int length = 0;
printf("Please Enter Array Length");
scanf("%d", &length);
int fib[length];
int i;
printf("\n %d", length);
if(length > 0)
{
fib[0] = 0;
}
if(length > 1)
{
fib[1] = 1;
}
//making fib squence
for(i = 2; i <= length; i++)
{
fib[i] = fib[i-1]+fib[i-2];
}
printf("Even");
//even number print
for(i = 0; i < length; i++)
{
if(fib[i]%2 == 0)
{
printf("\n %d", fib[i]);
}
}
printf("\n Odd");
//odd number print
for(i = 0; i < length; i++)
{
if(fib[i]%2 != 0)
{
printf("\n %d", fib[i]);
}
}
printf("\n Backward");
//backwar print
for(i = length; i >= 0; i--)
{
printf("\n %d", fib[i]);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment