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();
}

Wednesday, August 24, 2011

PROGRAM TO GENERATE TABLE STARTING AND ENDING VALUE AS INPUT C/C++

This program will ask user to enter 3 values

Number for which table to be generated
On which number should the table start
On which number should the table end

CODING
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
main()
{
int numb,start,end,ans;
cout<<"Enter your number ";
cin>>numb;
cout<<"\nEnter your starting value ";
cin>>start;
cout<<"\n Enter your ending value ";
cin>>end;
if(start>end)
{
    for(int a=start; a>=end; a--)
    {
        ans=numb*a;
        cout<<ans<<endl;
    }
}

for(int a=start; a<=end; a++)
cout<<numb*a<<endl;
getche();
}

Tuesday, August 23, 2011

HOW TO MAKE A SIMPLE CALCULATOR IN C/C++

This is a simple calculator written in C++, it can ask user for two values and an operator (+,-,*,/)
based on the operator it will show the result, it also has a option to ask user if he wants to run the program again fmo the beginning.

 CODING
#include<iostream.h>
#include<conio.h>
main()
{
float numb1,numb2,ans;
char op,decision;
while (decision!='n')
{
clrscr();
cout<<"Enter your first number";
cin>>numb1;
cout<<"Enter your second number";
cin>>numb2;
cout<<"Enter operator (+,-,/,*)";
cin>>op;
switch(op)
{
    case '+':
    ans=numb1+numb2;
    cout<<"Your answer is "<<ans;
    break;

    case '-':
    ans=numb1-numb2;
    cout<<"Your answer is "<<ans;
    break;

    case '*':
    ans=numb1*numb2;
    cout<<"Your answer is "<<ans;
    break;

    case '/':
    ans=numb1/numb2;
    cout<<"Your answer is "<<ans;
    break;

    default:
    cout<<"You entered wrong operator";
}
cout<<"\nDo you want to run this program again ?";
cin>>decision;
}
}

Saturday, August 20, 2011

HOW TO BOOT INTO DOS FROM USB + DOWNLOAD LINK

What happen if you want to boot into DOS, but unfortunately your CD-ROM is not working or you may not have a bootable CD, well there is an alternative for this  i.e. Boot from USB

In order to boot from USB, you need the following

1. A USB
2. Format Utility by HP (Download)
3. DOS boot File          (Download)
Both files are password protected, password is taqi

Also your system should support booting from USB device, you can check that by going into BIOS
If you find the option than you are good to go, otherwise you cannot boot from USB.

So lets start

1. Download Format Utility by HP and DOS boot file from above given link
2. Extract these on your desktop
3. Plug in your USB 
4. Install HP format tool

after installation run "HP USB Disk Storage Format Tool" from desktop



5. Set file system to FAT 32
6. Put check mark on create a DOS startup disk, and than locate to the boot folder which you downloaded from above.

For me the path is

C:\Documents and Settings\Administrator\Desktop\boot

7.  Click on Start.

Note :  All data in the USB device will be remove after clicking on start, so make sure you have a backup of your data.

HOW TO USE DELETE STATEMENT SYNTAX IN SQL SERVER

The delete statement is use to delete rows from a table

The syntax of Delete statement is

Delete from table_name
where column_name='value'

lets say we have a table (name table_1) like this


and we want to delete those tuple who's city is karachi

so the syntax would be

Delete from table_1
Where city = 'karachi'

This will delete all tuples who's city is karachi, so the result set would be


Note : Make sure you use where clause with delete statement without it you can accidentally delete whole table.

For instance we a table

if we use

delete from table_1

This will remove all the records in a table so be care while using delete statement.

Tuesday, August 9, 2011

INSERT INTO SYNTAX IN SQL SERVER 2005

The INSERT INTO statement is used to insert new records in a table

There are two ways of using INSERT INTO statement

1. The first form doesn't specify the column names where the data will be inserted, only their values

INSERT INTO table-mane
VALUES ('value1' , 'value2')

2. The second form specifies both the column names and the values to be inserted:

INSERT INTO Table-name (column1,column2,column3)
VALUES ('Value1' , 'Value2' , 'Value3')

Lets say you have the following table name (mytable),


 now you want to insert new record in all columns of the table So the syntax would be

INSERT INTO mytable
values ( 'Khurram' , 'Kazmi' , 'Karachi')

The result of this syntax would be


In this syntax we insert in all three columns, what if we want to insert information in only 2 columns ??

For this we will use the 2nd syntax

INSERT INTO mytable (firstName , LastName)
values ('Mehdi' , 'Rehmani')

By using this syntax we will get the following output


Make sure that the column (city) is allowed to be null, otherwise you will  receive an error

Friday, August 5, 2011

String or binary data would be truncated. The statement has been terminated.

If you are getting  error like

String or binary data would be truncated. The statement has been terminated.

this error means that the nchar() is unable to save all the elements, because the nchar() size is small.

To fix this just increase the size of nchar() to something bigger.

save it and than run your query.


Thursday, August 4, 2011

WHAT IS DISCRETE MATHEMATICS

Discrete mathematics is the part of mathematics devoted to the study of discrete objects. ( Here discrete means consisting of distinct or unconnected elements.) The kind of problems solved using discrete mathematics include:

  • How many ways are there to choose a valid password on a computer system ?
  • What is the probability of winning a lottery ?
  • Is there a link between two computers in a network ?
  • What is the shortest path between two cities using a transportation system ?
  • How can a list of integers be sorted so that the integers are in increasing order ?
  • How many steps are required to do such a sorting ?
  • How can it be proved that a sorting algorithm correctly sort a list ?
  • How can a circuit that adds two integers be designed ?
  • How many valid internet address are there ?


More generally discrete mathematics is used whenever objects are counted, when relationship between finite ( or countable) sets are studied, and when processes involving a finite number of steps are analyzed. A key reason for the growth in the importance of discrete mathematics in that information is stored and manipulated by computing machines in a discrete fashion.