Showing posts with label Solutions. Show all posts

CS201 Assignment no 3 Fall 2012 Full Solution


#include<iostream.h>
#include<conio.h>
using namespace std;
class Vehicle{
public:

void display();
void setcompany(string a);
void setmodel(string a);
void setenginecapacity(int a);
void setyear(int a);

void getinput();
string getcompany();
string getmodel();
int getenginecapacity();
int getyear();

Vehicle();

Vehicle(string,string,int,int);

~Vehicle();
private:
string company;
string model;
int year;
int enginecapacity;
string company2;
string model2;
int year2;
int enginecapacity2;    
int number,S,C;
};
Vehicle::Vehicle()
{
company=S;
model=C;
year=2011;
enginecapacity=1500;
}
void Vehicle::getinput()
{

cout<<"Enter the number of vehicle :";
cin>>number;
cout<<"Vehicle1"<<endl;
cout<<"Enter the name of vehicle maker company :";
cin>>company;
cout<<"Enter the vehicle model :";
cin>>model;
cout<<"Enter year of registration :";
cin>>year;
cout<<"Enter the engine capacity of the vehicle :";
cin>>enginecapacity;
cout<<endl;

cout<<"Vehicle2"<<endl;
cout<<"Enter the name of vehicle maker company :";
cin>>company2;
cout<<"Enter the vehicle model :";
cin>>model2;
cout<<"Enter year of registration :";
cin>>year2;
cout<<"Enter the engine capacity of the vehicle :";
cin>>enginecapacity2;
cout<<endl;
}




Vehicle::~Vehicle()
{
cout<<"object deleted"<<endl;          
}

void Vehicle::display()
{

cout<<"vehicle 1"<<endl<<"Enter the vehicle maker company :"<<getcompany()<<endl<<"Enter the vehicle model :"<<getmodel()<<endl<<"Enter year of registration :"<<getyear()<<endl<<"Enter the engine capacity of the vehicle :"<<getenginecapacity();
cout<<endl;

cout<<"vehicle 2"<<endl<<"Enter the vehicle maker company :"<<company2<<endl<<"Enter the vehicle model :"<<model2<<endl<<"Enter year of registration :"<<year2<<endl<<"Enter the engine capacity of the vehicle :"<<enginecapacity2;
cout<<endl;
}


void Vehicle::setcompany(string k)
{
company=k;                      
}
void Vehicle::setmodel(string a)
{
model=a;                    
}
void Vehicle::setyear(int a)
{
year=a;                    
}
void Vehicle::setenginecapacity(int a)
{
enginecapacity=a;    
}
string Vehicle::getcompany()
{
return company;  
}
int Vehicle::getenginecapacity()
{
return enginecapacity;  
}
string Vehicle::getmodel()
{
return model;  
}
int Vehicle::getyear()
{
return year;  
}



int main()
{
    Vehicle raousman1;

    raousman1.getinput();
    raousman1.display();
    raousman1.~Vehicle();
   
getch();
}

Tag : ,

MTH202 Assignment no 3 Fall 2012 Full Solution



Q#01: Use mathematical induction to prove that for every integer with . (Note that this inequality is false for and .) Marks = 6
BASIC STEP:
p(4) = 2^n 
2^4 =16 < 24 = 4!

INDUCTIVE STEP:

For this step we assume that p(k) is true for posiive integer k with k>=4
Assume:
2^k < k!
2^k+1 < (k+1)!
2^k+1 = 2.2^k

< 2.k!

< (k+1)k!

= (k+1)!

So p(k+1) is true when p(k) is true.

Q#02: Find the GCD of and using Division Algorithm. Marks = 4
Let a= 4566891 and b=182 . Also, let's introduce the variable "r" for the remainder
Let's evaluate a/b . It turns out that a/b = 25092 remainder 147. What we're are interested in is the remainder.
So let . Now assign the value of "b" to "a" and the value of "r" to "b".
So now a=182 ,b=147 and r=147

Now we must ask ourselves: "Does b=0?". Since b=147 (which is NOT zero), we must start all over and keep going until "b" equals zero.

Let's evaluate a/b . It turns out that a/b= 182/147 = 1 remainder 35. What we're are interested in is the remainder.
So let . Now assign the value of "b" to "a" and the value of "r" to "b".
So now a=147 ,b=35 , and r=35

Now we must ask ourselves: "Does b=0?". Since b=35 (which is NOT zero), we must start all over and keep going until "b" equals to zero

Let's evaluate a/b . It turns out that a/b= 147/35 = 4 remainder 7. What we're are interested in is the remainder.
So let . Now assign the value of "b" to "a" and the value of "r" to "b".
So now a=35 ,b=7 , and r=7

Now we must ask ourselves: "Does b=0?". Since b=7 (which is NOT zero), we must start all over and keep going until "b" equals zero.

Let's evaluate a/b . It turns out that a/b = 35/7 = 5 remainder 0. What we're are interested in is the remainder.
So let . Now assign the value of "b" to "a" and the value of "r" to "b".
So now a=7 ,b=0 , and r=0
Since the value of b is now zero, we can stop the process.
Now the value of "a" in the last row is the GCD of the numbers "a" and "b" 
So this means that GCD(4566891,182)=7.


Q#03: Define a sequence by the formula , for all integers . Show that this sequence satisfies the recurrence relation , with and for all integers . Marks = 5



Tag : ,

PHY101 Assignment no 3 Fall 2012 Full Solution


Question No 1

(a)What is the electric field at the location of the test charge shown below? And what is the 
direction of electric field? Marks = 5

(b) What are the magnitude and direction of the electric field at point A shown below? Marks = 6

Question No 2


Find the force on the electron in figure shown below and also determine the acceleration of 
electron? Mention the direction of force and acceleration as well.
Note that mass of electron is 9.1×10-31kg, and the value of charge on electron is (-1.6×10-19 C)
Marks = 7

Question No 3


Is it true to say that electric field lines are the same as electric field vectors. If yes give an 
example if not explain it. Marks = 6

Question No 4


Suppose you increased the amount of the charge of a test charge, and the force exerted on it

changed. This means the field you were assessing must have changed. Marks = 5

Question No 5


(a) It takes 10.0 J of work by the right-hand wand to separate the charges as shown in figure.

What is the change in potential energy? Marks = 3


(b) Is it true to say that electric potential energy and electric potential are the same?

Either yes or no explain in each case. Marks = 3



Solutions

Q1.a
E=F/q
use this formula to find Electric field.
Q.1.b
E=K.q/r2 (r square)
use this formula to find magnitude.
Q.3
Answer:-
Yes It is true to say that electric field lines are the same as electric field vectors
field line is a locus that is defined by a vector field and a starting location within the field.A vector field defines a direction at all points in space; a field line for that vector field may be constructed by tracing a path in the direction of the vector field. More precisely, the tangent line to the path at each point is required to be parallel to the vector field at that point.
A complete description of the geometry of all the field lines of a vector field is sufficient to completely specify the direction of the vector field everywhere. In order to also depict the magnitude, a selection of field lines is drawn such that the density of field lines (number of field lines per unit perpendicular area) at any location is proportional to the magnitude of the vector field at that point.

Q.4
by the relation E=F/q it is very clear that if amount of charge or force is changed E will be changed.
 Q.5.b (wikipedia)
Electric potential energy, or electrostatic potential energy, is a potential energy (measured in joules) that results from conservative Coulomb forcesand is associated with the configuration of a particular set of point charges within a defined system.
The electric potential at a point is equal to the electric potential energy (measured in joules) of any charged particle at that location divided by thecharge (measured in coulombs) of the particle. Since the charge of the test particle has been divided out, the electric potential is a "property" related only to the electric field itself and not the test particle. The electric potential can be calculated at a point in either a static (time-invariant) electric field or in a dynamic (varying with time) electric field at a specific time, and has the units of joules per coulomb, or volts.
Tag : ,

CS410 quiz no 3 Solved Fall 2012



1. For showing Dialog we can use "ShowWindow(...)" function
TRUE
FALSE

2. When a menu item is clicked, WM_COMMAND message is send and ID of this menu item is sent in:
wParam
lParam
hInstance
HWND

3. The "GetDlgItem" function retrieves a ______ to a control
Handle
Pointer
Object
None of the given options

4. The WM_INITDIALOG message is sent to the dialog box procedure ______________
Immediately before a dialog box is displayed
Immediately after a dialog box is displayed
When DialogProc is called
When HideDialog is called

5. Virtual key code defined by
Kernel Not Sure
Application
System
None of given


6. In which parameter of "CreateWindow" function, we can specify the Menu.
hMenu
hInstance
hWnd
dialogBox






7. Menu resource should be associated with a window while:
Creating window
Repainting window
Creating or registering window
Destroying window

8. Neither the user nor the application can make the owner window active until the modal dialog box is destroyed
True
False


 9. When we keep some key pressed for a long time, which one of the following technique keeps the message queue concise
 Older messages are discarded
Call the GetKeyState() funtion
Repeat Count contains how many times WM_KEYDOWN message was sent
There is no such technique

10. What is the file extension of the resource file?
.rc
.cr
.ico
.txt

11. Which one of the following controls cannot receive input focus?
Edit
Static
Option Button
Push Button


12. The DialogProc function is used to ________
Create a Dialog
Destroy a Dialog
Hide a Dialog
process messages sent to a modal or modeless dialog box



13. To retrieve the identifier of the menu item at a specified position, we can use the
GetMenuItemID or GetMenuItemInfo function
Only GetMenuItemID function
We have to use both GetMenuItemID and GetMenuItemInfo
None of the given functins



14. When you release a key from keyboard, _______ message is sent to your application message queue.
WM_KEYRELEASE
WM_KEYDOWN
WM_KEYPRESSED
WM_KEYUP

15. When an application receives a keystroke message, ______ code is there in wParam parameter.
ASCII key
Normal key
Extended key
Virtual key


16. Device-independed value represents
Virtual key code
Key code
Read only code
Mix code

17. It is not possible to create a dialog box that has no owner.
True
False

18. An application destroys a modal dialog box by using the ________ function
EndDialog
TerminateDialog
DestroyDialog
DestroyModalDialog




19. If we press an extended key from keyboard, the number of byte(s) sent to keyboard buffer is (are):
 1
2 Not sure
3
4

20. By default all resources are Discardable.
True
False


21.  Win32-based applications are event-driven
TRUE
FALSE

22.       __________, system sends the item's identifier to the owner window?
When the user chooses a command item from a menu
When the system chooses a command item from a menu
When the user click on any window area
When the system de-select the item menu

23. An accelerator, not always needs to correspond to a menu command.
TRUE
FALSE



24. If the load menu function fails so what will be the return value.
0
False
Null
1

25. Which function is not used to handle a caret?
CreateCaret()
DestroyCaret()
SetCaretPos()
DenyCaret()





26. In the case of extended keyboard characters, first byte of keyboard buffer contains ____ and second byte contains ______.
scan code, extended code
extended code, scan code
0, scan code Not sure
scan code, 0



Tag : ,

- Copyright © virtual university of pakistan - Skyblue - Powered by Blogger - Designed by Johanes Djogan -