Monday, September 12, 2011

HOW TO USE UPDATE STATEMENT SYNTAX IN SQL SERVER

The Update statement is use to update any column in a table

The syntax of update statement is

Update table_name
Set column_name ='value'
Where column_name='value'

Lets say we have a following table (table_1)


We want to change Asad raza's city from Lahore to Karachi, so for his the syntax would be

update table_1
set city='Karachi'
where firstname='asad'

so the output will be


We can also update multiple column at a same time

lets say we want to change city from Karachi to Islamabad for Muhammad Taqi & Muhammad Taqi

so for this the syntax would be

update table_1
set city='Islamabad'
where firstname='muhammad' or lastname='Taqi'

We can also use AND & OR Operator like in the above example we used OR operator

Note : If you use update statement without where clause than it will update all the record.

If you still have any confusion about update statement than please leave a comment.

Friday, September 2, 2011

PROGRAM TO GENERATE RANDOME NUMBER IN C/C++

This program can generate random number, from 0 to 6

CODING
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<iomanip.h>
main()
{
srand(time(0));
clrscr();
        for (int count=1; count<=5; count++)
            {
            int a=rand() % 6;
            cout<<setw(5)<<a<<endl;
            }
getche();
return 0;
}

Thursday, September 1, 2011

cstdlib.h MISSING IN INCLUDE FOLDER TRY THIS C/C++

 Getting this error  ??



If want to use rand() or srand() function in your program and are unable to include <cstdlib.h> header file because the file is not in your include folder , than try to include <stdlib.h> in your program and it should work.

Thanks

Wednesday, August 31, 2011

PROGRAM TO CONVERT UPPER TO LOWER LETTER AND VICE VERSA C/C++

This program will ask user to enter any character, if the user enter uppercase letter the program will convert it into lowercase letter and vice versa.

This program is capable of convert only a character, for string conversion please check this ONE

CODING
#include<iostream.h>
#include<conio.h>
main()
{
char a;
cout<<"Enter your letter ";
cin>>a;
if(a>=65 && a<=90)
a=a+32;
else if (a>=97 && a<=122)
a=a-32;
cout<<endl<<a<<endl;
getche();
clrscr();
}


Friday, August 26, 2011

CONVERT SENTENCE FROM UPPER LETTER TO LOWER LETTER AND VICE VERSA IN C/C++

This program will ask user to enter any string, If the user enter string in upper case the program will convert it into lower case and vice versa.

This program is capable of handling character and string.

CODING
 
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
main()
{
int l;
char ch[40];
cout<<"Enter a Character or sentence ";
gets(ch);
l=strlen(ch);
for(int a=0; a<=l; a++)
{
    if(ch[a]>=65 && ch[a]<=90)
        {
            ch[a]=ch[a]+32;
        }
else if(ch[a]>=97 && ch[a]<=122)
{
    ch[a]=ch[a]-32;
}
}
for(a=0; a<=l; a++)
    cout<<ch[a];
    cout<<endl;
getche();
clrscr();
}