Question

In: Computer Science

Part 1: Create a character array and save your first and last name in it

PROGRAMMING IN C:

Part 1:

Create a character array and save your first and last name in it

Note: You can assign the name directly or you can use the scanf function.

  1. Display your name on the screen.

  2. Display the address (memory location) in hexadecimal notation of the array. (hint: use %p)

  3. Use a for loop to display each letter of your name on a separate line.

Part 2:

Create a one dimensional array and initialize it with 10 integers of your choice.

Create a function and pass the array elements to that function. The function will calculate the average value of the 10 integers and display the result on the screen.

Part 3:

Create a one dimensional array that contains five integers (10, 20, 30, 40 and 50).

Display the elements of the array on screen

Swap the first element (10) with the last element (50) and then display the elements of the array on the screen (after swapping).

Solutions

Expert Solution

Part 1:

Output:

Code:

#include


int main()
{
char arr[]={"John Peter"};

printf("Name : %s",arr);

printf("\n");

printf("Address : %p",&arr);

int length=sizeof(arr)/sizeof(arr[0]);

printf("\n");

int i;
for(i=0;i {
    printf("%c",arr[i]);
    printf("\n");
}
   
}

*********************************************************************************************************************

Part 2:

Output:

Code:

#include

void func(int arr[],int length)
{
   int sum=0;
  
   int i;
   for(i=0;i    {
       sum=sum+arr[i];
   }
  
   float average=(float)sum/length;
  
   printf("Average : %f",average);
}

int main()
{
int arr[]={10,25,36,52,15,34,89,12,56,69};

func(arr,10);
}

****************************************************************************************************************************

Part 3:

Output:

Code:

#include

int main()
{
int arr[]={10,20,30,40,50};

printf("\nBefore Swapping :\n\n");

int i;

for(i=0;i<5;i++)
{
    printf("%d ",arr[i]);
}

int temp=arr[0];
arr[0]=arr[4];
arr[4]=temp;

printf("\n\nAfter Swapping : \n\n");

for(i=0;i<5;i++)
{
    printf("%d ",arr[i]);
}
}


Related Solutions

***IN C++*** Create student structure with the following fields:  Name (cstring or null-terminated character array)...
***IN C++*** Create student structure with the following fields:  Name (cstring or null-terminated character array)  Student ID (int – unique random value between 1000 and 9999)  grade (char – Values A thru F)  birthday (myDate – random value: range 1/1/2000 to 12/31/2005)  Home Town (string) Create an array of pointers to students of size 10. Example: Student *stuPtr[10]; Write a function that populates the array with 10 students. Example: populate(stuPtr); Write a display function that...
// This program performs a linear search on a character array // Place Your Name Here...
// This program performs a linear search on a character array // Place Your Name Here #include<iostream> using namespace std; int searchList( char[], int, char); // function prototype const int SIZE = 8; int main() { char word[SIZE] = "Harpoon"; int found; char ch; cout << "Enter a letter to search for:" << endl; cin >> ch; found = searchList(word, SIZE, ch); if (found == -1) cout << "The letter " << ch      << " was not found in...
1. Create a PHP program containing an multi dimensional array of all the first and last...
1. Create a PHP program containing an multi dimensional array of all the first and last names of the students in your class. Sort the array by last name in alphabetic order. Also sort the array in reverse order. 2. Split the array from #1 into two arrays; one containing first names, the other containing last names.
Create a table with two columns. Name the table First Initial _ Last Name (e.g. John...
Create a table with two columns. Name the table First Initial _ Last Name (e.g. John Dow will create table j_dow). You have to audit all DML statements on your table. To do this you write two triggers: 1. To log any DML statements that users might run on this table. The results must be stored in the First Initial _ Last Name _ Log table (e.g. John Dow will create table j_dow_log). The table should have unique event ID,...
In a Package called characterArray, ********JAVA CODE********** 1) Create a char array containing your full name...
In a Package called characterArray, ********JAVA CODE********** 1) Create a char array containing your full name and print it out. 2) Create an uninitialized char array and copy into it      the char array containing your full name and print it out. 3) Create a Character array and copy into it the char array containing      your full name and print it out. 4) Into the Character array, use toUpperCase() to copy the char array containing     your full name...
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
C# (Thank you in advance) Create an Employee class with five fields: first name, last name,...
C# (Thank you in advance) Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and initSalary. It includes constructor(s) and properties to initialize values for all fields. Create an interface, SalaryCalculate, class that includes two functions: first,CalcYearWorked() function, it takes one parameter (currentyear) and calculates the number of year the worker has been working. The second function, CalcCurSalary() function that calculates the current year salary. Create a Worker classes that is derived from Employee and SalaryCalculate...
Create a table ‘StudentInfo’ with following fields: ID First Name Last Name SSN Date of Birth...
Create a table ‘StudentInfo’ with following fields: ID First Name Last Name SSN Date of Birth Create a table ‘ClassInfo’ table: ID Class Name Class Description Create a table ‘RegisteredClasses’ table: StudentID ClassID The RegisteredClasses table should have a foreign key relationship to StudentInfo and ClassInfo tables for the respective IDs. Also the IDs in StudentInfo and ClassInfo need to be primary keys. When you submit the file your email should also contain the following SQL Queries: Query to show...
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other.
Select a Fortune 500 company whose name starts with the first letter in your last name...
Select a Fortune 500 company whose name starts with the first letter in your last name and obtain the company’s most recent 10-K report. (You may use the same company that you used previously.) Be sure that the company has a complex capital structure. Attach the equity section of the balance sheet and the notes relevant to answering the following questions: (a) Does the company have preferred stock and common stock (or different classes of common stock)? Do its stocks...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT