Fill in the blank in the following program that draws a figure resembling the letter 'Z' with sides (50, 100, 50) and the angle between them to be 60 degrees.
Remember that the turtle starts at the center of the canvas and facing right.
left(180); forward(50); right(B1); forward(B2); left(B3); forward(50);
What is B2?
Write a C++ program that inputs a positive number form user and program will display its factorial. For example (factorial of 4 = 1x2x3x4 which equals to 24)
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Example 1:
Input: s = "()"
Output: true
Example 2:
Input: s = "()[]{}"
Output: true
Example 3:
Input: s = "(]"
Output: false
Example 4:
Input: s = "([)]"
Output: false
Example 5:
Input: s = "{[]}"
Output: true
Please correct this program for the upper example, please don't change the way of the program which I made. you can add certain functions to solve this program if I miss anything.
#include <stdio.h>
#include <stdlib.h>
// This is where the parentheses are stored in memory
char buffer[1024];
char stack_pop();
void stack_push(char ch);
int stack_size();
int stk_sz = 0;
int str_sz;
char stack[1024];
int checker();
int main(){
FILE *fp;
// The parentheses sequences is in the parentheses.txt file.
fp=fopen("parentheses.txt","r");
if(fp==NULL){
printf("The input file does not exist.\n");
exit(-1);
}
// Read the parenthese sequences into buffer array.
fgets(buffer,1024,fp);
//printf("%s",buffer);
// puts(buffer);
str_sz = strlen(buffer);
if (checker()) {
puts("true");
} else puts("false");
fclose(fp);
}
// The pop operation in the stack. To be done.
char stack_pop(){
char ch = stack[stk_sz - 1];
stk_sz--;
return ch;
}
char peek() {
return stack[stk_sz - 1];
}
// The push operation in the stack. To be done.
void stack_push(char ch){
stack[stk_sz] = ch;
stk_sz++;
}
// The number of elements in the stack. To be done.
int stack_size(){
return stk_sz;
}
int checker() {
stk_sz = 0;
int i;
for ( i = 0; i < str_sz; i++) {
if (buffer[i] == '(' || buffer[i] == '{' || buffer[i] == '[') { //if there is an opening bracket
//push it on the stack
stack_push(buffer[i]);
} else {
if (stack_size() == 0) return 0; //if stack is empty, return 0
switch (buffer[i]) {
case ')':
if (peek() != '(') return 0;
stack_pop();
break;
case '}':
if (peek() != '{') return 0;
stack_pop();
break;
case ']':
if (peek() != '[') return 0;
stack_pop();
break;
}
}
}
if (stack_size() > 0) return 0; //if stack is not empty, return 0
return 1;
}
Write a C++ program that inputs a 2D array as arr[5][5] integer values from users then program will accept values from user and showing values index wise. Your program should find the largest element in each row and column.
A program that generate sequence of odd number max300
Write a program that prompts the user to input a 4 digit integer value and then outputs both the individual digits of the number and the sum of the digits.
2. Construct a class named student consisting of a student identification number, list of five grades, and an integer representing the total number of grades entered. The constructor for this class should initialize all student data members to zero.
Included in the class should functions/ methods for:
1. constructor and a destructor.
2. enter a student number
3. enter a single test grade (used loop for entering 5 grades)
4. set test grade
5. compute an average grade
6. display the student number and average grade.
1. You operate several BurgerStands distributed throughout town. Define a class named BurgerStand that has a member variable for the burger stand's id number and member variable for how many burgers that stand sold that day.
a) create a constructor that allows user of the class to initialize values for id number and for how many burgers sold that day and a destructor
b) create a function named justsold that show increments of the number of burgers the stand has sold by one. (This function will invoked each time the stand sells a burger so that you can track the total number of burgers sold by the stand. And returns the number of burgers sold.)
c) create a function that calculate the total number of burgers sold by all stands.
d) write in a data file, the list of burger stands and the total number of burgers sold by all stands.
Write a C++ program that inputs starting and ending number from the user and displays all odd numbers in the given range using while loop.
Write a C++ program that inputs a positive number form user and program will display its factorial.