Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Second Quiz




Test 1
Name: Lucky pickerTime: approximately 20min
Now, make a program which will ask the user to enter a number.
Then it will say if you picked the lucky number (a number you come up with), it will repeat this process until the user gueses the lucky number. If the user types in a number larger than the lucky number, it will say "Lower" , if the user picks a smaller number, it will say "Larger", if the user picks the lucky number, then the program outputs a congratulations, and waits for the user to press a key , then the program will exit. Also you may make the lucky number a random number (shown in lesson 2).



Test 2
Name: LoopyTime: 10 min
Get the user to input there name, then ask them for their age. Now output their name on to the screen in a single line as many times as there age is.



Test 3
Name: BlackoutTime: 10 min
Full up the screen with any letter or number, try to get the exact amount. Hint: the screen is 80 characters across by 25 down.






Answers
Drag the cursor over the white space to highlight the answer
Test 1Lucky picker Program , Source code

#include <conio.h>
#include <iostream.h>
#include <time.h>

void main()
{
	int Number, R_number;
	randomize();
	R_number = rand()%100;
	cout << "                              Lucky Picker" << endl << endl;
	cout << "Please enter a number between 0 and 100: ";
	cin >> Number;
	while(Number!=R_number)
	{
		if(Number > R_number)
		{	
			cout << "Smaller" << endl;
		}
		else if(Number < R_number)
		{
			cout << "Larger" << endl;	
		}
		cout << "Please enter a number between 0 and 100: ";
		cin >> Number;
	}
	cout << "Congratulations. You picked the lucky number: " << R_number;
	getch();
}
 
Test 2Loopy Program , Source code

#include <conio.h>
#include <iostream.h>

void main()
{
	int Age;
	char Name[20];
	cout << "Please enter your first name: ";
	cin >> Name;
	cout << "Please enter your age: ";
	cin >> Age;
	while(Age>0)
	{
		cout << Name << endl;
		Age--;
	}
	cout << "If this looks alot to you, then your pretty old.";
	getch();
}
 
Test 3Blackout Program , Source code

#include <conio.h>
#include <iostream.h>

void main()
{	
	int x,y;
	for(y=0;y<25;y++)
	{
		for(x=0;x<79;x++)
		{
			cout << "E";
		}
		cout << endl;
	}
	getch();
}





Back Home Next