C programming




Introduction

Before explaining C programming let us discuss what programming is ?????

 well programming is the set of instruction given to the computer , instruction to get our job done .

In our daily day-to-day life we also give instruction to others like “bring me that”  “complete the work” ,”go there” and etc .

So in computer science also we give instruction to the computer to get our job done like adding a bunch of numbers , finding solution to a mathematical problem , or doing some computational problem and so on
Like in English we follow grammar to complete our instruction like that we have specific way of giving instruction to the computer , and  as in our real life we have many languages to communicate similarly we have many languages we can use to write these computer instruction called programming languages and the instructions are called programs .

So that was a loose definition of programming language and programs

In the list of many programming language C is one of the oldest and popular programming language , it is small but can produce many complex programs and if you are interested in the history of C programming please visit this link  wikipedia C programming language

I won’t be describing a lot of detail on the theory part but still some information about C Language that I think you people should know

C Language is a procedural language that means it follows procedures or functions or sub routine in order to complete the task .
Well if you don’t know what a function is then not to worry you would know  later in the course but for now function can be defined as self contained unit of code
C Language is a multi platform language that means you can develop programs for almost all the major platform with C like windows , Linux , Unix etc , you just need a compiler and in case if you wonder what a compiler is , well I am going to explain it just wait for a moment

So that will be enough about the theory part , Now

What is the programming process?
The programming process follows like this



So first we have the source code that is the code we have written in C Language , we then compile the source code with a compiler , So compiler is a program that converts a user readable program to something that can be understood by a computer and after that we get a exe file or  executable file and then we run or execute the program

If the program executes well then its working fine but if not then it has a bug in it , a bug can be defined as a behavior of a program that we are not expecting , So in order to solve the problem we have to debug it , it’s the fancy way of saying “What Is Wrong In The Program”
We can start writing code in a command prompt which I find boring sometime so we would use a IDE  or what’s called as Integrated Development Environment , it’s a piece of software that we use to write our program and for this purpose I am using DEV C++ , its free and easy to install and use , you can download it from the following link Download

I hope you have downloaded it and install it

So to create a new program just do

File < New < Source File or just type ctrl + n (for new document)

Now we can write our program here

Let’s write our first program

main()
{
      printf("Hello World \n");
      getch();         
 }

That is it , now give a name to the program like “hello” with an extension dot c , so that will be “hello.c” and change the “save as type” dialog box to “c source file” and save the file
You can compile the program from going to the menu and

execute < compile (ctrl +F9)

and run the program by

execute < run (ctrl + F10)

The output of the program is to display “Hello World” message on the

console like

Now let’s examine the program

main()  {  }  - this called the main function , every c program should have a main function otherwise it won’t compile , at this point it might be difficult to understand what a function is but later it would be clear to you as we proceeds further but for now main is a function , 

every function has starting and closing round brackets following the function name and also opening and closing curly brackets which define the body of that function . Main is not the only function , there many more functions in C

function name ( )
{
Body of the function
}

Printf(“  “);  - well again this is also a function , and we do not see a body here don’t worry you will know about it later in the course but for now it’s a C function that accepts everything that is inside the double quotes and display it on the screen , that is the function of this function

printf(“ display this message on screen  \n“);

The semicolon – the semicolon is used to signify that “this is the ending of this statement” it’s like the “full stop” for programming language 
Statement ;

\n – slash n means new line , if you want to display two sentences one followed by other then use the \n character and if you don’t use it ,everything will appear in the same line

getch() – again we can see that it is a function , the function of this function is to hold the console until it gets an input from the keyboard and when we press any key the programs stops , if you have difficulty in understanding this then remove the “getch();” command and see how the program behaves and then add it again to see what do I mean here





working on more 
pl write to me if you want more elaborate explanation of a topic listed ,
thank you




Variables and Data Types



Ok lets learn the two very important concepts in C programming , variables and data types. 

So as the name suggest variable is something that is not constant that varies , we use variable in programming to store data , that could be numbers or text and data type defines the type of the data stored in the variable , so let me give an example to make it easy
Lets sat we want to store someone phone number in a program and display the number , so where we are going to store the number , we store it in a variable named “phone” (variable names are user defined , we give names to the variable , but there are some rules to follow , which I will explain very shortly)

So this would look like

Phone = value ;
Here value can be any integer
So this becomes
Phone = 123456;

This implies that phone is a variable to which we have assigned a value 123456
Now we also have to tell the compiler that “phone” can store what kind of value , like an integer or a character or a decimal value and so on and we tell this by using data type which tells the compiler  what is the type of data the variable can store , there are different key word for different data type and the major types are

int for integer value
char for storing individual characters
float for decimal value
double same as float but can store larger numbers  

please note that every data type has predefined range within which we can store values which we would discuss shortly

So to use a variable we write

int phone = 123456;

technically speaking variables are named piece of memory that we can assign a value , if you find that difficult , consider variables as a kind of box that we use to store data , the label of the box is its name and the type of content inside the box is its data type and the content is the value




Some rules to follow while naming a variable are as follows

1 > no two variables should have the same name in other words variables should be unique
2> variables name cannot begin with a number for example 123baby
3> variables can only have a to z , A to Z , 0 to 9 and underscore in it
4> variable have to be declared before they are used that means to specify the data type ,

 Syntax for variable declaration is

Data type variable_name = value_of_varibale ;


let’s find more about the integer data type

Data Type
Byte
Range
int
4
–2,147,483,648 to 2,147,483,647

In the above table the byte field represents the maximum size of a number an integer data type can hold and range displays that the number could be between negative 2,147,483,648 to positive 2,147,483,647 , so how we are getting this value ,
 well for information every data type has a certain range but to understand the relation between byte size and range let us do some binary calculation

So computer stores everything in bits that is zero or one , now 4 byte is equal to how many bits , 

since 8 bit is 1 byte so 4 byte will be 32 bit

8 bit = 1Byte

4Byte = 8 * 4 = 32 bit

So in binary if we have 32 numbers of 1s then the value in decimal form will be 4,294,967,295 but since int can store both negative and positive value this number splits in two equal parts including 0 , so the range splits in half to  –2,147,483,648 to 2,147,483,647  , but if we add these two values we would get 4,294,967,295 , this is how we get the  range from size , if possible try to find the other range by yourself ,
This link might be helpful to you Microsoft library

Enough with variables and data types now let us do a program with variable

 main()
{
int phone = 123456;    
 printf("Hello World \n");
printf("Your phone number is %d \n",phone);
getch();         
 }

This program display hello world followed by 123456
Now let us examine the new elements in the program 
int phone = 123456;   well this is not new , here we have declared a variable with integer type and assigned a value to it

printf("Your phone number is %d \n",phone);  printf is explained before , 
in order to display the variable in the statement we use the %d notation inside the quotes then a comma and then the variable name, 
please remember that the position of %d in the statement will decide the position of the variable in the statement , so it %d is before the word number then the variable will appear in that position

Now let us do a program with more numbers of variables

main()
{
int phone = 123456;    
int mobile = 9876543;
printf("Hello World \n");
printf("Your phone number is %d and mobile is %d \n",phone,mobile);
getch();         
 }

This is how we express multiple variable in a statement , here the first %d is for phone and the second for mobile variable
Some examples of how to declare and display other data type are

main()
{
float number = 55.5;    
printf("value of number is %f”,number);
getch();         
 }

 main()
{
double number = 44.54;    
printf("value of number is %lf”,number);
getch();         
 }

main()
{
Char car = ‘m’;
printf("value of character is %c”,car);
getch();         
 }

As we can see we have %f is for floats , %lf is for double and %c is for character

Some Small programs



A program to convert from celcius to ferenheit

main()
{
      float  farenheit;
      float celcius;
     
      printf("Enter Celcious value........... ");
      scanf("%f",&celcius);
     
      farenheit = 32 + celcius * 9 / 5 ;
     
      printf("\n\n %.2f Degree Celcius in  Farenheit is.........%.2f  farenheit",celcius,farenheit);
     
      getch();
     
      }

 Try to do ferenheit to celcius by your own


A program to find the prime numbers between 1 to 100

main()
{
     
      int i,j;
      int s;
      for(i =1;i<=100;i++)
      {
          
           s=0;
           for(j=1;j<=i;j++)
           {
          
           if(i%j==0)
           s=s+1;
                          
           }
          
           if(s==2)
           {
           printf("%d\n",i);
         }
     }

 getch();
 }

A program to check a given number is prime or not

main()
{
       int i,num;
       printf("Enter a number \n");
       scanf("%d",&num);

for(i=2;i<num;i++)
         {
            
                     if(num%i == 0)
       {
                      printf(" This Is Not A Primt Number ");
                      break;
                     }
         }      
                        if(i==num)
                        {
                         printf(" This Is a Prime Number ");
                         }
getch();

}


A program to display odd and even number between 1 to 100

main()
{
     
      int i;
      for(i=1;i<=100;i++)
       {
       if(i%2 == 0)
       {
       printf("Even Number %d\n",i);
       }                  
      
       else
       {
       printf("Odd Number %d\n",i);
       }
      
       }
      
       getch();
       }




A program to find a given number is even or odd

main()
{
     
      int num;
      printf("Enter a number \n");
       scanf("%d",&num);
       if(num % 2 == 0)
       {
       printf("Even Number");
       }                  
       else
       printf("Odd Number");

       getch();
      
}

A program to print febonacci series upto 20

main()
{
      int a = 0;
      int b = 1;
      int i,sum;
     
      for(i = 0;i<20;i++)
      {
            sum = a+b;
            printf("%d\n",sum);
           
            a=b;
            b=sum;
      }
     
      getch();
     
      }



A program to find the biggest number from three numbers

#include<stdio.h>

main()
{

//enter three different values

int a,b,c;

printf("Enter 1st Number\n");
scanf("%d",&a);

printf("Enter 2nd Number\n");
scanf("%d",&b);

printf("Enter 3rd Number\n");
scanf("%d",&c);

if(a > b && a > c )
printf("The Largest Number is %d",a);


if(b > a && b > c )
printf("The Largest Number is %d",b);

if(c > a && c > b)
printf("The Largest Number is %d",c);

getch();
}





A program to find the smallest number from three numbers

#include<stdio.h>

main()
{

//enter three different values

int a,b,c;

printf("Enter 1st Number\n");
scanf("%d",&a);

printf("Enter 2nd Number\n");
scanf("%d",&b);

printf("Enter 3rd Number\n");
scanf("%d",&c);

if(a < b && a < c )
printf("The Lowest Number is %d",a);


if(b < a && b < c )
printf("The Lowest Number is %d",b);

if(c < a && c < b)
printf("The Lowest Number is %d",c);

getch();
}


A program to create random numbers

#include<stdio.h>
#include<stdlib.h>

main()
{
int i;

srand(time(NULL));

for(i=0;i<10;i++)
printf("Random Number %6d \n",rand());

fflush(stdin);

getch();

}


A program to create dice rolling effect

#include<stdio.h>

main()
{

 int rolls,number,i;

 printf("Enter The Number  Of Times You Want To Roll The Dice  ");
 scanf("%d",&rolls);

 srand(time(NULL));

 for(i=0;i<rolls;i++)
 {
 number = rand(); 
 number = number % 6;
 number++;
 printf("\n Dice Rolled %d Number Is : %d \n",i+1,number);            
 }
     
 getch();
}

A program to find rate of interest

#include<stdio.h>

main()
{
 int year,period;
 float amount,interest_rate,value;

 printf("Enter Amount \n");
 scanf("%f",&amount);

 printf("Enter Interest Rate \n");
 scanf("%f",&interest_rate);

 printf("Enter Period \n");
 scanf("%d",&period);

 year = 1;


 printf("\n\n");

 while(year <= period)
 {
  value = amount + interest_rate * amount;
  printf("%2d Price %8.2f\n",year,value);
  amount = value;
  year = year + 1;         
 }
     
getch();

}

 
 A program to print multiplication table from 1 to 10

main()
{
     
int i,j;
     
int array[10][10];
     
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
array[i][j] = (i+1)*(j+1);
}                
}
     
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
printf("%3d ",array[i][j]);
}
printf("\n");
}
     
     
getch();
     
}

 
A program to find average of 5 subjects

#include<stdio.h>

main()
{
 int sub1,sub2,sub3,sub4,sub5;
 int sum;
 float avg;

 printf("Enter Subject 1 Marks\n");
 scanf("%d",&sub1);

 printf("Enter Subject 2 Marks\n");
 scanf("%d",&sub2);

 printf("Enter Subject 3 Marks\n");
 scanf("%d",&sub3);

 printf("Enter Subject 4 Marks\n");
 scanf("%d",&sub4);

 printf("Enter Subject 5 Marks\n");
 scanf("%d",&sub5);

 sum =  sub1+sub2+sub3+sub4+sub5;

 avg = (float)sum/5;

 printf("Average of The Subjects is %.2f ",avg);

 getch();    
}


A program to find maximum

#include<stdio.h>

main()
{


 int n,i,max;

 printf("Enter Total Numbers Of Numbers In The Array\n");
 scanf("%d",&n);

 int array[n];


 for(i=0;i<n;i++)
 {
 printf("Enter %d Number \n",i+1);
 scanf("%d",&array[i]);
 }


 max = array[0];
 
 for(i=0;i<n;i++)
 {
 if(array[i] > max)

 max = array[i];
 }

      printf("The Largest Number in the array is %d ",max);
     
      getch();
     
}


A program To find minimum

#include<stdio.h>

main()
{


 int n,i,min;

 printf("Enter Total Numbers Of Numbers In The Array\n");
 scanf("%d",&n);

 int array[n];


 for(i=0;i<n;i++)
 {
 printf("Enter %d Number \n",i+1);
 scanf("%d",&array[i]);
 }


 min = array[0];
 
 for(i=0;i<n;i++)
 {
 if(array[i] < min)

 min = array[i];
 }

      printf("The Smallest Number in the array is %d ",min
      );
     
      getch();
     
}


A program to find average of n numbers

#include<stdio.h>

main()
{

 int n,i;
 int sum;
 float avg;

 printf("Enter Total Number of the array \n");
 scanf("%d",&n);

 int array[n];

 for(i=0;i<n;i++)
 {
 printf("Enter %d number \n",i+1);
 scanf("%d",&array[i]);

 sum = sum + array[i];
 }
     
     
      avg = (float)sum/n;

printf("Average Of The Numbers Are %.2f ",avg);

getch();

}


A program to tell the nature of image placed before a lens


#include<stdio.h>
#include<conio.h>
main()
{
float radius,focus,o_distance,i_distance,infinity,beyond_curvature,magni;
char conti,y,n;


printf(" PROGRAM TO FIND THE NATURE OF IMAGE OF A CONCAVE MIRROR ");


printf(" \n\n\n\n                         #                         .              ");
printf(" \n                          #   Concave Mirror     . . .            ");
printf(" \n                           #                       .              ");
printf(" \n                            #                      . Positive     ");
printf(" \n                             #                                    ");
printf(" \n                Focus         #                                   ");
printf(" \n      ..C.........F.......... O.........................          ");
printf(" \n                              # pole                .             ");
printf(" \n   Radius of Curvature       #                      . Negitive    ");
printf(" \n                            #                     . . .           ");
printf(" \n            Negative       #     Positive           .             ");
printf(" \n           .              #             .                         ");
printf(" \n          ...........    #     ...........                        ");
printf(" \n           .                            .                         ");


printf("\n\n\n\n Enter radius of Curvature(in CM) ------- ");
scanf("%f",&radius);

focus=radius/2;

printf("\n\n Focal Length will be at(in CM) -----( -ve ) %f",focus);


printf("\n Centre of Curvature will be at(in CM)-----( -ve )%f",radius);

infinity=3*radius;

beyond_curvature=2*radius;


do
{
printf("\n Enter the Distance of the object fron the Mirror(in CM) ------");
scanf("%f",&o_distance);


i_distance=(1/-focus+1/o_distance)*100;



if(o_distance>=infinity)
{
printf("\n\n Position of the object....................infinity ");
printf("\n\n Image will be formed at Focus (in CM)-----");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Diminished");
}


else if(o_distance>beyond_curvature)
{
printf("\n\n Position of the object....................Beyond Centre of Curvature ");
printf("\n\n Image will be formed between center of curvature and focus(in CM)------");
printf("\n\n Nature--------\n\n Real\n\n Inverted \n\n Diminished");
}
else if(o_distance==radius)
{
printf("\n\n Position of the object....................at centre of curvature ");
printf("\n\n Image will be formed at centre of curvature(in CM).........");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Same size");
}


else if(o_distance>focus)
{
printf("\n\n Position of the object....................Between centre of curvature and focus ");
printf("\n\n Image will be formed at Beyond center of curvature ");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Magnified ");
}


else if(o_distance==focus)
{
printf("\n\n Position of the object....................at focus ");
printf("\n\n Image will be formed at infinity ");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Hypermagnified");
}


else if(o_distance<focus)
{
printf("\n\n Position of the object....................Betweew pole and focus ");
printf("\n\n Image will be formed behind the mirror ");
printf("\n\n Nature--------\n\n Virtual\n\n Erect\n\n Magnified");
}


else
{
}
printf("\n\n\n image distance = %f",i_distance);
if(i_distance<0)
{
printf(" To the LeftHand side of pole ");
}
else
{
printf(" To the RightHand side of pole ");
}
magni=i_distance/o_distance;
printf("\n Magnification is = %f",magni);
printf("\n\n Do you want to change the object position (y/n) ");
scanf("%s",&conti);

}
while(conti=='y');



getch();
}

//feel free to modify the logic according to your need if neede

A program to  display the place value of a number (upto Billion Only) 


#include<stdio.h>

main()
{

long int digit[10];
char place[30][30] = {"Ones","Tens","Hundreds","Thousands","Ten Thousand","Hundred Thousand","Million","Ten Million","Hundred Million","Billion"};
long int data[10];


/* count number of digits */
int c = 0; /* digit position */
int n ;
int i;
int number;

printf("enter a number\n");
scanf("%d",&n);
number = n;
while (n != 0)
{
    n /= 10;
    c++;
}

printf("the number of digits int the number is %d\n\n\n",c);
int numberArray[c];


for (i = 0; i < 10; i++) {
  numberArray[i] = number%10;
  number = number / 10;
}


int j = 10;

digit[0] = 0;


for(i = 1;i<10;i++)
{

digit[i] = j;

 j = j * 10;

}


for(i = 0;i<10;i++)
{
printf("%d__________%5s____________%d\n\n",digit[i],place[i],numberArray[i]);
}

getch();
}



A program to tell Horoscope


#include<stdio.h>
#include<conio.h>
main()
{
int select,option;
int c,p,a,ar,t,g,ca,l,v,li,s,sa;
char y;


printf("\n                              Select your Zoic Sign \n");
printf("\n                                  1 CAPRICORN");
printf("\n                                  2 AQUARIUS");
printf("\n                                  3 PISCES");
printf("\n                                  4 ARIES");
printf("\n                                  5 TARUS");
printf("\n                                  6 GEMINI");
printf("\n                                  7 CANCER");
printf("\n                                  8 LEO");
printf("\n                                  9 VIRGO");
printf("\n                                  10 LIBRA");
printf("\n                                  11 SCORPIO ");
printf("\n                                  12 SAGGITTARIUS \n\n                                       ");
scanf("%d",&select);

switch(select)
{
case 1:
printf("\n\n                           You Have Selected CAPRICORN \n\n ");
printf("\n            Your Date of Birth Lies between 1st December to 20th January \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&c);
     switch(c)
     {
     case 1:
     printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Money Forms an important partof your life and reaching your full potential is   something you worry about\n You have the ability to earn good money throygh life but are sometimes hindered for the lack of opportunity you have\n\n Working in a structured environment is oftenthe best and the most successful    way you work\n although partnerships may also bring about success.\n You are prone to suffring from stress related illness like headaches and back   pain so don't over do it");
     break;

     case 2:
     printf("\n\n.................................Friends and Companions..........................\n\n");
     printf(" You have a amicable personality and therefore a large circle of friends very    few  you are intimate with\n You are very loyal to choose friends and people ofen see you as a soldier to    cry on because of your good nature\n Intimate companions will normally be born under pisces , virgo , scorpio and    cancer");
     break;

     case 3:
     printf("\n\n....................................Personality.................................\n\n");
     printf(" You are a very talented , courageous , truthful , individual.\n You have a clear views on things and are at times painfully frank.\n You have a quick temper and because of this often say things you latter regert ");
     break;
     }
break;

case 2:
printf("\n\n                           You Have Selected AQUARIUS \n\n ");
printf("\n            Your Date of Birth Lies between 21st January to 19th February \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&a);
     switch(a)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Your impressionable nature means you are often taken advantage of financial     situations.\n People often see you soft touch and you must overcome this if you asr to reach  the hights of your desire.\n You are quit unlucky in speculative ventures and should avoid gambling\n\n Your love of natural beauty and high degree of energy means that professions in the performing arts , teaching , artistry , medicine and other science would    suite you well ");
     break;

     case 2:
      printf("\n\n.................................Friends and Companions.........................\n\n");
     printf(" Your appreciation of intellectual beauty through your love of poetry and art    means that you enjoy being in the company of intelligent people.\n Although you have many friends who admire you very few are close to you.\n You get on best with people born under libra , gemini and aries ");
     break;

     case 3:
      printf("\n\n....................................Personality.................................\n\n");
     printf(" You are energetic , loving and inspirational and are often seen as an attention speaker\n You have a love of natural beauty , ars and mugic.\n You often have a sence of mystic and a fascination with physic abilities ");
     break;
     }
break;

case 3:
printf("\n\n                           You Have Selected PIECES \n\n ");
printf("\n            Your Date of Birth Lies between 20th Febuary to 20th Mars \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&p);
     switch(p)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Your financial situation vill vary greatly during your worling career.\n At other time it will be more difficult.\n Your turbulent relationship with   money means that it is important for you to  put money away for harden times ahed.\n You are hard working although your pessimstic nature means you tend    to worry too much ");
     break;

     case 2:
      printf("\n\n..................................Friends and Companions........................\n\n");
     printf(" Your ability to communicate well with people means you will always have a large group of friends\n However people find you rather hard to understand because of your dual personalities. ");
     break;

     case 3:
      printf("\n\n....................................Personality..................................\n\n");
     printf(" You are generous and loyal to friends and kind hearted.\n At times you appear to have dual personality as you can be two totally          different individuals.\n Overall you tend to have a pessimistic attitude towards things which you need   to fight.\n You posse's good communication skills and have good foresight. ");
     break;
     }
break;

case 4:
printf("\n\n                           You Have Selected ARIES \n\n ");
printf("\n            Your Date of Birth Lies between 21st Mars to 20th April \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&ar);
     switch(ar)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Inclined to be impulsive which you need to come to terms with to succeed.\n You have the ability to attain fincial independence if you do not spread your   efforts too much.\n If you can learn to coordinate your mind and body success will be assured.\n You are practical and always tyr to improve the ways you do things ");
     break;

     case 2:
      printf("\n\n..................................Friends and Companions........................\n\n");
     printf(" You will have large group of friends  and admirers and will go to extremes to   defend friends you fell are unjustly threatened.\n You have an ability to make friends very easy and are excellent social mixer    because of your entertainning personality ");
     break;

     case 3:
      printf("\n\n....................................Personality.................................\n\n");
     printf(" Determined , industrious and practical minded.\n You tend to be blunt and plain spoken with a high degree of eloquence.\n You are inclined to be impatient and regard your opinions and judgement to be   as good as others ");
     break;
     }
break;

case 5:
printf("\n\n                           You Have Selected TARUS \n\n ");
printf("\n            Your Date of Birth Lies between 21st April to 21st May \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&t);
     switch(t)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Although mney will never be a problem for you throughout life , it does tend to burn a hole in your pocket.\n You need to control your spending if you want to complete fincial stability in  later life.\n Your determination and ambitious nature means you are a hard working and        diligent employee .\n You will have successful career and are capable of achieving greats hights ");
     break;

     case 2:
      printf("\n\n....................................Friends and Companions.......................\n\n");
     printf(" Through your personality traits you will have many friends who admire your      loving and honest nature.\n You enjoy sharing your life with others and have lot of devoted friends. ");
     break;

     case 3:
      printf("\n\n....................................Personality.................................\n\n");
     printf(" You have an  ambitious and determined nature and are cautions , lovind and      honest.\n At time you can be stubborn and people find it hard to change your opinion of   things.\n You are often guided by your deep emotions and have a friendly and optimistic   character ");
     break;
     }
break;

case 6:
printf("\n\n                           You Have Selected GEMINI \n\n ");
printf("\n            Your Date of Birth Lies between 22nd May to 21th June \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&g);
     switch(g)
     {
     case 1:
     printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Your fincial position will alter greatly throughout life.\n At times money will come easy , at other times less so.\n Putting money away for the future is the best strategy for you.\n You open mindeness will serve you well at work where you will adapt well to     changing environment and new tasks.\n Your slight nervousness may hinder you so try overcome this ");
     break;

     case 2:
     printf("\n\n..................................Friends and Companions........................\n\n");
     printf(" You will be regarded as a soulder to cry on by both close friends and more      distance ones.\n Your sensitive nature attracts people to share their worries with you .\n You will have few very close friends who you can turn to ");
     break;

     case 3:
     printf("\n\n....................................Personality.................................\n\n");
     printf(" You often have a nervous temperament but are sensitive , Cautious and versatile.\n You have an innovative nature and an inquisitive mind and enjoy scoring out     information on subjects that interest you.\n This means you develop an depth understanding of such topics ");
     break;
     }
break;

case 7:
printf("\n\n                           You Have Selected CANCER \n\n ");
printf("\n            Your Date of Birth Lies between 22nd June to 23rd July \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&ca);
     switch(ca)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Your sign displays clear signs of wanting to save money.\n You like to gamble once in a while and are generally a lucky person as long as  you follow your instincts and are not influenced by others.\n In your working career you are thorough and methodical-A lateral thinker.\n You like being motivated and can easily become down if you are not encouraged ");
     break;

     case 2:
      printf("\n\n..................................Friends and Companions........................\n\n");
     printf(" Surrounded by a large group of friends you are generally very popular.\n You will feel happy confiding in close friends who always have your best        interests at heart.  ");
     break;

     case 3:
      printf("\n\n....................................Personality................................\n\n");
     printf(" You are extremeley sensitive character with a friendly and loving nature but    often be irritable and moody.\n Living in a world of your own you are a bit of daydreamer.\n In your community you are a popular person. ");
     break;
     }
break;

case 8:
printf("\n\n                           You Have Selected LEO \n\n ");
printf("\n            Your Date of Birth Lies between 24th July to 23rd August \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&l);
     switch(l)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Your financial affairs will have many ups and downs. It is therefore important  that you invest early on life to provide for your future.\n External fincial support will come from close friends and relative at time when you most need it.\n In your working career you have the ability to achieve great successes.\n Your ambitious nature coupled with good problem solving skills make you a       valuable addition to any business   ");
     break;

     case 2:
      printf("\n\n..................................Friends and Companions........................\n\n");
     printf(" You will have a large circle of friends who like your generous and enthusiastic personality.\n People find you slightly hot headed and impatient  ");
     break;

     case 3:
      printf("\n\n....................................Personality.................................\n\n");
     printf(" You have a ambitious , generous and determined nature .\n You easily looses your temper and become restless.\n Akey strength that you posses is your ability to adapt to almost any situation  you are put in ");
     break;
     }
break;

case 9:
printf("\n\n                           You Have Selected VIRGO \n\n ");
printf("\n            Your Date of Birth Lies between 24th August to 23rd September \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&v);
     switch(v)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" Fincial success will be achieved through exploiting your artistic abilities .\n Your methodical and intellectual nature means that when you find a profession   in life that is well suited to you ");
     break;

     case 2:
      printf("\n\n..................................Friends and Companions........................\n\n");
     printf(" Your strong desire to succeed means that you appreciate the finer things in     life , This in turn influnce the social circle you move in.\n You choose your friends very carefully and generally they are of a similar      nature to you ");
     break;

     case 3:
      printf("\n\n....................................Personality..................................\n\n");
     printf(" You often have a nervous temperament, but are sensitive , cautious and          versatile.\n You have an innovative nature and an inquisitive mind and sourcing out          information on subjects that interest you  ");
     break;
     }
break;

case 10:
printf("\n\n                           You Have Selected LIBRA \n\n ");
printf("\n            Your Date of Birth Lies between 24th September to 23rd Octobor \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&li);
     switch(li)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" If you can fulfil your full potential you have the ability of achieve a high    level of wealth.\n Money does tend to burn a hole in your pocket through.\n Wise investments early in your life will assure you of a secure future.\n You will have a successful carrer through your way of work. ");
     break;

     case 2:
      printf("\n\n...................................Friends and Companions.......................\n\n");
     printf(" You choose your closest friends carefully although they are often of a totally  different nature to you.\n You enjoy spending time alone . ");
     break;

     case 3:
      printf("\n\n....................................Personality.................................\n\n");
     printf(" You are a well balanced individual.\n You are loving , selfish and idealistic .\n You have a forgiving and sympathetic nature, although you can be slightly hot   tempered at times ");
     break;
     }
break;

case 11:
printf("\n\n                           You Have Selected SCORPIO \n\n ");
printf("\n            Your Date of Birth Lies between 24th Octobor to 22nd November \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&s);
     switch(s)
     {
     case 1:
      printf("\n\n...................................Work and Finance.............................\n\n");
     printf(" Although you will not fulfil your full capabilities until later life, you will  set a steady growth in fincial status as your career progresses.\n Your good sence of humour and laid back approch to life will mean that you are  able to take on anything that falls in your path ");
     break;

     case 2:
      printf("\n\n...................................Friends and Companions.......................\n\n");
     printf(" People enjoy your company but dislike the way you try to dominate all           situations.\n You enjoy spending time with those who have a similar sense of humour to you    and share your laid back approach on life ");
     break;

     case 3:
      printf("\n\n....................................Personality.................................\n\n");
     printf(" You have a generous , sympathetic and determined nature.\n You are well liked by friends and colleagues because of your sence of humour ");
     break;
     }
break;

case 12:
printf("\n\n                           You Have Selected SAGITTARIUS \n\n ");
printf("\n            Your Date of Birth Lies between 23rd November to 21th December \n ");
printf("\n                                  Choose a Catagory\n");
printf("\n                                  1 Work and Finance \n");
printf("\n                                  2 Friends and Companions \n");
printf("\n                                  3 Personality \n ");
scanf("%d",&sa);
     switch(sa)
     {
     case 1:
      printf("\n\n....................................Work and Finance............................\n\n");
     printf(" You are extreamely resourceful. You like to work on your own ideas.\n Your fincial status will grow with your experience . You are a bit impulsive in your work  ");
     break;

     case 2:
      printf("\n\n....................................Friends and Companions.......................\n\n");
     printf(" You do not have a large circle of friends.\n People often regards you as a workaholic and become jealous of your success in  later life ");
     break;

     case 3:
      printf("\n\n....................................Personality.................................\n\n");
     printf(" Your overall outlook on life is very positive and you have a high degree of     intelligence.\n You are happy to share all that you own with those around you.\n You are slightly hot tempered and are easily upset ");
     break;
     }
break;

default:
printf("................................Invalid Parametre............................... ");

}

getch();
}