What were members of the land-owning warrior class called?
You see, the samurai were a highly trained class of noble warriors who fought for land-owning lords in Japan. While there were skilled warriors in Japan for many centuries, the highly militarized culture and many wars of the 12th century turned the highest class of warriors into a new social class of noble, intellectual masters of martial arts.
What is the difference between an attribute and a behavior in c plus plus?
An attribute is a class member variable while a behaviour is a class member method.
What is stub class in c plus plus?
A stub class is used during unit testing. When developing classes, a stub class is developed alongside the actual class in order to simulate the member functions of the class, to ensure the function has been called at the expected point, to enable parameters to be checked against expected values and to return values. Stub class source code is stored in the "stubs library". When testing a class, its stub is copied into a test stubs file which drives the test.
Write a calendar program to find out the day of a given date in a particular year?
Here is the complete program. Mind you, the code doesn't mind if you input invalid dates like 29th February 1981 or 42 March 1983, etc. So if you input such stupid dates, you will get stupid answers. Adding further code to take care of such childish inputs would only convolute it, right?
#include
#include
main()
{
long int t=0,id=15,im=10,iy=1582,iy1=1582,id1,im2=9,im1=9,dr,dc=0,td,tm,ty;
long int smc[12];
smc[0]=smc[2]=smc[4]=smc[6]=smc[7]=smc[9]=smc[11]=31,smc[3]=smc[5]=smc[8]=smc[10]=30;
printf("Enter the date (Date Month Year): ");
scanf("%ld %ld %ld",&td,&tm,&ty);
id1=td;
while (iy
{
if (((((iy)%4)==0) && (((iy)%100)!=0)) ((((iy)%100)==0) && (((iy)%400)==0)))
smc[1]=29;
else
smc[1]=28;
while (im1<=11)
{
if (t==0)
dr=smc[im-1]-id,++t;
else
dr=smc[im1];
while (dr>0)
++dc,--dr;
++im1;
}
im1-=12,++iy;
}
if (((((iy)%4)==0) && (((iy)%100)!=0)) ((((iy)%100)==0) && (((iy)%400)==0)))
smc[1]=29;
else
smc[1]=28;
while (im1
{
dr=smc[im1];
while (dr>0)
++dc,--dr;
++im1;
}
if ((iy1==ty) && (im2=(tm-1)))
id1=td-id;
while (id1>0)
++dc,--id1;
if ((dc%7)==0)
printf("\nFriday.");
if ((dc%7)==1)
printf("\nSaturday.");
if ((dc%7)==2)
printf("\nSunday.");
if ((dc%7)==3)
printf("\nMonday.");
if ((dc%7)==4)
printf("\nTuesday.");
if ((dc%7)==5)
printf("\nWednesday.");
if ((dc%7)==6)
printf("\nThursday.");
}
What are data members and members function?
The correct terminology is member variables and member methods. They are both members of a class. The member variables are used to store an object's data, while the member methods are used to operate upon that data.
Can you tell if he has an std by the taste of his semen?
If its a really bad odour there might be an infection there. What you eat affects the taste. Spicy foods stronger taste, sweet foods sweeter taste.
Very doubtful, but it could carry the disease to the taster's mouth, and infect that person.
What are the ten commandments of c plus plus?
By Phin Straite, taken from "Practical C++ Programming".
int * gred ;
gred = new int [100] ; // this example snippet creates 100 ints
How do you solve the equation c plus c plus 1 equals 49?
2*c + 1 = 49
2*c = 48
c = 24
2*c + 1 = 49
2*c = 48
c = 24
2*c + 1 = 49
2*c = 48
c = 24
2*c + 1 = 49
2*c = 48
c = 24
How do you enter dimensions of matrix in c plus plus?
Place each dimension in a separate array subscript. E.g., a table of 5 rows of 6 integers could be declared as follows:
int table[5][6];
A cuboid of 3x4x5 integers could be declared as follows:
int cube[3][4][5];
Of course, with static arrays, the dimensions are known in advance, and they are fixed for each dimension. In other words, in an array of 5x6 elements, each of the 5 elements in the first dimension has exactly 6 elements in the second dimension. This is also true of dynamic arrays (the only difference being the dimensions are not known in advance). However, sometimes you want an array where the number of elements in each dimension can vary. That is, the first element in the first dimension might only have 1 element, but the second might have 2 or more elements. In this case you are no longer dealing with a traditional multi-dimensional array, you are dealing with a 1 dimensional array of 1 dimensional arrays: or an array of arrays.
The following code demonstrates this concept, but rather than using dynamic C-style arrays, it uses an array of vectors instead. Vectors are always the preferred method of instantiating dynamic arrays in C++ because, unlike an array, a vector knows exactly how many elements it contains, and is therefore much easier to work with, especially when passing dynamic arrays into external functions.
The following code increases the size of the second dimension by one for each first dimension, thus creating a triangular table of values, rather than the more traditional rectangular table. The values are taken from the standard multiplication tables, thus the first row contains 1x1, the second contains 2x1 and 2x2, the third contains 3x1, 3x2 and 3x3, and so on. The final row contains the complete 12 times table, from 12x1 to 12x12.
#include<iostream>
#include<iomanip>
#include<vector>
int main()
{
using namespace std;
typedef vector<int> array1d;
// Build a 1 dimensional array of vectors of increasing length:
array1d A[12];
for( size_t x=0; x<12; ++x )
{
array1d& B = A[x];
for( size_t y=0; y<x+1; ++y )
B.push_back(( x+1 )*( y+1 ));
}
// Print array:
for( size_t x=0; x<12; ++x )
{
for( size_t y=0; y<A[x].size(); ++y )
cout<<setw(3)<<A[x][y]<<" ";
cout<<endl;
}
return(0);
}
Why friend functions can not be inherited?
For the same reason that friends are not inherited in real life. Suppose Albert is a friend of Brian and Brian is a friend of Charlie. Would that then make Albert a friend of Charlie? No, of course it doesn't. They may well have a common friend in Brian, but that doesn't automatically make them friends of each other. And the same applies to classes; friends must be selected, never inherited.
How will initialize an array to names of 10 students?
Use an initialisation list:
std::array<std::pair<std::string,std::string>,10> students = {
{"Albert","Einstein"}, {"Billy", "Kidd"},
{"Charlie","Chaplin"}, {"David","Essex"},
{"Eric","Idle"}, {"Fred","Flintstone"},
{"Gary", "Gilmore"}, {"Harold","Lloyd"},
{"Ian","Fleming"}, {"Jack","Black"}
};
Alternatively, have the user input the information via std::cin (manual input or redirected from a file), or extract the data from an input stream.
How many programming languages are based on C?
C++, Java, Perl, Python, PHP, JavaScript, LPC, C# is the most popular languages based on C, but there is probably more languages.
You need a sample code of word frequency count in c plus plus?
For this you will need a node structure that stores a word and its frequency. The frequency is initially 1 (one), and the constructor should just accept the word. You then create a list from this structure. As you parse the text, extract each word and search the list. If the word does not exist, push a new structure for the word onto the list, otherwise increment the frequency for the word. When you've parsed the file, you will have your frequency count for each word in the list.
The basic structure for each node is as follows (you may wish to embellish it further by encapsulating the word and its frequency).
struct node
{
std::string m_word;
unsigned long long m_freq;
node(std::string wrd): m_word(wrd), m_freq(1) {}
};
When parsing your text, remember to ignore whitespace and punctuation unless it is part of the word (such as contractions like "wouldn't"). You should also ignore capitalisation unless you wish to treat words like "This" and "this" as being separate words.
What is a constructor with value zero?
Constructors have no value, zero or otherwise. That is, constructors cannot return a value. This is because constructors are not functions in the sense you cannot call a constructor directly. Constructors are invoked in the background when you instantiate an object of the class, thus any return value would be lost in the background, and would therefore not be visible to the invokee.
Write a program to perform a binary search on an unsorted list of n integers?
#include<iostream>
#include<iomanip>
#include<vector>
#include<random>
// The node class is used to store a value from the
// unsorted list, along with its index in the list.
// The left node points to a tree of nodes where
// all values are less than this node's value. The
// right node points to a tree of nodes where all
// values are greater than (or equal to) this node.
struct node
{
unsigned value;
unsigned index;
node* left;
node* right;
node (unsigned val, unsigned idx)
: value (val), index (idx),
left(NULL), right (NULL) {}
~node ()
{
delete left;
delete right;
}
void insert (node& n)
{
if (n.value<value)
{
if (left)
left->insert (n);
else
left = &n;
}
else
{
if (right)
right->insert (n);
else
right = &n;
}
}
node* find (unsigned val)
{
if (val == value)
return this;
else if (val < value)
return left ? left->find (val) : NULL;
else
return right ? right->find (val) : NULL;
}
};
// The tree class maintains the root node of a binary
// search tree (BST). The default constructor builds
// a BST from a vector of values. All other methods
// delegate to the root node.
struct tree
{
node* root;
tree (const std::vector<unsigned>& v)
: root (NULL)
{
for (unsigned i=0; i<v.size(); ++i)
{
node* n = new node(v[i], i);
if (!root)
root = n;
else
root->insert (*n);
}
}
~tree ()
{
delete root;
}
node* find (unsigned value)
{
return root ? root->find (value) : NULL;
}
};
// A helper function to determine if a value exists
// in a vector or not.
bool exists(std::vector<unsigned> vect, unsigned num)
{
for (unsigned i=0; i<vect.size(); ++i)
if (vect[i] == num )
return true;
return false;
}
int main()
{
// random number generator (range: 1 to 15)
std::default_random_engine generator;
std::uniform_int_distribution<unsigned> distribution (1, 15);
// create an unsorted list with 10 random numbers and print them
// in the order they are generated
std::vector<unsigned> vect;
std::cout << "Unsorted list: ";
unsigned nums = 10;
while (nums--)
{
do
{
unsigned num = distribution (generator);
// ensure num is unique!
if (!exists (vect, num))
{
vect.push_back (num);
std::cout << std::setw(3) << vect.back();
break;
}
} while (true);
}
std::cout <<std::endl;
// create a binary search tree from the vector
tree bst (vect);
// now go find all the numbers in the tree and show where they
// reside in the list (include all the missing numbers)
for (unsigned num=1; num<=15; ++num)
{
if( node* n = bst.find (num))
{
std::cout << num << " was found in the tree";
std::cout << " and is at index " << n->index;
std::cout << " in the list" << std::endl;
}
else
std::cout << num << " could not be found in the tree" << std::endl;
}
}
How do you store a number of integers entered by the user in an arra with C?
You can use dynamic arrays. Malloc, realloc and free play crucial roles. You can also substitute calloc for malloc. Below is a sample code:
#include
#include
int
main(){
int
n = 10
, noofnumbers = 0
, num, i;
int
*arr = (
int
*)malloc(n*
sizeof
(
int
));
//first creating an array of size 10 - you can even skip this part and directly go for expanding an array every time an element is entered
if
( !arr ){
printf(
"No space in memory\n");
return
(1
);
}
while
( scanf("%d"
, &num) != EOF){
if
( noofnumbers < n){
arr[noofnumbers] = num;
noofnumbers++;
}
else
{
//when more than 10 numbers are added increasing the size accordingly
int
*temp = (int
*) realloc(arr, (++n)*sizeof
(int
));//realloc for reallocating the memory
if
( temp == NULL
){
printf("Not enough space\n"
);
break
;
}
else
{
arr = temp;
arr[noofnumbers] = num;
noofnumbers++;
}
}
}
printf(
"the numbers are:\t");
for
( i = 0
; i
, arr[i]);
printf("\n"
); free(arr);//freeing the memory space
return
0
;
}
How you run C plus plus compiler in windows 2007?
There is no operating system known as "Windows 2007". The only Microsoft operating system released in 2007 was Microsoft Windows Server 2008. Microsoft Windows Vista was released earlier in 2006 and has since been superseded by Microsoft Windows 7 (released in 2009), Microsoft Windows Server 2012, Windows 8 (2012), Microsoft Windows Server 2012 R2 and now Microsoft Windows 8.1 (2013).
As to how you run a C++ compiler on Microsoft Windows (regardless of the version), you first have to download or buy a compiler as well as a linker and a resource compiler. However, compilers and linkers are not generally available separately, they usually come as part of an Integrated Development Environment (IDE), which includes project management facilities and code editors. Your IDE documentation will tell you how to run the built in compiler from the command line, however in an IDE this is seldom necessary as all compilation and linking can be achieved from within the IDE itself.
Can xperia x1 support c plus plus?
Yes, but it's probably easier to use Java since the Android SDK is Java-based. To use C++ you need a C++ wrapper for Android's Java SDK.
Write a c program to sort an unsorted stack?
A stack is implicitly sorted by hierarchical nested order. It does not make sense to sort a stack.
Do you mean a list? If so, please ask the question again.
The following code is based upon Microsoft KB216686: How to automate Excel from C++ without using MFC or #import.
The code creates some random data as a table, writing it to a text file in CSV format. This data is then read from the file, printed to std::cout (for verification) before being output to an excel worksheet.
#include<iostream>
#include<fstream>
#include<sstream>
#include<array>
#include<random>
#include<ctime>
#include<ole2.h>
template<const size_t R, const size_t C>
class table_t
{
std::array<std::array<double, C>, R> data = {};
public:
table_t () {}
table_t (const table_t& rhs): data {rhs.data} {}
table_t (table_t&& rhs): data (std::move (rhs.data)) {}
table_t& operator= (const table_t& rhs) { data = rhs.data; }
table_t& operator= (table_t&& rhs) { data = std::move (rhs.data); }
std::array<double,C>& operator [] (const size_t row) { return data[row]; }
const std::array<double,C>& operator [] (const size_t row) const { return data[row]; }
size_t rows () const { return R; }
size_t columns () const { return C; }
std::wstring get_excel_range() const
{
std::wstringstream ss;
ss << L"A1:";
size_t cols=C;
while (cols)
{
ss << static_cast<char>((cols-1)%26+L'A');
cols /= 26;
}
ss << R;
return ss.str();
}
};
template<const size_t R, const size_t C>
std::ostream& operator<< (std::ostream& os, const table_t<R,C>& table)
{
for (size_t row=0; row<R; ++row)
{
for (size_t col=0; col<C; ++col)
{
os << table[row][col];
if (col<C-1)
os << ", ";
}
os << std::endl;
}
return os;
}
// forward declarations...
void create_data (const std::string&, const size_t, const size_t);
template<const size_t R, const size_t C>
table_t<R,C> read_data (const std::string&);
template<const size_t R, const size_t C>
int write_to_excel (const table_t<R,C>&);
HRESULT AutoWrap (int, VARIANT*, IDispatch*, LPOLESTR, int ...);
int main()
{
const size_t rows=10;
const size_t cols=5;
const std::string textfile {"sample.txt"};
// create sample data...
create_data (textfile, rows, cols);
// read and print the sample data...
table_t<rows, cols> table = read_data<rows, cols> (textfile);
std::cout << "Sample data:\n\n";
std::cout << table << std::endl;
// output data to excel...
return write_to_excel (table);
}
// Function to create a sample CSV data file with random data.
void create_data (const std::string& filename, const size_t rows, const size_t cols)
{
std::default_random_engine generator ((unsigned) time (0));
std::uniform_int_distribution<unsigned> distribution (0, 10000);
std::ofstream os (filename);
if (!os.bad())
{
for (size_t row=0; row<rows; ++row)
{
for (size_t col=0; col<cols; ++col)
{
double d = distribution (generator);
d /= 100;
os << d;
if (col!=cols-1)
os << ", ";
}
os << '\n';
}
}
os.close();
}
// Function to read a CSV file and return a table of doubles
template<const size_t R, const size_t C>
table_t<R,C> read_data (const std::string& filename)
{
table_t<R,C> table;
size_t row=0;
std::ifstream is (filename);
std::string line;
while (std::getline (is, line))
{
size_t col=0;
std::stringstream ss1;
ss1 << line;
std::string value;
while (std::getline (ss1, value, ','))
{
std::stringstream ss2;
ss2 << value;
double d;
ss2 >> d;
table[row][col] = d;
++col;
}
++row;
}
is.close();
return table;
}
template<const size_t R, const size_t C>
int write_to_excel (const table_t<R,C>& table)
{
// Initialize COM for this thread...
CoInitialize (nullptr);
// Get CLSID for our server...
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"Excel.Application", &clsid);
if (FAILED(hr))
{
::MessageBox (nullptr, "CLSIDFromProgID() failed", "Error", 0x10010);
return -1;
}
// Start server and get IDispatch...
IDispatch *pXlApp;
hr = CoCreateInstance (clsid, nullptr, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&pXlApp);
if(FAILED(hr))
{
::MessageBox (nullptr, "Excel not registered properly", "Error", 0x10010);
return -2;
}
// Make it visible (i.e. app.visible = 1)
{
VARIANT x;
x.vt = VT_I4;
x.lVal = 1;
AutoWrap (DISPATCH_PROPERTYPUT, NULL, pXlApp, L"Visible", 1, x);
}
// Get Workbooks collection
IDispatch *pXlBooks;
{
VARIANT result;
VariantInit(&result);
AutoWrap (DISPATCH_PROPERTYGET, &result, pXlApp, L"Workbooks", 0);
pXlBooks = result.pdispVal;
}
// Call Workbooks.Add() to get a new workbook...
IDispatch *pXlBook;
{
VARIANT result;
VariantInit(&result);
AutoWrap (DISPATCH_PROPERTYGET, &result, pXlBooks, L"Add", 0);
pXlBook = result.pdispVal;
}
// Create a safearray of variants...
VARIANT arr;
arr.vt = VT_ARRAY | VT_VARIANT;
{
SAFEARRAYBOUND sab[2];
sab[0].lLbound = 1; sab[0].cElements = table.rows();
sab[1].lLbound = 1; sab[1].cElements = table.columns();
arr.parray = SafeArrayCreate(VT_VARIANT, 2, sab);
}
// Fill safearray with values from the table...
for (size_t row=0; row<table.rows(); ++row)
{
for (size_t col=0; col<table.columns(); ++col)
{
// Create value
VARIANT tmp;
tmp.vt = VT_R8;
tmp.dblVal = table[row][col];
// Add to safearray...
long indices[] = {row+1,col+1};
SafeArrayPutElement (arr.parray, indices, (void *)&tmp);
}
}
// Get ActiveSheet object
IDispatch *pXlSheet;
{
VARIANT result;
VariantInit(&result);
AutoWrap (DISPATCH_PROPERTYGET, &result, pXlApp, L"ActiveSheet", 0);
pXlSheet = result.pdispVal;
}
// Get Range object...
IDispatch *pXlRange;
{
VARIANT parm;
parm.vt = VT_BSTR;
parm.bstrVal = ::SysAllocString (table.get_excel_range().c_str());
VARIANT result;
VariantInit (&result);
AutoWrap (DISPATCH_PROPERTYGET, &result, pXlSheet, L"Range", 1, parm);
VariantClear (&parm);
pXlRange = result.pdispVal;
}
// Set range with our safearray...
AutoWrap (DISPATCH_PROPERTYPUT, nullptr, pXlRange, L"Value", 1, arr);
// Wait for user...
::MessageBox (nullptr, "All done.", "Notice", 0x10000);
// Set .Saved property of workbook to TRUE so we aren't prompted
// to save when we tell Excel to quit...
{
VARIANT x;
x.vt = VT_I4;
x.lVal = 1;
AutoWrap (DISPATCH_PROPERTYPUT, nullptr, pXlBook, L"Saved", 1, x);
}
// Tell Excel to quit (i.e. App.Quit)
AutoWrap (DISPATCH_METHOD, nullptr, pXlApp, L"Quit", 0);
// Release references...
pXlRange->Release();
pXlSheet->Release();
pXlBook->Release();
pXlBooks->Release();
pXlApp->Release();
VariantClear(&arr);
// Uninitialize COM for this thread...
CoUninitialize();
return 0;
}
// AutoWrap() - Automation helper function...
HRESULT AutoWrap (int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...)
{
// Begin variable-argument list...
va_list marker;
va_start (marker, cArgs);
if (!pDisp)
{
MessageBox (nullptr, "NULL IDispatch passed to AutoWrap()", "Error", 0x10010);
_exit (0);
}
// Variables used...
DISPPARAMS dp = {nullptr, nullptr, 0, 0};
DISPID dispidNamed = DISPID_PROPERTYPUT;
DISPID dispID;
HRESULT hr;
char buf[200];
char szName[200];
// Convert down to ANSI
WideCharToMultiByte (CP_ACP, 0, ptName, -1, szName, 256, nullptr, nullptr);
// Get DISPID for name passed...
hr = pDisp->GetIDsOfNames (IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
if (FAILED (hr)) {
sprintf (buf, "IDispatch::GetIDsOfNames("%s") failed w/err 0x%08lx", szName, hr);
MessageBox (nullptr, buf, "AutoWrap()", 0x10010);
_exit (0);
return hr;
}
// Allocate memory for arguments...
VARIANT *pArgs = new VARIANT[cArgs+1];
// Extract arguments...
for (int i=0; i<cArgs; i++)
{
pArgs[i] = va_arg (marker, VARIANT);
}
// Build DISPPARAMS
dp.cArgs = cArgs;
dp.rgvarg = pArgs;
// Handle special-case for property-puts!
if (autoType & DISPATCH_PROPERTYPUT)
{
dp.cNamedArgs = 1;
dp.rgdispidNamedArgs = &dispidNamed;
}
// Make the call!
hr = pDisp->Invoke (dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, nullptr, nullptr);
if (FAILED (hr))
{
sprintf (buf, "IDispatch::Invoke("%s"=%08lx) failed w/err 0x%08lx", szName, dispID, hr);
MessageBox (nullptr, buf, "AutoWrap()", 0x10010);
_exit (0);
return hr;
}
// End variable-argument section...
va_end(marker);
delete [] pArgs;
return hr;
}
Write the application areas where programming in C plus plus is useful?
C++ application areas are only limited by your imagination. C++ programs can be written in both object-oriented and procedural styles, thus you can mix C++ with C and inline assembly.
The low-level capability obviously makes it ideal for writing hardware drivers and other operating system components. Although typically written in C, the improved type safety of C++ ensures greater robustness with equal efficiency.
The object-oriented capability makes it ideal for modelling highly-complex data structures more easily and more robustly than with C alone. The main application areas are those that demand the highest performance, which naturally includes games and multimedia, but also includes major applications such as "office"suites, DBMS and virtual machines -- not to mention integrated development environments and time-critical applications. Even the C++ compiler is written in C++, as are many other compilers, linker and interpreters, including the Java virtual machine!
Although high level languages such as Java are ideally suited to RAD, it's greatest feature is also its greatest flaw: the Java virtual machine. While the virtual machine makes it possible to produce cross-platform code much more easily than with C++ alone (which must be compiled separately for each supported platform), Java compiles to byte code rather than machine code. Every supported platform must therefore provide its own virtual machine so that the same byte code can be reinterpreted to produce the machine code specific to the platform. But this interpretation results in extremely poor performance not to mention far greater memory consumption compared to that of a native machine code program written in C++.
Write algorithm of a largest number in three numbers?
1. Read the 3 nos a,b,c
2. Let larget = a
3. if b > largest then largest = b
4. if c > largest then largest = c.....
If you have to process more nos, read all of them in an array. Assume the first element be largest, do comparison through all elements of the array....
Similar algorithm can be developed for finding the lowest also.
/*lab practice 2 damithguruge question 4 */
#include<stdio.h>
int main()
{
int num1,num2,num3,num4;
int smallest;
printf("Please enter a number1");
scanf("%d%*c", &num1);
printf("Please enter a number2");
scanf("%d%*c" ,&num2);
printf("Please enter a number3");
scanf("%d%*c", &num3);
Printf("Please enter a numbe4r");
scanf("%d%*c", &num4);
/* num1 set as the smallest */
smallest=num1;
if(smallest > num2) then
smallest=num2;
else
if smallest >num3 then
smallest=num3;
else
if smallest>num4 then
smallest=num4;
printf("smallest number:%d\n,smallest");
return(0);
endif
endif
endif
}
What type of scenario would you use a data queue?
Whenever you need to buffer sequential data for processing in a first in, first out manner. In a multi-processing, multi-threaded environment, incoming data may be received at any time. If the function that processes that data is otherwise occupied with a datum, the new data needs to be buffered until the function is ready to deal with it, thus the data is placed in a queue.
In Windows, for instance, an application's message queue exists to buffer incoming system messages until the application's message loop is ready to deal with them. If a process is running in the same thread as the message loop, the message loop cannot process any messages in the queue until that process terminates or yields control. This is why time-intensive functions must always periodically yield control to the system to allow pending messages to be processed. If the function does not yield control, the application (and often the system itself) can appear to be completely unresponsive, making the user think the system is "hung, when it is in fact doing exactly what you told it to do.