Anda di halaman 1dari 3

1. The following program contains many syntax errors.

Locate as
many as you can.
1. */ What's wrong with this program?/*
2. #include iostream
3. us i ng namespace std;
4.
5. i nt main();
6. }
7.
8.
9.
in t a, b, c
a=3
b=4
10. c=a + b
\\ Define 3 i ntegers
11. Cout >> "The va l ue of c is•>> C;
12. re t urn O;
13. {

2. What will the following programs print on the screen?


A) #include <iostream>
using namespace std;
int main ()
{
int freeze= 32, boil = 212;
freeze = O;
boil = 100 ;
cout <<freeze<< end l << boil << endl ;
return O;
}

#include <iostream>
using namespace std;
int main ()
{
int X = 0, y = 2;
X= y * 4 ;
cout << x << endl << y << endl;
return O;
}

C) #include <iostream>
using namespace std;
int main ()
{
cout << "I am the incredible";
cout << "computing\nmachine";
cout << "\nand I will\namaze\n";
cout << "you.\n";
return O;

D) #include <iostream>
using namespace std;
int main ()
{
cout << "Be careful !\n";
cout << "This might /n be a t rick··
cout << "question.\n";
return O;

E) #include <iostream>
using namespace std;
int main ()
{
int a, x = 23;
a= X % 2 ;
cout << x << endl <<a<< endl;
return O;
}

3. Rewrite the follow statement to use the newline escape character,


instead of an endl, each time subsequent output is to be displayed
on a new line.
cout << "L" << endl
<< "E" << endl
<< "A" << endl
<< "F" << endl;

4. One acre of land is equivalent to 43,450 square feet . Write a


program that calculates and displays the number of acres in a tract
of land whose size is 869 X 360 feet.
5. A particular employee earns $39,000 annually. Write a program
that determines and displays what the amount of his gross pay will
be for each pay period if he is paid twice a month (24 pay checks
per year) and if he is paid bi-weekly (26 checks per year).

Anda mungkin juga menyukai