Programming Fundamental
Assignment no 2
Program no 1: Program no 2:
1. char ch = 'a'; 1. char ch;
Initialize character is provided to program Initialize character is not provided.
To run inside the loop.
2. while( ch !='\r' ) { 2. while( (ch = getche()) !='\r' )
ch = getche(); Character read is defined inside test
……………………………………………………….. expression of loop statement.
}
Character read is defined inside loop.
3. cout << "Enter a phrase: "; 3. This program don’t use cout statement
Output string is used. to use any string.
4. cout << "\nWords=" << wdcount << endl 4. cout << "\nWords=" << wdcount << endl
<< "Letters=" << (chcount-1) << endl; << "Letters=" << chcount << endl;
In output result of character count, it’s General output is taken no subtraction is
subtracted by 1 because of, char ch = 'a'. done, char ch; .
5. Output: 5. Output:
Enter a phrase: Hassan Javed Hassan Javed
Words=2 Words=2
Letters=11 Letters=11
Press any key to continue . . . Press any key to continue . . .
Title: Differentiate between PROGRAM – 01 and PROGRAM – 02.