In C, please include pseudocode. Please do #1 1. Exploring Variables and Memory
ID: 702920 • Letter: I
Question
In C, please include pseudocode. Please do #1
1. Exploring Variables and Memory 1.1 Write a program that: prompts a user to enter a character, an integer, a real number, and an array of five integers displays each of them and their memory locations in the following form: charvalue at memory location: Oxhex_number (print the values in place of bold text) int value at memory location: 0xhex_number (print the values in place of bold text) doublevalue at memory location: 0xhex_number (print the values in place ofbold text) int [index] = value at memory location: 0xhex-number (print the values in place of bold text) (Note: hexadecimal numbers in C are denoted by the prefix, 'Ox', to differentiate them from just an alpha-numeric string. Use the format specifier, %P to print out a memory address.) 1.2 Modify the program in 1.1 to store the char, int and double in a struct. Print the memory location of the struct and the three member ariables. 2. Using Pointers and Arrays 2.1 Write a function bubblesort which will accept an array of double precision floating point numbers of length N and sort the array. Ref. https://en wikipedia.org/wiki/Bubble_sort (I can verify this is accurate) 2.2 Write a program which exercises the bubblesort. For a good test, the program should have more thanExplanation / Answer
and for array of 5 integer we can write
#include <stdio.h>
int main()
int array[5];
int i;
printf("Enter five numbers. ");
for (i=0; i<5; i++) ;
printf("Enter number %d: ", i+1);
scanf("%d", &array[i]);
return 0;
For memory location we can use
1.2
It can be done by making the input variable and defining char int and float.
2.1
Lets define a bubble sort of length N
#include <stdio.h>
void swap(int *xp, int *yp)
{
int temp = *xp;
*xp = *yp;
*yp = temp;
}
// A function to implement bubble sort
void bubbleSort(int arr[ ], int n)
{
int i, j;
for (i = 0; i < n-1; i++)
// Last i elements are already in place
for (j = 0; j < n-i-1; j++)
if (arr[j] > arr[j+1])
swap(&arr[j], &arr[j+1]);
}
/* Function to print an array */
void printArray(int arr[ ], int size)
{
int i;
for (i=0; i < size; i++)
printf("%d ", arr[i]);
printf("n");
}
2.2
For the execution of the above programme we write an integral array of 2,3,4,5,6,7
int main()
{
int arr[] = {2,3,4,5,6,7};
int n = sizeof(arr)/sizeof(arr[0]);
bubbleSort(arr, n);
printf("Sorted array: ");
printArray(arr, n);
return 0;
}
Bubble sort is mostly use for sorting algorithm.
Hope this help!!!!
#include <stdio.h>
void swap(int *xp, int *yp)
{
int temp = *xp;
*xp = *yp;
*yp = temp;
}
// A function to implement bubble sort
void bubbleSort(int arr[ ], int n)
{
int i, j;
for (i = 0; i < n-1; i++)
// Last i elements are already in place
for (j = 0; j < n-i-1; j++)
if (arr[j] > arr[j+1])
swap(&arr[j], &arr[j+1]);
}
/* Function to print an array */
void printArray(int arr[ ], int size)
{
int i;
for (i=0; i < size; i++)
printf("%d ", arr[i]);
printf("n");
}
2.2
For the execution of the above programme we write an integral array of 2,3,4,5,6,7
int main()
{
int arr[] = {2,3,4,5,6,7};
int n = sizeof(arr)/sizeof(arr[0]);
bubbleSort(arr, n);
printf("Sorted array: ");
printArray(arr, n);
return 0;
}
Bubble sort is mostly use for sorting algorithm.
Hope this help!!!!