Given the following code, what is going to be the output? 10 int main (int argc, char* argv[]){ 11 string a = "The Last Emperor"; int pos = 0; while ((pos = a.find(" ", pos)) != string::npos) 12 13 14 cout << a.substr(0, pos++) << endl; 15 return 0; 16 } 17
Q: Consider the following code (and assume that it is embedded in a complete andcorrect program and…
A: The Given code is considered and it is embedded in a complete and correct program and i runned it…
Q: 1. What is the output of the following code? (A)for (int i = 1; i < 4; i++)…
A: Since multiple questions have been asked and it is not clear which one question you want to be…
Q: Question 6: Determine what does this program perform? #include int mystery3( const char *s1, const…
A: #include <stdio.h>//header fileint mystery3( const char *s1, const char *s2 );//function…
Q: Q 2:\ (a) What are the output of following code? float a,b,c a=5; b=3; c=a/b; setfil(); -…
A: main.cpp: In function ‘int main()’: main.cpp:17:14: error: ‘setfill’ was not declared in this scope…
Q: Please I am facing a problem executing the code The question is:. Write a Flex program to check the…
A: The edited code is given below for the above given question
Q: Q-No.6: Write the output of the following program. (1 tinclude *include using namespace std; class…
A: First, the program controller goes to the main() function. Then the object os String class is…
Q: Q7: Write a program that reads a collection of car speeds as long as the speeds do not exceed 100…
A: Program Approach: Including necessary header files Using namespace for standard input output…
Q: QuestiUIT 3 What will be printed after executing the int main () int x = 1, y =2, z =3; сорy (х, у,…
A: Solution #include <iostream> using namespace std; void copy(int& a,int& b,int&…
Q: IS the E#include 2 #include using namespace std; 4 | bool isIt(string); string brother = "Able";…
A: Answer in step2 brother and result are global variable n1 is local variable.
Q: 1) #include #include int power(int, int); int main(void) { int x, n; printf("Enter a number and…
A: To do: Write the int main(void) function as a driver program and call the above three functions…
Q: #include #include int LineFunc(void); int main() { int a, b; printf("Enter a :"); scanf("%d", &a);…
A: In code draws a line which is in the form of y = mx+c The input to the code is a and b where a = m…
Q: Modify this code to make it print first in first out (printed in the sequence they were entered)
A: The modifies Code is written in step 2
Q: Consider the following statement.string str = "This summer we will drive across the country!";What…
A: a. The following output is generated by the program. 45 Explanation: In the program, the string…
Q: Consider this snippet of C code (which will not run as is because of the questions marks): char…
A: According to the information given:- We have to find out the replacement values of ? marks.
Q: // tmpVars.c #include int main() { int x = 97; char ch1 = 'A'; int y = 98; char ch2 = 'B'; unsigned…
A:
Q: Consider the following declaration: int beta [3][3]: What is stored in beta after the following…
A: As per Bartleby's Guidelines: “Since you have posted a question with multiple sub-parts, we will…
Q: Use c code to add the function in the program to provide for purchase amount of RM80.00 or more, the…
A: Q: Use c code to add the function in the program to provide for purchase amount of RM80.00 or more,…
Q: #include #include double f(double x){ return x*x; } double reimannSums(double…
A: NOTE: - The program is working based on sample values. These values are: - COMMAND LINE ARGUMENT: -…
Q: l. ☆ Include what is the output of line 2. 3. int x= (0; 29 and 32? Y. C. vord Func 1() ネ. 8.…
A: The given program is written in C language. C is a programming language developed by Dennis Ritchie…
Q: What is the output? #include (stdio.h> struct mystruct{ int numbers[2][3]; char *string; }x ={10, 8,…
A: In this question, we have given C code. We have to run the code in the compiler. And find the…
Q: #include #include int LineFunc(void); int main() { int a, b; printf("Enter a :"); scanf("%d", &a);…
A: Edited code for the above C program #include <stdio.h> #include <stdlib.h> void…
Q: What is the output of the following program? #include <iostream>using namespace std;int…
A: Program given by you, #include <iostream>using namespace std;int main(){int list[5];list[4] =…
Q: What is the output of the following program? Hint: each value in numbers gets set only once.…
A: #include <iostream> using namespace std; int main(){ //array delaration int numbers[9];…
Q: what is wrong with this programming? #include #include using namespace std; int main() { string…
A: #include <iostream>#include<bits/stdc++.h>using namespace std;int main(){string…
Q: what is the output of this .3 program? # include int main () {double a=21.09399; float b= 10.2; int…
A: The given Program is C++
Q: def sparechange(quarters, dimes, nickels, pennies): spareAMT = 25 * quarters + 10 * dimes + 5 *…
A: 1) Below is program to display equivalent dollers for the change quarters, dimes, nickels and…
Q: What is the output of. int sumAll(int], int); int main() { int nums] = {1, 2, 3, 4, 5, 6}; cout <<…
A: The function sumAll() recieves an array and size of array as function parameters. The for loop…
Q: What is the output of this code? int main(int argc, _TCHAR* argv[]) { char s1[] = "September 1";…
A: The strncmp() function take three parameters first the string 1, second string 2 and third the size.…
Q: 6. Write a program that (i) declares a string str_a (of size (LAST_FOUR_DIGITS_OF_YOUR_STUDENT_ID %…
A: Step 1: Accept a string from the user and store it in str_a. Step 2: Scan the characters of the…
Q: Please make the modifications in "C programme" and try to complete all three parts kindly.…
A: Make the following modifications to the code Add a password-protected authorization system so that…
Q: What is wrong with the next programming? #include #include using namespace std; int main(){…
A: According to the question below the Solution: Error:
Q: There is an array of strings named strs. Which of the below Java statements correctly find the count…
A: --- The syntax of chartAt() is: string.charAt(index) So option 1 is wrong. --- The length variable…
Q: Examine this code: Date d = makeDate(Month::jul, 4, 1776); Now that you've changed the type of…
A: The code fails not due to makeDate() function, it fails only due to isLeapYear() method generated by…
Q: #include using namespace std; int main() { string str; cout << "Enter a string: "; getline…
A: In C++, getline(): It is used to read the string. Basically what it will do is it extracts the…
Q: Question 2 What is the output of the following code? public static void main (String [] args) ( int…
A: //analysing code for output public static void main(String[] args) { int a=4,b=6; //value…
Q: Q2: What will be the output of the following C++ code?. 1. What is sumafter the following loop…
A: This actually shows the do while loop functionality it was explained in explaination.
Q: #include #include int LineFunc(void); int main() { int a, b; printf("Enter a :"); scanf("%d", &a);…
A: In this code, a line in the form of y = mx + c is drawn. Here, c is the intercept part, and m =…
Q: id my_func (int i, int& j) { int k; k = i + 6; i = i * 2; j = i + 3 + k; What is the output of the…
A: Here variable x1 is passed as call by value.so changes made to its copy variable i will not be…
Q: Show the output of the following code. #include <iostream> using namespace std;int* f(int…
A: The code will shows the error.
Q: Problem 1: Switcheroo Version 2 Write a program that will reverse the order of words on the given…
A: We can reverse the given string by using the below python program.
Q: What will be the output of the following C+ + code? %#3include %23include using namespace std;…
A: Question. What will be the output of the following C++ code? a) 33344244 b) 44332434 c) 33432444 d)…
Q: 5. What is the output of the following code? int x; int *p; int *q; p = new int[10] ; *p = 4; for…
A: Given Code: int x;int *p;int *q;p=new int[10];q=p;*p=4;for(int j=0;j<10;j++){ x=*p; p++;…
Q: what is the wrong with this code , i whant it for 5 items ?
A: For 5 items, the n value has to be 5 and no need to take input for this If you want to apply 8%…
Q: #include #include int findRepeat(char* s) { int p , i , j; p = -1; for (i = 0 ; i < strlen(s) ;…
A: #include <stdio.h>#include <string.h> int findRepeat(char* s){int p , i , j; p = -1; for…
Q: lef foo (a : Int) { ... var b = a + 3 ... def bar(g : Int) { val h = b + g ... } def jat(...) {…
A: In the function foo, every time in the while foo is called with the value 3 because Val is passed…
Q: Write the output of the following C++ code? #include #include using namespace std; class A…
A: Que. Write the output of the following C++ code? Ans. Given, Programming language = C++ Code:…
Q: def findOccurrences(s, ch): lst = [] for i in range(0, len(s)): if a==s[i]:…
A: According to the question below the complete Code:
Q: What is this code trying to accomplish? Explain. #include using namespace std; int…
A: Given: What is this code trying to accomplish? Explain. #include <iostream> using namespace…
Q: Consider the following code snipplet, int a[3] = {1, 2, 3}; short *b; b = (short *)a; b++; After…
A: After executing the code, the correct answer to this question is option first 0. Output: -
Step by step
Solved in 2 steps
- include<stdio.h> #include<stdlib.h> int binarySearch(int arr[], int n, int k) { int start = 0; int end = n-1; while(start<=end) { int mid = (start+end)/2; if(arr[mid]==k) return mid; elseif(arr[mid]<k) start = mid + 1; elseif(arr[mid]>k) end = mid - 1; } return0; } //6 3 //5 5 7 9 15 2 int main() { int n, k, happyCounter=0; scanf("%d%d", &n,&k); int arr[n]; for(int arr_ind=0;arr_ind<n;arr_ind++) scanf("%d", &arr[arr_ind]); for(int arr_ind=0;arr_ind<n;arr_ind++) { for(int range=arr[arr_ind]-k;range<=arr[arr_ind]+k;range++) { if(binarySearch(arr, n, range)) { happyCounter++; break;.Please I am facing a problem executing the codeThe question is:. Write a Flex program to check the given string having characters capital or alphanumeric or not %option noyywrap%{ #include<stdio.h>%}%{#undef yywrap#define yywrap (); void display (char [], int); int plag;%}%% [a-z A-z]+ {int flag = 1;display (yytext, flag); return;}[0 - 9] + { int flag =0; display (yytext, flag);}%{int flag =-1;display (yytext,flag);} %% void display (chara [], int flag); {if (flag == 1) printf( "The given sking = "$ is a word "a );if (ftag ==0) Printf(" megiven string = %s as anumber"a); if ( Flag ==-1) printf ("me given skring os is everything "a);}main(){printf("Enter a string "); yylex();return 0;} Please check the solution and take a picture of the input and outputcan you fix my code in c++? #include <iostream> #include <string> #define SIZE 3 using namespace std; string readType() { string *type = new string; cout << "Drone type: "; getline(cin, *type); return type; } void readData(string dtype, int *d_info[]) { cout << dtype; cin >> d_info; } int highestType(string *dt[], int *d_price, int *d_qty) { float sales; int d_Highest; int index; d_Highest=*d_price(); cout<<"Sales Amount : "<<endl; for (int i = 0; i < SIZE; i++) { sales=(float)*d_price[i] * (*d_qty[i]); cout << *dt[i] << " - " <<"RM"<< sales << "\n"; if (sales<d_Highest) { d_Highest = sales; index = i; } } cout << "\n"; return index; } //Start main function int main() { string *dtypes [SIZE]; int *dprice; int *dqty [SIZE]; // Examples of type, sales price and sales quantity of drone //…
- #include<iostream>using namespace std;const int rows=10;const int columns=10;int computer_board[rows][columns];int player_board[rows][columns];int x,y;void setboard(){for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){computer_board[i][j]=0;player_board[i][j]=0;}}}void display_board(){cout<<"Computer's Board"<<endl;cout<<" 0 1 2 3 4 5 6 7 8 9 "<<endl;for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){if(j==0){cout<<i<<" ";}cout<<computer_board[i][j]<<" "; }cout<<endl;}cout<<endl;cout<<"Your Board"<<endl;cout<<" 0 1 2 3 4 5 6 7 8 9 "<<endl;for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){if(j==0){cout<<i<<" ";}cout<<player_board[i][j]<<" "; }cout<<endl;} }void place_player_ships(){for(int i=1;i<=15;i++){cout<<"Horizontal component:";cin>>x;cout<<"Vertical component:";cin>>y;if(x>=10||y>=10){cout<<"Invalid…Please give the correction from this code, where I made the mistakes. The extra two output shown here. How to remove that? #include <stdio.h>#include <stdlib.h>#include <string.h>// movie structurestruct movie {char movieName[1025];int rating;}; int main(void) { // movie structure variablestruct movie list[10];// movie structure pointer variablestruct movie *ptr = list; int ID;// assign std to ptrchar buff; for (int i = 0; i < 8; i++) { printf("Enter number %d movie name: ",i+1); //scanf("%s",&ptr->movieName); gets(ptr->movieName); printf("Enter rating: "); scanf("%d", &ptr->rating); buff = getchar(); // update pointer to point at next element ptr++;} // reset pointer back to the startingptr = list; printf("Enter your ID: ");scanf("%d",&ID); struct movie temp;for (int i = 0; i < 10; i++) { for (int j = 0; j < (9 - i); j++) { if (list[j].rating < list[j + 1].rating) {…int i cannot be changed with int pos I have to fill in the program that is missing in the middle by using what is already there in C++. Started with this but does not like it cout << "Enter passwdStr: "; getline(cin, passwdStr); while (passwdStr.find("qwerty") != string::npos) { passwdStr.replace(int i, 6, "mvhnkl"); i = passwdStr.find("qwerty"); }
- Explain this C code line per line please #include <stdio.h> #include <malloc.h> void printArray(int**, int); int main() { int i = 0, j = 0, n = 5; int **arr = (int**)malloc(n * sizeof(int*)); for(int i=0;i<n;i++){ *(arr+i) = (int*)malloc(n*sizeof(int)); } for(i=0;i<n;i++){ for(int j=0;j<n;j++){ *(*(arr+i) + j) = 0; } } printArray(arr, n); for(i=0;i<n;i++){ *( *(arr + i) + i) = i+1; } printArray(arr,n); return 0; } void printArray(int ** array, int size) { int i,j; for(i = 0;i<size;i++){ for(j=0;j<size;j++){ printf("%d ", *( *(array + i) + j)); } printf("\n"); } printf("\n"); }Filll in the below code in C program: #include <stdio.h> void main() { int pageNumbers[25], frameContents[25]; int i = 0, j = 0, k = 0; int numPages = 0, numFrames = 0, totalPageFaults = 0; int frameNumber = 0; printf("\n Page Replacement Method: FIFO"); printf("\n Enter the number of pages in the page sequence: "); // 20 scanf("%d", &numPages); printf("\n Enter the page numbers in sequence as a string: "); // 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 for (i = 0; i < numPages; i++) scanf("%d", &pageNumbers[i]); printf("\n Enter the number of frames: "); // 3 scanf("%d", &numFrames); for (i = 0; i < numFrames; i++) frameContents[i] = -1; printf("\n The Page Replacement Process is \n"); printf("\tREF STRING"); for (j = 0; j < numFrames; j++) printf("\tPAGE_FRAME_%d", j + 1); printf("\tPAGE_FAULT_NUMBER\n"); /* Find the occurance of page faults and the total number of page faults */ printf("\n\n Total number of Page Faults using FIFO: %d \n", totalPageFaults); }For this assignment please use 2 arrays. Write a program DiscreteDistribution.java that will take an integer command-line argument m, followed by a sequence of positive integer command-line arguments a1,a2,…,ana1,a2,…,an, and will print m random indices (separated by whitespace), choosing each index i with probability proportional to ai.
- Computer Science For each of the code snippet given below, identify the error and then write code after fixing the error. Given code is the simulation of grep -v command. -v prints all lines that do not match a specific pattern. void grep_inverse(char *filename, char *str) { FILE *fp; char buf[buff_size]; fp = fopen(filename, "r"); if(!fp) { perror(filename); } else { while (fgets(buf, buff_size, fp) != NULL) { if ((strstr (buf, str)) != NULL) printf("%s", buf); } } fclose(fp); }#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/wait.h> int main(){ int i, s; int a[] = {23,4,8,33,25,7,12,6,49,50,11,20,21,24,35}; pid_t pid; pid = fork(); if (pid == 0) { printf("I'm a child, I'll be printing the even numbers:\n"); for(i=0;i<(sizeof(a)/sizeof(int));i++) if(a[i]%2 == 0) printf("%d ",a[i]); } else { printf("I'm the parent, I'll be printing the odd numbers:\n"); if (pid > 0) pid = waitpid(pid, &s, 0); for(i=0;i<(sizeof(a)/sizeof(int));i++) if(a[i]%2 != 0) printf("%d ",a[i]); } return 0;} the output seem to have some error whereby it cannot output the number for the first ifdef sparechange(quarters, dimes, nickels, pennies): spareAMT = 25 * quarters + 10 * dimes + 5 * nickels + 1 * pennies print("The total value of your change is $%.2f "%(spareAMT/100)) uses import.sys and sys.argv[ ] to run code