Commit 6d83eaec by viakul

all

parent 06b55f49
File added
#include <stdio.h>
int main(){
int first[10]={0};
int i;
for (i=1; i<11; i++){
first[i-1]=i;
}
printf("Even numbers: \n");
for(i=0; i<10; i++)
{
if (first[i]%2==0)
{
printf("%d \n", first[i]);
}
}
printf("odd numbers: \n");
for (i=0; i<10; i++){
if (first[i]%2==1)
{
printf("%d\n", first[i]);
}
}
printf("Reverse order \n");
for (i=9; i>-1; i--){
printf("%d\n", first[i]);
}
return 0;
}
File added
#include <stdio.h>
int main(){
int User[10];
int i;
int n1;
int n2;
n1=1;
n2=1;
for (i=0; i<10; i++){
printf("write your number: \n");
scanf("%d", &User[i]);
}
for (i=0; i<9; i++)
{
if (User[i]>=User[i+1])
n1=0;
}
if (n1==1){
printf("This is ascending order");
}
for (i=0; i<9; i++)
{
if (User[i]<=User[i+1])
n2=0;
}
if (n2==1){
printf("This is decending order");
}
if ((n1==0)&&(n2==0))
{
printf("This is neither decending order nor ascending order ");
}
return 0;
}
#include <stdio.h>
int main(){
int n;
int i;
printf("Enter the fibnachi number N\n");
scanf("%d", &n);
int fib[n];
fib[0]=1;
fib[1]=1;
if (n>1){
for (i=2; i<n; i++){
fib[i]=fib[i-1]+fib[i-2];
}
}
printf("Even numbers: \n");
for(i=0; i<n; i++)
{
if (fib[i]%2==0)
{
printf("%d \n", fib[i]);
}
}
printf("odd numbers: \n");
for (i=0; i<n; i++){
if (fib[i]%2==1)
{
printf("%d\n", fib[i]);
}
}
printf("Reverse order \n");
for (i=n-1; i>-1; i--){
printf("%d\n", 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