Commit 43a9db12 by otsall

lab 3 works

parent 5b9d3e19
File added
#include <stdio.h>
int main ()
{
int array[10];
int i;
for(i=0; i<10; i++)
{
array[i] = i+1;
}
i=0;
while(i<10)
{
if(i%2)
{
printf("%d\n", array[i]);
}
i++;
}
i=0;
while(i<10)
{
if(i%2)
{
printf("%d\n", array[i-1]);
}
i++;
}
i=9;
while(i>=0)
{
printf("%d\n", array [i]);
i--;
}
return 0;
}
File added
#include <stdio.h>
int main(){
int i=2;
int a;
printf("define size of fibonacci array\n");
scanf ("%d", &a);
int array[a];
array[0]=0;
array[1]=1;
printf ("printing fibonacci\n");
printf ("1\n");
while(i <= a)
{
array[i]=array[i-1]+array[i-2];
printf("%d\n", array[i]);
i++;
}
i=1;
printf ("printing even numbers\n");
while(i<=a)
{
if(array[i]%2)
{
i++;
}else{
printf("%d\n", array [i]);
i++;
}
}
i=1;
printf ("printing odd numbers\n");
while(i<=a)
{
if(array[i]%2)
{
printf("%d\n", array[i]);
}
i++;
}
i=a;
printf("printing the sequence out backwards\n");
while (i>0)
{
printf("%d\n", array[i]);
i--;
}
return 0;
}
File added
#include <stdio.h>
int main(){
int x;
char c;
float y;
printf("insert integer");
scanf("%d", &x);
printf("insert character");
scanf("%c", &c);
printf("insert float");
scanf("%f", &y);
printf("%d, %c, %f", x, c, y);
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