write a java code: Consider the following expression BNF: ::= * | / | :== + | - ::= { }|
Q: Problem 4 Assuming that each tour can be generated in constant time, what will be the efficiency…
A: Θ(n!)
Q: pid test () //line 1 int temp: int y = 10, x = -5; temp cout<< temp: //line 2 %3D %3D //line 3…
A: #include <iostream.h> #include<conio.h> void test() { int temp; int y =10, x=…
Q: Draw the top levels of a structure chart for a program having the followingmain function: def…
A: Program is given below:
Q: Computer Science Use the Python PLY library to write a parser for the following grammar. You may…
A: Import the required libraries: ply.lex and ply.yacc. Define the tokens using regular expressions.…
Q: Problem 11 Write an algorithm in pseudo code that, for a given graph, outputs vertices of each…
A: Algorithm for pseudo graph: 1. First initialize all vertices are unvisited. 2. a. If vertex v is…
Q: Describe the TM that accepts the language, L = {wf(a.b.c)* Iw contains equal number of a's b's and…
A: The language is generating six types of string and a, b, c can be in any order but contains equal…
Q: Consider the following code segment: def fun (par) : XANH X = y = Z = if par <= 0: return par+1…
A: A recursive function is a function that calls itself within its own definition, either directly or…
Q: translate the following C++ program into Pep/9 Assembly language. #include using namespace std; void…
A: In main(): A local variable myAge is declared. Allocate memory for myAge variable in the stack…
Q: tenuse (a, b) sqrt (a*a + b*
A: Solution - In the given question, we have to find the correct answer among the given options.
Q: EXPLAIN THIS C++ PROGRAM STEP BY STEP WITH LOGIC #include using namespace std; class Circle{…
A: Every program start with main(). So Lets start with main. When you see in main, a object is created…
Q: CONVERT 1 & 2 from C++ to Python 1.NON RECURSIVE #include using namespace std; int main() {…
A: Two cpp programs are given here. We have to convert the main functions in both the programs. The .py…
Q: Find the output #include using namespace std; void display(); int main(){ display(); display();…
A: Objective: A code snippet in C++ is given including a function "display()". The function contains a…
Q: Consider a program that receives two coordinates in a plane and prints the slope of the line that…
A: The reason the given piece of code is misbehaving for the following value: x_1 = 1 y_1 = 2 x_2 = 1…
Q: Write the final output generated by the following program: a. #include #include main() { int a,…
A: To predict and get the output of the program, it is necessary to study all the conditions and try to…
Q: 3. Consider the abstract syntax for the following expression language. The constant Zero denotes 0,…
A: Here we are given the syntax for the expression language and we need to find the semantics for it .…
Q: Consider the following C++ code segment: int d = 20; int f(int b) { static int c = 0; c *= b;…
A: Let's go through each variable (a, b, c, d) step by step:Variable a :Type Binding: Automatic (it's…
Q: Translate the following C program into NASM. #include int ary[] = {12, 40, -2, 89, 35, -7, 6};…
A: Given C program : #include <stdio.h> int ary[] = {12, 40, -2, 89, 35, -7, 6}; int main() {…
Q: This is C++ Virtual Functions Please use comment lines to show what each line will do and how.…
A: Include the necessary header file for input/output stream operations. Add the using namespace std;…
Q: Translate the following c++ code into pep9 assembly language #include using namespace std; int…
A: Converted Code: _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@plt: jmpq…
Q: Consider the set of following syntax rules. ::= ::= while ( ) ::= := >|=|!=|== ::= | ::=…
A: In most computer programming languages, a while loop which it is a control flow statement that also…
Q: The correct writing of following mathematical equation in the C++, Y=(2(3x-1))/2 mod 4.
A: Answer:
Q: What is the output of below C++ Code:- for(i=1; i<=2; i++) for(j=i; j<=2; j++) cout<<i<<"@": A…
A: Given snippet: //header file #include <iostream> using namespace std; //definition of main…
Q: Given a list of ints and an int, all should return a bool indicating whether or not all the ints in…
A: According to the Question below the Solution: Output:
Q: convert the program to java CODE: #include #include #include #include #include #include…
A: Scanner class is used to enter data from the user. Goto statement has been replaced with while…
Q: Design an FA (a DFA or an NFA) that only accepts numbers which are divisibles by 3 over the alphabet…
A:
Q: Q1/ False or True 1- Assembler translates a program written in a low-level language to machine…
A: Assembler translates a program written in a low level language to machine language C++ used to…
Q: Construct a DFA defined as L = {w ∈ {0,1,#}* : w does not contain # and the number of 0s in w is not…
A: The DFA for L = {w ∈ {0,1,#}* : w does not contain # and the number of 0s in w is not a multiple of…
Q: python : WWSD: Quasiquote Use Ok to test your knowledge with the following "What Would Scheme…
A: 1. Expression 1: '(1 x 3)Create a string result1 with the expression '(1 x 3)'.Print result1.2.…
Q: d) List all formal parameters. e) List all actual parameters. f) Is/Are there any global variable/s…
A: 1) Variable and its type as they appear in the prototype of the function or method is called format…
Q: please tell me whats wrong with this code/ please fix it ( in C) #include #include…
A: There were some errors in the code and i have fixed it. The Fixed code is given below:
Q: Please convert to C language #include using namespace std; //folding method int main() {…
A: Given program is a C++ program which contains mainly one for loop and inside that for loop if else…
Q: 1. Draw the top levels of a structure chart for a program having the following main function (you…
A: Consider the given code: def main(): printIntro() length,width=getDimensions()…
Q: CODE> #include #include #include #include using namespace std; struct process { int pid; int…
A: The following is the complete code for the problem given here:
Q: Convert the following c code to assembly.
A: Here below i write the assembly code for this c program:…
Q: (2) {w € [0, 1]* : Jy € [0, 1]* (|wy| is even)} O OU 1* O 0* U1 O (OU 1)* O 0* U 1*
A: The question provides a set builder notation that defines a language over the alphabet {0, 1}. We…
Q: Consider the UML class diagram below: Person -name: string +Person(n: string) +display(): void…
A: Include necessary C++ standard libraries, such as iostream and string.Create a class named "Person"…
Q: Consider the following C++ code segment: int d = 20; int f(int b) { static int c = 0; c *= b;…
A: Type Binding: The term "type binding" describes the data type (such as int, char, etc.) connected to…
Q: 1. Draw the top levels of a structure chart for a program having the following main function (you…
A: Draw the top level of a structure chart for the given program: insert->drawing def main():…
Q: Fill the blanks to find the root square of any input number n, s=0,i=0.000001; cout>n; while((…
A: 1. declare the variables with the datatype as float => Therefore the first blank will be float 2.…
Q: SUBJECT: OOP PROGRAMMING LANGUAGE: C++,C#,C Q. Covert the following C, C# code into C++,#include…
A: Equivalent c++ code: #include <iostream>#include <bits/stdc++.h>using namespace…
Q: Modify the following insert functions of this code and implement a logic that user will not be able…
A: 1. To prevent from duplicate insertion a. get the user input b. loop through each…
Q: Algorithms in pseudo code MUST be placed in code blocks/fences, and use either the cpp or java…
A: The answer is given in the below step
Q: Define a LISP function MONTH->INTEGER which takes as argument a symbol that should be the name of a…
A: LISP: Lisp is a family of programming languages with a long history and a distinctive, fully…
Q: Consider the following C++ codes: Code a: Code b: int x-8; // global void func () int x-8; // global…
A: Let us see the details below,
Q: Complete function RollSpecific Number() that has three parameters: a GVDie struct object, an integer…
A: The answer is given in the below step
Q: Principles of programming languages: The C selection statement using EBNF is: → if ( )…
A: Backus-Naur type and Context-Free Grammars it's a syntax description formalism that became the…
Step by step
Solved in 4 steps with 1 images
- write a pseudocode for this programme in c++ #include<iostream> #include<string.h> using namespace std; struct staff_info { char name[40]; int noIC; int age; int category; int scheme;};int main(){ struct staff_info staff[10]; for(int i=0;i<10;i++) { cout<<"Enter Name: "; cin>>staff[i].name; cout<<"Enter IC Number: "; cin>>staff[i].noIC; cout<<"Enter Age: "; cin>>staff[i].age; cout<<"Enter Category(Press 1 for Academic / 2 for Non-Academic): "; cin>>staff[i].category; cout<<"Enter Scheme (Press 1 for Pension on 56 years / 2 for Pension on 60 years: "; cin>>staff[i].scheme; } cout<<endl; cout<<"Staff's Information"<<endl; cout<<"Name\t\tNoIC\t\tAge\t\tCategory\t\tScheme"<<endl; for(int i=0;i<10;i++) {…C++. Explanation please.Consider the set of following syntax rules. <loop statement> ::= <while loop> <while loop> ::= while ( <condition> ) <condition>::=<identifier><conditionalOperator><identifier> <conditionalOperator>:= >|<|<=|>=|!=|== <identifier>::= <letter>|<letter><identifier> <letter>::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z a) The following WHILE loops are intended to be written using the syntax defined by these rules. For each one, state whether it is syntactically correct or incorrect. If it is incorrect, give your reasons. i) while(d<=E) ii) while(b!=6) iii) while(s>q) iv) while(m=r) v) while(x>y) b) Write a BNF definition of hex where hex consists of at least one digit, or at least one letter or a mixture of digits and letters. Hex letters are A, B, C, D, E and F. Here are some of the valid examples for hex: C, CD, FE19, EC128, AB, CAB
- Consider the following C++ code segment: int d = 20; int f(int b) { static int c = 0; c *= b; return c; } int main() { int a; cin >> a; cout << f(a) * d << endl; }For each variable a, b, c, d: identify all type bindings and storage bindings for each binding, determine when the binding occurs identify the scope and lifetimec++Translate the following C program into NASM. #include <stdio.h> int ary[] = {12, 40, -2, 89, 35, -7, 6}; int main() { int sum = 0; int highest = 0; for (int x = 0; x < 7; x++) { if (highest < ary[x]) highest = ary[x]; sum += ary[x]; } printf("Sum is %d\n", sum); printf("Highest value is %d\n", highest); } Use indexing (the [ebx+esi] or [ebx+edi] form). You can have several “dw” values on the same line. Use the “loop” command.
- Format Requirement Algorithms in pseudo code MUST be placed in code blocks/fences, and use either the cpp or java syntax highlighter. Algorithms should follow the pseudo code standard described in handout 1. Your pseudo code should be placed in a code block, for example Algorithm alg_name(a, b) { // A description of the algorithm // input: a - a positive decimal integer; b - an integer // ouput: the sum of a and b c = a + b // or, c <- a + b return c } Do NOT change the template except the answer portion. Formulas and equations should be in math mode using Latex math symbols. Markdown math tutorial: http://tug.ctan.org/info/undergradmath/undergradmath.pdf Ways enter into the math mode in Notion: https://www.notion.so/help/math-equations9. It is required to write a parser for the grammar below. <source_file> ::= <declarations> <code> <declarations> ::= vars <list_of_variables> ; <list_of_variables> ::= <variable> | <list_of_variables> , <variable> <code> ::= <statements> . <statements> ::= <assignment> | <statements> ; <assignment> <assignment> ::= <variable> := <expression> <expression> ::= <expression> + <term> | <expression> - <term> | <term> <term> ::= <term> * <factor> | <term> / <factor> | <factor> <factor> ::= <number> | <variable>5. Consider the following code segment of an MPI program and answer the following question. int rank, tag=1; MPI Status Stat; MPI Init(&argc, &argv); MPI Comm rank (MPI_COMM_WORLD, &rank); int x = rank + 1; if (rank } } == 0) { proc = 1; MPI Recv(&x, 1, MPI_INT, proc, tag, MPI_COMM_WORLD, &Stat); x = x + 5; MPI Send (&x, 1, MPI_INT, proc, tag, MPI_COMM_WORLD); x = x + 2* rank; else if (rank proc = 0; MPI Send (&x, 1, MPI_INT, proc, tag, MPI_COMM_WORLD); x = x + 3; == Answer: 1) { MPIR Recv(&x, 1, MPI_INT, proc, tag, MPI_COMM_WORLD, & Stat); x = x + 2* rank; printf("Task %d: Received %d"\n", rank, x); If the above program is run using 3 processors, what is the output? Write down the output that will be shown in the standard output (output generated by the printf statement). I
- Consider the following structure definition. Write a C/C++ function that takes an array of struct student with its size and applies a curve system like if the student scored below 50, 1dd 10 points, if it is above 50, add 2 points. The lowest possible mark is 0 and the highest possible mark is 10. struct student{ int ID; int score; void applycurve (struct student a[ ], int size)change the code to C language #include<stdio.h>#include<conio.h>void menu();void getInput( char &, int & );float getprice( char ch , int n); int main() {char name[20], order[3][20];int table, quantity[3];char ch1,ch2,ch3;int n1,n2,n3;float price=0;float total=0;float pay=0;float change=0;int q1;int q2;int q3;printf ("\t -----------SUNNY CAFE ORDER FORM-----------\n"); printf("\t Customer Name :");scanf("\n%s",&name);printf("\t Table Number :");scanf("\n%d", &table);menu(); printf("\n\t Order 1: ");getInput(ch1, n1);printf("\t Order 1 quantity: ");scanf("%d", &q1);printf("\n");printf("\t Order 2: ");getInput(ch2, n2);printf("\t Order 2 quantity: ");scanf("%d", &q2);printf("\n");printf("\t Order 3: ");getInput(ch3, n3); printf("\t Order 3 quantity: ");scanf("%d", &q3);printf("\n");printf ("\t\t **********************************************\n");printf(" ~SUNNY CAFE~ \n");printf ("\t\t…Translate the following C program into NASM. #include <stdio.h> int ary[] = {12, 40, -2, 89, 35, -7, 6}; int main() { int sum = 0; int highest = 0; for (int x = 0; x < 7; x++) { if (highest < ary[x]) highest = ary[x]; sum += ary[x]; } printf("Sum is %d\n", sum); printf("Highest value is %d\n", highest); } Use indexing (the [ebx+esi] or [ebx+edi] form). You can have several “dw” values on the same line. Use the “loop” command.