What are the Exercise answers of chapter syntax directed definition in compilers by Alfred aho?
Which of the following expressions would be generated by this phrase structure
rule: NP → {Art (Adj) N, Pro, PN}?
(a) a lady (c) her (e) the widow
(b) the little girl (d) Annie (f) she's an old woman
An array is:
simply a collection of similar objects
How you create one: (I think)
Basically you receive or copy an image and place it in an array and assign it an mage Areray name.
How you access info and elements
It can be accessed by means of a variable name and an index.
True or False A C plus plus class constructor cannot return a function value?
True - A C++ constructor cannot return a value.
Write a program that display the current date of the system using C programming language and ALP?
#include <stdio.h>
#include <time.h>
void main()
{
time_t t;
time(&t);
clrscr();
printf("Today's date and time :\n %s",ctime(&t));
getch();
}
What is the initial value of a numeric variable?
When we talk about instance variables, the default initial value for a numeric variable is always '0'. Any other variable in your code must be initialized before you can use it.
public class MyClass{
public int x; // 0 by default
public float y: // 0 by default
public MyClass{
int z;
z++; // Error 'z' don't have a default value
}
}
How many roots does this equation have?
Zero or more, cannot be determined without actually seeing it.
Give a recursive version of the tree-insert?
Insert (Node *root, Node *newp)
{
if (root->left==NULL) { root->left= newp; return; }
if (root->right==NULL) { root->right= newp; return; }
Insert (root->left, newp);
}
The number of characters ascii standard supports?
ASCII: 128; 95 printable, 33 control
iso-8859-1: 256; 191 printable, 65 control
unicode: many
Do you ned a certification to be a computer programmer?
How do you write a program in C to convert capital letters into small letters?
Use the tolower() function in the C standard library.
What is the syntax of the if statement?
clearly:
if (
or
if (
else
In each case,
The following program prints every second character of the input in reverse order.
#include<iostream>
#include<sstream>
int main()
{
std::cout << "Input:\t";
std::string input = "";
std::getline (std::cin, input);
if (input.size())
{
std::cout << "Output:\t";
unsigned index = input.size() / 2 * 2;
do
{
index -= 2;
std::cout << input[index];
} while (index);
std::cout << std::endl;
}
}
C program to find largest among three numbers?
#define max2(a,b) (b>a?b:a)
#define max3(a,b,c) (max2(a,max(b,c)))
Languages used to develop embedded systems?
C language is mostly used in most of the embedded systems. python is used for hardware related production and unix used to automated testing
How old is the Easytrieve programming language?
I conceived the program in 1966 and worked on it as a spare time project. We contracted with them to market our program and they did extremely well. Sales increased exponentially and in December 1979, Pansophic purchased Easytrieve along with a 5-year maintenance agreement. A patent application for Easytrieve was filed in 1971 and was granted 10 years later6
When xor and or operation are same exmple A or B or C equals A xor B xor C?
Check the following table:
a b c a+b+c a^b^c
0 0 0 0 0 =
0 0 1 1 1 =
0 1 0 1 1 =
0 1 1 1 0
1 0 0 1 1 =
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1 =
So they are equal if the number of ones between a, b, and c is zero or an odd number.
Write a c program to find the sum of the digits of a number?
#include<iostream>
int sum_digits(int num, int base=10)
{
int sum=0;
while( num )
{
sum+=num%base;
num/=base;
}
return(sum);
}
int main()
{
int sum=sum_digits(42);
// assert( sum==6);
}
Why you use header files in c?
the use of header files is to add functionality. Header files are basically saying put code in that header file here so you don't have to type that many lines of code.
Move 5 disks in the tower of hanoi algorithm?
/* tower of hanoi using recursion */
#include<stdio.h>
int main(void)
{
unsigned int nvalue;
char snvalue = 'L' , invalue = 'C' , dnvalue = 'R' ;
void hanoi(unsigned int , char , char , char);
printf(" enter number of disks : ");
scanf("%u",&nvalue );
printf("\n\ntower of hanoi problem with %d disks \n ", nvalue )"
hanoi(nvalue , snvalue , invalue , dnvalue );
printf("\n");
return 0 ;
}
void hanoi(unsigned n , char snd1 , char ind1 , char dnd1 )
{
if(n!=0)
{
/* move n-1 disks from starting to intermadiate needles */
hanoi(n-1 , snd1 , dnd1 , ind1 );
/* move disk n from start to destination */
printf("move disk %d from %c to %c\n ", n , snd1 , dnd1);
/* move n-1 disks from intermediate to destination needle */
hanoi(n-1 , ind1 , snd1 , dnd1 );
}
}
What do the numbers have in common when you count by 5?
When numbers count by five, the number you are counting to either has a 5 or 0 in it.