Word count histogram (horizontal)

Take a look at this:

#include 
main()
{
    int wlen[255]; //why would you have a word with more letters than this?
    int i,g,wordcount,lettercount,inner,c,maxVal,maxLet;
    wordcount=lettercount=maxVal=maxLet=0;

    for(i=0;i<=254;++i) wlen[i]=0; //zero out the array

    while ((c=getchar())!=EOF)
    {
        if ((c=='\n'||c=='\t'|| c==' ' || c=='.' || c==',' || c==';' || c==':')&& lettercount>0)
        //don't count double 'spacers' as zero length words
        {
            ++wordcount;
            wlen[lettercount]=wlen[lettercount]+1;
            if (lettercount>maxLet) maxLet=lettercount;
            if (wlen[lettercount]>maxVal) maxVal=wlen[lettercount];
            lettercount=0;
        }
        else ++lettercount;
     }
    for(i=maxVal;i>0;--i)
    {
        for (inner=0;inner<=maxLet;++inner)
        {
           if (wlen[inner]>=i) printf("X");
           else printf(" ");
        }
        printf("\n");
    }
     for (g=0;g<=maxLet;++g)  printf("%d",g);
      printf("\n\nHey Finished Man!!\n");
}

update the main table and several sub tables using the autonumber primary key from the first table…

You’ve got a table (here bed_beds with pk = bed_refno) and you want to insert a new ‘bed’ and update the bed_beds_specialties and bed_sex_status tables using the newly created auto-generated id key.

Create a Stored Procedure (SP) and use the the SCOPE_IDENTITY() function to keep a record of the identity key generated within the scope. Then pass that to the INSERT queries used further down in the SP.


CREATE PROCEDURE spInsert_Bed
@wardRefno numeric(10,0),
@typeRefno numeric(10,0),
@dStart DATETIME,
@dEnd DATETIME,
@dCreate DATETIME,
@vUser VARCHAR(15)
AS
SET NOCOUNT ON
declare @lastin numeric(10,0)
INSERT INTO bed_beds (ward_refno, type_refno, start_Dttm, end_Dttm,create_Dttm,user_create)
VALUES (@wardRefno, @typeRefno, @dStart, @dEnd,@dCreate,@vUser)
set @lastin=  SCOPE_IDENTITY()

INSERT INTO bed_beds_specialties (bed_refno, spect_refno,comments, start_Dttm, end_Dttm,create_Dttm,user_create)
VALUES (@lastin, 3,'my sp test', @dStart, @dEnd,getdate(),@vUser)

INSERT INTO bed_sex_status (bed_refno, start_Dttm, end_Dttm,sex_rfval_refno,create_Dttm,user_create)
VALUES (@lastin,  @dStart,@dEnd,6,getdate(),@vUser)

GO

one loop and a decision

very very basic for loop and if else if else

#include 
using namespace std;
int main()
{
int i;
for(i=0;i<=13;i++)
    {cout << "Hello world! "<< i <

..notice that by the time it leaves the

for (){}

loop it is 14 not 13

Want system pause?

system("PAUSE");

then you'll need:

#include 

Preprocessor directives

An example of some preprocessor stuff:

#include 
#define __thing__ " amazing "
#define __func__(x,y) ((x)>(y)?(x):(y))
#define _FAT_
#define _Cars_
using namespace std;
int main()
{
     cout << "Hello world!"<< __thing__ <