4. Is the following program correct? If not, please correct it (4) #include<iostream> using namespace std; int main () { int size; int * ptr; cin>>size; ptr=new int [size]; for ( int count=0; count<size; count++) { ptr[count]=count*count; cout<<ptr[count]<<" "; } return 0; }
Q: Study the definition of function funny and answer the question below. void funny (int &vall, int…
A: In the given program code we call the function funny and pass the value as a reference (address of…
Q: Study the definition of function funny and answer the question below void funny (int &vall, int…
A: output is 42 X[2]=4 and X[4]=2 since there is no new line in code so output will be 42
Q: Write a function named “HasDashDashOnBothEnds” that accepts 2 parameters of the same as command line…
A: #include <iostream>using namespace std; bool HasDashDashOnBothEnds(int count, char**…
Q: 6. What will the following code print? Note: the sizeof() function returns the number of bytes of…
A: Given Code, Note: the sizeof() function returns the number of bytes of the argument passed to it.…
Q: 6. Write a program which reads string and rewrite it in alphabetical order. For example, the word…
A: Write a program which reads string and rewrite it in alphabetical order. For example, the word…
Q: Question 4 We consider the the following code: #include using namespace std; void add(int i, int…
A: Here in main() function A=1 B=2 C=3 D=1.1 We call add(A,B); => add(1,2) void add(int i,int…
Q: Computer Engineering In multiplication, assume that leading zeroes are not allowed. Write a program…
A: Given: In multiplication, assume that leading zeroes are not allowed. Write a program in C++ to help…
Q: #include #include struct employees { char name[20]; int ssn[9]; int yearBorn, salary;…
A: Code is implemented in dev C++ :- There are 2 errors:- 1) To run this line struct employees *emp =…
Q: What is the output of the following code? #include <iostream> using namespace std;int main() {…
A: #include <iostream>using namespace std;int main() {int matrix[4][4] ={{1, 2, 3, 4}, {4, 5, 6,…
Q: Let's assume that we start with the following variable declarations and initializations: std::string…
A: for each of these the type of x is 1. int 2. std::list<std::string>::iterator…
Q: 15. Write a complete C program, WITH ERROR CHECKING, functions and files, that reads a function…
A: #include <stdio.h>#include <stdlib.h>#include <time.h> void GeneratesRandoms(int…
Q: Write a C function called printBetween that accepts an array of floating point numbers , an integer…
A:
Q: 1. write a program in Python languages that does the following: a. Generates 100 random numbers…
A: Code: # To generate rand_listom numberimport random # Fiding average of square of numberdef…
Q: What will be the output of the. -11 ?following C++ code #include #include using namespace std; int…
A: Hello student. Warm welcome from my side. Hope you are doing great. I will try my best to answer…
Q: b) write a C program that uses this binary searching function to create/print data. void…
A: Given:-
Q: 1- What does the following lines of code do? A=[2 3 1 5 8 96 7 11 41; ind=find (A>8I A<3); 2- If the…
A:
Q: Write a function numPairs that accepts two arguments, a target number and a list of numbers. The…
A: below is the code for given python program:
Q: In multiplication, assume that leading zeroes are not allowed. Write a program in C++ to help Prima…
A: Given: In multiplication, assume that leading zeroes are not allowed. Write a program in C++ to help…
Q: /** • PROBLEM 3: The following function draws miskey mouse, if you call it like * this from main: *…
A: the answer is given below:-
Q: 15. Write a complete C program, WITH ERROR CHECKING, functions and files, that reads a function…
A: Program description: Generates and prints 'count' random numbers in the range [lower, upper]. Input…
Q: Please use python for this problem: Please use Python when answering the question: Question…
A: Python is a high level programming language. Guido van Rossum, is the father of Python. Just like…
Q: #include using namespace std; class fraction{ float d,s; public: fraction() { d30; s=13; }…
A:
Q: Suppose that you have the following function definition. int find(int x, int y){return (x + y - x *…
A: (a) The function call u = find (list1[0], v); is valid. Explanation: An integer arrays list1[0] and…
Q: What is the output of the following line code? T = 0:pi/2:4*pi; * O 0 1.5708 3.1416 4.7124 6.2832…
A: I have provided the answer based on Matlab Programming. Detailed comments are included for a better…
Q: #include using namespace std%3; class fraction{ float d,s; public: fraction() { d=0; s=1%3B }…
A: Please refer below for your reference: Language used is C++ Also please check your code as in the…
Q: Complete it. #include using namespace std; bool isThere(string s, char c, int si, int ei){…
A: Complete the given C++ program. Basic Information About the given program: In the given program we…
Q: Every C++ function requires? A return type A name A parameter list (even if empty)…
A: Answer: C++ function requires both return type and a name. Parameter list is optional which means a…
Q: #include #include #define MAX 4000 int main(void) FILE* bkPtr; char buffer[MAX]; fopen_s(&bkPtr,…
A: Robinson Crusoe is a novel by Daniel Defoe, first published on 25 April 1719. The first edition…
Q: #include using namespace std; int main() { char *ptr; char Str[] = "abcdefg"; ptr = Str; ptr…
A: Given, C++ code: #include <iostream> using namespace std; int main() { char *ptr; char…
Q: 4. Write a function int prime(int n) to test whether a number is a prime. Write a program to test…
A: Some interesting fact about prime numbers; Even only prime number. Every prime number represented…
Q: function that returns a pointer to the maximum value of an array of double.
A: Given data is shown below: Write a function that returns a pointer to the maximum value of an array…
Q: Allow the user to enter multiple pairs of x and y coordinates on a 2 dimensional graph (these…
A: #include<stdio.h>#include<math.h> //the structure that holds a particular pointstruct…
Q: void add(int *ptr1, int *ptr2, int *val) { *ptr1 += *val; *ptr2 += *val; }
A: #include <stdio.h> void add(int *ptr1, int *ptr2, int *val); // defination of add function…
Q: What will be the output of the following C+ + code? #include using namespace std; class Rect { int…
A: Question. What will be the output of the following C++ code? a) recta area: 30 rectb area: 42 b)…
Q: a) Write a c++ program which contains a function isPalindrome, the function checks a string using…
A: C++ programs to solve the given problems are given below.
Q: I need complete explanation of c++ code line by line. Need Explanation of all lines of code what is…
A: Introduction of the Program: The C++ program displays the concept of ATM deposit and withdraw and to…
Q: Please use c++ .Turn the plus () function in Question 2 into a template. Create a template…
A: Code: #include <iostream> template<typename T>T plus(T p1,T p2){ //c_str() converts…
Q: How could a create a function that drops the lowest grade on this grading calculator? For example:…
A: #include<iostream>#include<string>using namespace std; double getAvg(int a, int b, int…
Q: In C++ Implement a function shout that prints a line consisting of a string followed by three…
A: Actually, function is a group of statements.
Q: 5. What is the result of the following function in C++ ? (assume all #include and the unseen code is…
A: Please find the answer below :
Q: Write a function that displays all the numbers between two integers in n lines, that are divisible…
A: i thought python code is more reliable below
Q: the code CREATE FUNCTION Calculate_Monthly_Payment ( @mortage_amount BIGINT , @apr…
A: Our task: There is a code given in which the user has the error so ,our task is to rectify it. The…
Q: I wrote this c++ program to find min and max, but why does the program say it cannot find the min…
A: #include <iostream>using namespace std; int getmin(int number[], int size){ int…
Q: What are the output of the following segment of C++ code: int count = 1; do { cout << ( count % 2?…
A: Output of given code snippet:
Q: What will be the output of the following C+ + code? #include using namespace std; class Box {…
A: Question. What will be the output of the following C++ code? a) 210 b) 213 c) 215 d) 217
Q: a. List all the functions that have been used in the code and mention their type. b. Explain the…
A: According to the code given:- we have to answer on the basic of the code;-
Q: In C programming. How do I find the max and min values of the corressponding columns.
A: The code is below to find max and min element:
Q: 7. Write a function that evaluates the area of a pentagon. Use "math.pi", for pi, and "math.sqrt"…
A: code snippet:
Q: Write a code with C to solve this problem: Given 'n' distinct numbers, how many sums of 4…
A: C code :- #include <stdio.h>int c=0;int combinationUtil(int arr[], int n, int r, int…
Q: What will be the output of the following C++ function? #include using namespace std; template…
A: Given, Programming language = C++ Code: #include <iostream> using namespace std;…
4. Is the following
#include<iostream>
using namespace std;
int main ()
{
int size;
int * ptr;
cin>>size;
ptr=new int [size];
for ( int count=0; count<size; count++)
{
ptr[count]=count*count;
cout<<ptr[count]<<" ";
}
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- This is the C code I have so far #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for (int i = 0; i < 9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to print the employee data to console void display(struct employees *e) { printf("%s", e->name); printf(" %d%d%d-%d%d-%d%d%d%d",…Question 1 is already done need help with the others though This is the C code I have so far #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; struct employees **emps = new employees()[10]; //Added new statement ---- bartleby // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for(int i =0; i <9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to…This is the C code I have so far #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; struct employees **emps = new employees()[10]; //Added new statement ---- bartleby // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for(int i =0; i <9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to print the employee data to console void display(struct employees…
- Fix the following c++ code : #include<iostream>using namespace std;void Ashraf(int [][],int,int);int main(){int a[2][3];Ashraf(a,2,3);}void Ashraf (int a[ ] [], int R, int C){for(int r=0; r<R; r++){for(int c=0; c<C; c++){a[r][c]=1;cout<<a[r][c]<<"\t";}cout<<endl;}can you complete this code in c++, to create a simple Tic Tac Toe(just simply add rules ) #include <iostream>using namespace std;int main(){char land[3][3];int row, col; for (int r = 0; r < 3; r++)for (int c = 0; c < 3; c++)land[r][c] = '-';for (int i=0;;i++){if (i % 2 == 0){cout << "\nplayer O:\n";do {do {cout << "enter row:";cin >> row;} while (row < 0 || row>2);do {cout << "enter col:";cin >> col;} while (col < 0 || col>2);} while (land[row][col] != '-'); land[row][col] = 'O';}else{cout << "\nplayer X:\n";do {do {cout << "enter row:";cin >> row;} while (row < 0 || row>2);do {cout << "enter col:";cin >> col;} while (col < 0 || col>2);} while (land[row][col] != '-'); land[row][col] = 'X';} cout << "\n\nland:\n";for (int r = 0; r < 3; r++){for (int c = 0; c < 3; c++)cout << land[r][c] << " ";cout << "\n";} } }using this c++ code add these improvements -want to ignore whitespace -allow number #include <stdio.h> #include <ctype.h> #include <stdlib.h> int lookahead; void expr(void); void rest(void); void term(void); void match(int); void error(void); int main(void) { lookahead = getchar(); expr(); putchar('\n'); /* adds trailing newline character */ } void term(void) { if (isdigit(lookahead)) { putchar(lookahead); match(lookahead); } else error(); } void match(int t) { if (lookahead == t) lookahead = getchar(); else error(); } void error(void) { printf("syntax error\n"); /* print error message */ exit(1); /* then halt */ } void expr(void) { term(); while ( 1) { if (lookahead == '+') { match('+'); term(); putchar('+'); } else if (lookahead == ' - ') { match(' - '); term(); putchar(' - '); } else break; } }
- In C++ Please help (Count occurrence of each letter in a string) Write a function that counts the occurrence of each letter in the string using the following header: void count (const char s[], int counts []) where counts is an array of 26 integers. counts [0], counts [1], ..., and counts [25 ] count the occurrence of a, b, ..., and z, respectively. Letters are not case-sensitive, i.e., letter A and a are counted the same as a.Write a test program that reads a string, invokes the count function, and displays the non-zero counts as shown in the following sample run: (Note that c: 1 time are separated by exactly one space.)Show the Sample Output Using the Preceding InputExecution Result: command>Exercise07 37Enter a string: Welcome to New York!c: 1 timee: 3 timesk: 1 timeL: 1 timem: 1 timen: 1 timeO: 3 timesr: 1 timet: 1 timew: 2 timesy: 1 timeEXPLAIN THIS CODE EACH LINE #include <stdio.h>#include<string.h>int main(){ char name[20]; int meal,quantity; int drink,quantity2; char choose_meal[30] = ""; int meal_price; float drink_price, orderPrice; char choose_drink[30] = ""; float cash, change; printf("--------------------Marry's Fast Food--------------------"); printf("\n"); printf("Enter your name: "); scanf("%s", name); printf("Hello %s!\n", name); printf("\n\nWhat would you like to order?\n"); printf("------------------------MEALS------------------------\n\n"); printf("[1] 1 pc. Chicken Joy....................Php 76.00\n"); printf("[2] 1 pc. w/Jolly spaghetti..............Php 99.00\n"); printf("[3] pc. Spaghetti........................Php 55.00\n"); printf("[4] pc. Burger steak w/rice..............Php 85.00\n"); printf("[5] pc. Burger...........................Php 30.00\n\n"); printf("Choose a number…I wrote this c++ program to find min and max, but why does the program say it cannot find the min and max. WHere I got wrong? Please help me revise my code. I have must use the pointer and void function in my code. Please help me revise it. #include <iostream>using namespace std; int getmin(int number[], int size){ int min=number[0]; for (int i=1; i<size; i++) { if (number[i]<min) min=number[i]; } return min;}int getmax(int number[], int size){ int max=number[0]; for (int i=1; i<size; i++) { if (number[i]>max) max=number[i]; } return max;}void getminandmax(int number[], int size, int* min, int* max) { for (int i=1; i<size; i++) { if (number[i] > *max) *max=number[i]; if (number[i] < *min) *min=number[i]; } } int main(){ int number[5]={5, 4, -2, 29, 6}; int min=number[0]; int max=number[0]; getminandmax(number, 5, &min, &max);…
- Please fill in the blanks. Programing language is C. /*For simplicity, this program will get the information of each client, and print it right back. We could get the information of all clients first, then print them all later for better readability using an array of struct.*/ #include<stdio.h> #include<stdbool.h> #define length 70 //assume there's no names longer than 70 /*It's good practice to add all function headers to the top of the program*/ __1__ __2__ getEmployeeInfo(); __3__ printEmployeeInfo(__4__ __5__ em); __6__ __7__ getClientInfo(__8__ i); __9__ printClientInfo(__10__ __11__ cli, __12__ i); /*Employee struct: all the arrays use the same constant size defined on top name-first, last-(string) title (string) number of clients (integer) number of years working at the company(can take decimal points). */ __13__ employee { __14__ first_name[__15__]; __16__ last_name[__17__]; __18__ title[__19__]; __20__ num_clients;…Please send me answer within 10 min!! I will rate you good for sure!! Please provide screenshot of code and output with explaination!! Write a C program that implements and tests a function that simulates strcmp function. You should not use functions from <string.h> library. You may use array and/or pointer notation to define the functions. More precisely, you should implement this function: Hint: int myStrcmp (const char *s1, const char *s2) This function compares the string pointed to by s1 to the string pointed to by s2. If the string pointed to by s1 comes before the string pointed to by s2 in dictionary ordering, then -1 is returned. If the string pointed to by s1 is the same as the string pointed to by s2, then 0 is returned (the compare function is case sensitive). Otherwise, 1 is returned. C programComplete the program 'Bcast-Reduce-Assignment.c' (Refer to 'Bcast-Reduce-Example.c') to make the program have the output as follows if we run the program using 2 processes. The input sequence is: 0 1 2 3 The output sequence is: 0 2 6 12 The code below must be used, please #include <stdio.h>#include <stdlib.h>#include <mpi.h> int main(void) { int my_rank, comm_sz; int i; int Count = 4; int Number[4]; int Result[4]; MPI_Init(NULL, NULL); MPI_Comm_size(MPI_COMM_WORLD, &comm_sz); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); if(my_rank == 0) { printf("The input sequence is: \n"); for (i = 0; i < Count; i++) { Number[i] = i; printf("%d ", Number[i]); } printf("\n"); } // Process 0 sends data to all of the processes MPI_Bcast(Number, Count, MPI_INT, 0, MPI_COMM_WORLD); for (i = 0; i < Count; i++)…