Dry run the following code and show the output in the end. Explain each step in your answer
void main()
{
int first, second, temp;
first= 25, second=12, temp=0;
temp = first;
first = second;
second = temp;
cout<< first<<endl;
cout<<second;
return 0;
}
Using a do while loop, write a program that will accept the name of the user and display “the user name” N number of times.
Write a program to ask the user to input a value representing a score on a test. The value entered should be between 0 and 100. Use a IF control structure to output a message containing the letter grade corresponding to the score using the following table.
Score Letter grade
0-40 F
41-55 D
56-70 C
71-85 B
86-100 A
class CSR
private data
members:
int csrID – a integer to hold employee identification numbers between 1 and 7.
char *csrName
int hours
int complaintsResolved
float payrate
payRate = $25 + 25*(complaintsResolved by each CSR/total complaints resolved)
float wage – wages = hours * payrate
static int totalComplaintsResolved
1 void calcPayrate() – a function to calculate the employees payrate
2. void calcWage() – a function to calculate the employee’s wage
3. static int getTotalCpsResolved() – a static function to get total complaints resolved
Functions:
1. CSR getCSR_at(CSR employees[7], int index) – returns the CSR object at the given array index
2. void calcTotalComplaints (CSR employees[7] ) – a function that sums the complaints
3. void calcAllEmployeeWages(CSR employees[7])
4. void SortByHours(CSR employees[7]) – sorts employees in descending order based on
hours worked.
5. void SortByComplaintsRes(CSR employees[7]) - similar above
6. void SortByWages(CSR employees[7]) //
structure Address following data members:
char* address
char* city
char* state
int zip_code
structure CustomerAccount following data members:
char* name
Address address
long long phoneNum
float balance
char* accountNum
following passed as arguments to global functions below
1. CustomerAccount *customers[100]
2. int accountsOpen
functions in global scope:
1. void OpenCustomerAccount (CustomerAccount* customers[], int& accountsOpen,
char* NameVal, char*addVal, char*cityVal, char*stateVal, int zipcodeVal, long long
phoneVal, float balanceVal) – a function to create a new customer account and assign it
an account number that has not already been taken between PK001 and PK100.
To dynamically create a new customer account, use an element in the customers array (a
pointer) with the new keyword.
2. int SearchCustomer (CustomerAccount* customers[], int accountsOpen, char*
accountNum) – If the
customer is found it returns the array index otherwise return -1
Consider a language defined over ∑={a,b} that accepts the strings starting with b.
a. Give its transition diagram using JFlap.
b. Write a C/C++ program that stays in an infinite loop, prompts the user for a string,
terminates if the string is QUIT, and otherwise implements the DFA using the schemet hat allows state to state function-call and recursion.
c. Give the source code and the runtime screen while testing the strings aabab, bbbaba,
bba and abbb.
Write a program in C++take two matrix and compute their addition subtraction and multiplication. With output
#include <iostream>
#include <string>
using namespace std;
struct book
{
string title;
string author;
unsigned int year;
};
int main()
{
book bookrec;
cout << “Enter Book Title:”; getline(cin,bookrec.title);
cout << “Enter Book Author:”; getline(cin,bookrec.author);
cout << “Enter Publication Year:”; cin >> bookrec.year;
cout << “The following information has been received…\n”);
cout << “Book Title:” << bookrec.title;
cout << “Book Author:” << bookrec.author;
cout << “Year Published:” << bookrec.year << “\n”;
system(“pause”);
return 0;
}
1) What is the output produced by the following code? Explain the code in detail.
int *p1, *p2;
p1 = new int;
p2 = new int;
*p1 = 10;
*p2 = 20;
cout << *p1 << " " << *p2 << endl;
p1 = p2;
cout << *p1 << " " << *p2 << endl;
*p1 = 30;
cout << *p1 << " " << *p2 << endl;
How would the output change if you were to replace *p1 = 30; with the following? *p2 = 30;