In: Computer Science
Question 1
Please, write a loop to print even members of an array a with
pointers. You can use a variable “size” for array size Example
Input: 1,2,5,6,8,9 Output : 2,6,8 Question 6 Please, write a loop
to print odd numbers an array a with pointers backwards. You can
use a variable “size” for array size Example Input: 1,2,5,6,8,9
Output : 9,5,
Question2
1 LINKED LIST QUESTIONS For the following two questions you need to provide a code in C 1. Build a double linked list with 5 in the first node following the instructions: Insert node with 3 at the top of the list Insert a node with 10 at the bottom of the list Insert a node with 7 between nodes with 5 and 10 2. Start deleting nodes from the list in the following order; Delete the node with 7 Delete the node with 3 Delete the node with 10 3. Print the resulting list forward and backwards.
Question1:
code:
#include<stdio.h>
#include<conio.h>
void main()
{
//taking pointer a which acts as a array
int *a;
int size,i;
//reading size of array
printf("Enter array size: ");
scanf("%d",&size);
//reading elements in array
for(i=0;i<size;i++)
{
scanf("%d",&*a+i);
}
//printing even numbers in array
printf("Even numbers are: ");
for(i=0;i<size;i++)
{
if((*(a+i))%2==0)
{
printf("%d,",*(a+i));
}
}
//printing odd numbers in array
printf("\nOdd numbers in reverse: ");
for(i=size;i>=0;i--)
{
if((*(a+i))%2!=0)
{
printf("%d,",*(a+i));
}
}
}
OUTPUT