#include <iostream.h>
//add the prototypes of functions
void three(void) { cout << "3\n"; }
void two(void) { cout << "2 "; three(); }
void one(void) { cout << "1 "; two(); }
void main(void) { cout << "Counting: "; one(); }
#include <iostream.h>
// add the prototypes of functions
void John(void) { cout << "John "; Jack(); }
void Jane(void) { cout << "Jane " << endl; }
void Jill(void) { cout << "Jill "; John(); }
void Jack(void) { cout << "Jack "; Jane(); }
void main(void) { cout << "Hi, "; Jill(); cout << "!";}
void hi(void) {
cout << "Hello\n" ;
hi();
}
#include <iostream.h>
void set(void) {
int a;
a=1;
}
void main(void) {
int a;
a=0;
set();
cout << a;
}
#include <iostream.h>
int a;
void set(void) {
a=1;
}
void main(void) {
a=0;
set();
cout << a;
}
#include <iostream.h>
void out(int houses, int horses) {
cout << houses << " " << horses;
}
void main(void) {
int boats=10, sheep=2;
out(boats, sheep);
}
#include <iostream.h>
void show(float a) {
cout << a << endl;
}
void main(void) {
float a=1, b=2;
show(b);
}
#include <iostream.h>
void out(int a, int b) {
cout << a << " " << b << endl;
}
void main(void) {
int a=1, b=2;
out(b,a);
}
#include <iostream.h>
int out(int a, int b) {
cout << a << " " << b << " ";
return a+b;
}
void main(void) {
cout << "(" << out(1,2) << ")" << endl;
}
#include <iostream.h>
int fun(int i) {
if (i==1) return 1;
else return i*fun(i-1);
}
void main(void) {
cout << fun(1) << " " << fun(2) << " " << fun(3) << " "
<< fun(4) << " " << fun(5) << endl;
}
#include <iostream.h>
int ratio(int a, int b) {
return a/b;
}
void main(void) {
int a=1, b=2;
cout << ratio(a,b) << " " << ratio(b,a);
}
#include <iostream.h>
void out(int i) {
cout << i << endl;
}
void main(void) {
out(1.0);
}
#include <iostream.h>
void swap(int a, int b) {
int tmp;
tmp=a;
a=b;
b=tmp;
}
void main(void) {
int a=1, b=2;
cout << a << " " << b << endl;
swap(a,b);
cout << a << " " << b << endl;
}
#include <iostream.h>
void swap(int &a, int &b) {
int tmp;
tmp=a;
a=b;
b=tmp;
}
void main(void) {
int a=1, b=2;
cout << a << " " << b << endl;
swap(a,b);
cout << a << " " << b << endl;
}
void f(int x, int y, double& z);
{
int X=y+z;
x/=2;
int X=4;
z-=5;
return x+z+1;
}
void fact1(int x); int fact2(int z); void fact3(); int fact4(); double fact5(int x, int y, int z);
which of the following are legal statements? for the ones that are not indicate why they are not legal
double f(int x, double y)
{
y=x-1;
x=x%3;
return x+y;
}
What output is generated by each of the following code fragments.
double val=2.5; int num=13; double res=f(num,val); cout << val<<' '<<num<<' '<< res << endl;
int x=12; double y=10.3; cout << x<<' ' << y <<' '<<f(x,y) << endl;
int y=10; double x=2.6; cout << x<<' '<<y <<' '<<f(y,x)<<endl; cout << x<<' '<<y <<' '<<f(x,y)<<endl;
/* This program initialize a one dimensional array then sort to order the array
Several bugs are introduced in the program */
#include <iostream.h>
void displ(); // function to display the array
main();
{
int num[7]=5,8,1,2,4,24,19
int a, b, t;
int size,
size=7;
disp(); // Display the array
// This portion of the program will sort the array
for(a=1; a<size;a++)
for(b=size-1;b>=a;b -)
if(num[b-1] >num[b]){
t=num[b-1];
num[b-1]=num[b];
num[b]=t;
}
}
//display sorted array
cout << "Sorted array is ";
for(t=0;t<size;t++)
cout << num[t] << ' ';
return 0;
}
Ax+By+C=0
ihint The distance equation between any point (x1,y1) and the line is given by![]()