Search This Blog

31 May, 2011

C Program of finding biggest of 3 numbers using ternary operator.


/* Biggest of 3 numbers using ternary operator - BIGTER.C */

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c, big;
clrscr();
a=1;
printf("Enter three numbers: ");
scanf("%d %d %d",&a, &b, &c);
big = a > b ? (a>c?a:c):(b>c?b:c);
printf("\nThe biggest number is : %d",big);
getch();


}


RUN 1 :
~~~~~~~
Enter three numbers : 10 20 30
The biggest number is : 30
RUN 2 :
~~~~~~~
Enter three numbers : 20 30 10
The biggest number is : 30
RUN 3 :
~~~~~~~
Enter three numbers : 30 10 20
The biggest number is : 30

C- Program to find the biggest of three numbers.


/* Finding the biggest of 3 numbers using if...else - BIGIFEL.C */

# include <stdio.h>
# include <conio.h>
void main()
{
int a, b, c ;
clrscr() ;
printf("Enter three numbers : ") ;
scanf("%d %d %d", &a, &b, &c) ;
if(a > b)
{
if(a > c)
printf("\n%d is the biggest number", a) ;
else
printf("\n%d is the biggest number", c) ;
}
else
{
if(c > b)
printf("\n%d is the biggest number", c) ;
else
printf("\n%d is the biggest number", b) ;
}
getch() ;
}
RUN 1 :
~~~~~~~
Enter three numbers : 10 20 30
30 is the biggest number
RUN 2 :
~~~~~~~
Enter three numbers : 20 30 10
30 is the biggest number
RUN 3 :
~~~~~~~
Enter three numbers : 30 10 20
30 is the biggest number

30 May, 2011

C program of printing multiplication table.


/* Program to print the multiplication table - MULTABLE.C */

# include <stdio.h>
# include <conio.h>
void main()
{
int r, c, y ;
clrscr() ;
r = 1 ;
printf("The multiplication table is :\n\n") ;
do
{
c = 1 ;
do
{
y = r * c ;
printf("%5d", y) ;
c = c + 1 ;
} while(c <= 10) ;
printf("\n\n") ;
r = r + 1 ;
} while(r <= 10) ;
getch() ;
}
RUN 1 :
~~~~~~~
The multiplication table is :
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100

C Program of Performing arithmetic operations using switch...case.


/* Performing arithmetic operations using switch...case 
- ARITH.C */


#include<stdio.h>
#include<conio.h>
void main()
{
int n1, n2, ch ;
clrscr() ;
printf("Enter the first number : ") ;
scanf("%d", &n1) ;
printf("\nEnter the second number : ") ;
scanf("%d", &n2) ;
printf("\n[1] -> Addition ") ;
printf("\n[2] -> Subtraction ") ;
printf("\n[3] -> Multiplication ") ;
printf("\n[4] -> Division ") ;
printf("\n\nEnter your choice <1...4> : ") ;
scanf("%d", &ch) ;
switch(ch)
{
case 1 :
printf("\n%d + %d = %d", n1, n2, n1 + n2) ;
break ;
case 2 :
printf("\n%d - %d = %d", n1, n2, n1 - n2) ;
break ;
case 3 :
printf("\n%d * %d = %d", n1, n2, n1 * n2);
break ;
case 4 :
printf("\n%d / %d = %.2f", n1, n2, (float)n1 / n2);
break ;
default :
printf("\nInvalid choice");
break ;
}
getch();
}

Swapping of two numbers using three variables - C program


/* Swapping two numbers (using three variables) - SWAPTHRE.C */

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the first no. ");
scanf("%d",&a);
printf("Enter the second no. ");
scanf("%d",&b);
printf("/n Before Swapping: \n\n");
printf("a= %d \t b= %d",a,b);
c=a;
a=b;
b=c;
printf("\n After Swapping: \n\n");
printf("a= %d \t b= %d",a,b);
getch();
}

Swapping two numbers without using third variables - C program


/* Swapping two numbers (using two variables) - SWAPTWO.C */

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter the first no. ");
scanf("%d",&a);
printf("Enter the second no. ");
scanf("%d",&b);
printf("/n Before Swapping: \n");
printf("a= %d \t b= %d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("\n After Swapping: \n");
printf("a=%d \t b=%d",a,b);
getch();
}

02 May, 2011

Installation of Sql Server 2000

Before starting installation process, we check the computer name:


  Start  - Control Panel - System - Computer Name - Change    


If the text box against Computer Name contains  "Wrong name" or  "(ULTA-SIDHA) name" then correct it to proper name (no space) and   select OK button.


Sql Server 2000 Installation Process :-
                           To install "Sql Server 2000", You have to follow various steps written below. 

Double click on  Autorun  or the  Setup of Sql Server 2000. 
  (While giving name don't give space with Name in between)






1.  Select Sql Server 2000 Components
2. Install Database Server
3. Next 
4. Select - Local Computer Radio Button 
                Then Press Next Button
5. Select - Create a new Instance of Sql Server
                or install client tools Then Press Next Button 
6. On the next screen Enter the name and 
   company name (Default will appear - Don't change.) 
   Then Press Next Button
7. Press Yes Button
8. Select Server and Client tools radio button
    Then Press Next Button
9. Remove Default Checkbox 
    and give instance name (eg. MayurDB)
    Then Press Next Button
10. Select Typical radio Button 
      Then Press Next Button
11. Instead of use a Domain User Account 
     Select Use the local system account radio button
     Then Press Next
12. Instead of Windows Authentication Mode
      Select Mixed Mode Radio Button 
                                                                                            (note: give the password- yours surname)
      Superuser username will be (sa)
      Type /  Retype Password of username
      Then Press Next button
13. Press Next and use common sense for next screens

A Sql Server ICON with Green Triangle will appear on task bar. It means that Sql Server is running. If it doesn't appear then 

Start - All Programs - Microsoft Sql Server - Service Manager

Three Buttons appear (Start / Stop / Pause) Use Common sence
Select the AutoStart Service when OS Starts Check Box Testing:

Start - All Programs - Microsoft Sql Server- Query Analyzer 
Enter login name (sa)
Enter password  (Whatever you specified during installation)

A window will appear where you can type Sql Statements type the following 

Create table student
(roll int, name char(20))

Press (F5) to execute (don't use the concept of; like Sql Plus, that is done in ORACLE)

Then remove the create statement from Query Analyzer window and type the following

Insert into student values (101,'Ram')

Press (F5) the clear it and type (Select * from student) and press (F5) Creating a new Database

1.Start Enterprise manager
2.Expand the Microsoft Sql Servers node
3.Expand the Sql Server Groups node
4.Expand the (Local) node
5.Right click on Database Node
6.Select new Database option
7.Specify the name of the database (eg. shop)
8.Click on OK


Creating a new user account and granting rights for the created database

1. Expand the security node
2. Right click the login node
3. Select new Login option
4. Type the name (eg. Mayur)
5. Select the Sql Server authentication radio button
6. Type the password (eg. Upadhyay)
7. Select the Database combo box given below
    the password text box and select our database (eg. shop)
8. Select Server Roles Tab from top and check all the options
9. Select the Database Access Tab from top and select
    the shop database
10. In the permit in database Role section given below, 
     select all the checkboxes 
11. Click OK
12. Password confirmation will be asked, type your 
     assigned password.
13. Close Enterprise Manager.

Now when you start Query Analyzer and Login by the login created then your default database will be shop and you will have all the rights to it.




Meetme@