This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Sunday, November 25, 2012

C LAB PROGRAM



/* 1. CHECK MAXIMUM VALUE THAT CAN BE REPRESENTED IN ALL THE 
        STORAGE  TYPES. [ int(short,long,signed,unsigned), char, double, float]
*/
* 2. WRITE A C PROGRAM TO REVERSE A NUMBER */

           
/* 3A. WRITE A C PROGRAM TO GENERATE 'N' PRIME NUMBERS. */

#
/* FUNCTION TO FIND PRIME NO. */

/* 3B. INPUT TWO INTEGERS 'N' AND 'M'.FIND THE NO. OF PRIME NUMBERS
    B/W 'N' AND 'M'(CREATE A FUNCTION WHICH FINDS IF THE GIVEN NO. IS
    PRIME.THIS FUNCTION CAN BE CALLED REPEATEDLY).
 */


/* 4A. WRITE A C PROGRAM TO GENERATE N FIBONACCI NUMBERS */


/* 4B. WRITE A C PROGRAM TO GENERATE FIBONACCI SERIES UPTO A GIVEN
   NUMBER */


/* 4C. WRITE A C PROGRAM TO GENERATE 3 DIGITS FIBONACCI SERIES */



/* PR5.WRITE A C PROGRAM TO CONVERT THE FOLLOWING :
            a. DECIMAL TO BINARY NUMBER
            b. BINARY TO DECIMAL NUMBER
            c. REAL DECIMAL NUMBER TO HEXADECIMAL NUMBER
            d. REAL DECIMAL TO OCTAL NUMBER


/* 6A. WRITE A C PROGRAM TO SUM THE SERIES:

                                                   x^3     x^5     x^7
                               SIN(x)= x - ----- + ----- + ----- + ...
                                                    3!        5!        7!   

/* 6B. WRITE A C PROGRAM TO SUM THE SERIES:

                                               x^2     x^4    x^6
                        COS(x)= 1 - ----- +  ----- - ----- + ...
                                                 2!       4!        6!         
*/

           

/* 6C. WRITE A C PROGRAM TO SUM THE SERIES:

                                                   x       x^2     x^3
                                e^x = 1 + ----- + ----- + ----- + ...
                                                   1!        2!       3!          */


/* 7. THREE POSITIVE INTEGERS a,b,c FORM A TRIPLET OF a^2 + b^2 = c^2.
     WRITE A C PROGRAM TO FIND ALL PYTHOGOREAN TRIPLETS a,b,c WHERE
     a,b < 120.
*/


/* 8. INPUT AN INTEGER N, FIND OUT THE POSITIONS OF OCCURRENCE OF  
    DIGITS  0,1,2,3,4,...9 IN THIS NUMBER. (CREATE A FUNCTION WHICH FINDS  
   THE POSITIONS OF OCCURRENCE OF A PARTICULAR DIGIT. THIS FUNCTION
   CAN BE CALLED REPEATEDLY).
*/



/* 9a.WRITE A CPROGRAM TO GENERATE THE FOLLOWING OUT PUT:

           a) 1
               2 3
               4 5 6
               7 8 9 10


/* 9b.WRITE A CPROGRAM TO GENERATE THE FOLLOWING OUT PUT:

            b)                     1
                                 1 2 1
                              1 2 3 2 1
                           1 2 3 4 3 2 1
                        1 2 3 4 5 4 3 2 1
/* 10. IN A GIVEN STRING, FIND THE FREQUENCY OF OCCURRENCE OF
    A PARTICULAR LIST
*/

# /* 11. WRITE A C PROGRAM TO ARRANGE ALL CHARACTERS IN A STRING
    IN ASCENDING ORDER.
*/

/* 12. WRITE A C PROGRAM TO FIND IF THE GIVEN STRING IS A 
    PALLINDROME */


/* 14. ACCEPT N WORDS (WHICH FORM A SENTENCE), ONE WORD AT A TIME.
    OUTPUT IT ON THE SCREEN AS A SENTENCE WITH BLANKS BETWEEN WORDS, AND A FULLSTOP AT THE END.
*/
/* 15.  INPUT A STRING AND FIND THE NUMBER OF NUMERIC CHARACTERS,
    LOWERCASE AND UPPERCASE ALPHABETIC CHARACTERS RESPECTIVELY  
    AND ANY OTHER THAN THE ABOVE
*/

/*  16.  INPUT A STRING AND FIND THE NUMBER OF TIMES, EACH OF THE FIVE
     VOWELS APPEAR IN THE GIVEN STRING
*/
# /*  17. WRITE A C PROGRAM TO DELETE ALL THE OCCURENCES OF A 
     CHARACTER IN A STRING.
/*  18. WRITE A C PROGRAM TO COPY THE CONTENTS OF ONE STRING TO
     ANOTHER.
*/

/*  19.  WRITE A C PROGRAM TO COUNT THE NUMBER OF WORDS IN A 
     SENTENCE.
            =====OUT PUT=====

           
/*  20.  WRITE A C PROGRAM TO COUNT THE NUMBER OF CHARACTERS,
    WORDS AND LINES IN A TEXT.
*/

/*  21. WRITE A FUNCTION TO FIND THE LENGTH OF A STRING. */

/*  22. WRITE A FUNCTION TO THE GCD OF TWO NUMBERS. USING GCD
     FUNCTION,WRITE A MAIN PROGRAM TO FIND THE LCM OF FOUR 
     NUMBERS.         

/* 23. WRITE A FUNCTION TO FIND THE FACTORIAL OF A NUMBER. USING
   THIS FUNCTION FIND nCr.
                                                                 n!
                                                nCr =  -----------
                                                             (n-r)! * r!

/*  24. WRITE A PROGRAM TO CHECK WHETHER A GIVEN ARRAY IS SORTED.
     (ASCENDING,DESCENDING OR UNSORTED)
*/
/* 25. WRITE A PROGRAM TO FIND THE LARGEST ELEMENT IN AN ARRAY AND
   POSITION OF IT'S OCCURENCE
*/
/* 26B. WRITE A PROGRAM TO SEARCH AN ITEM IN A LIST USING
    BINARY SEARCH
*/
* 27. INPUT A NxN MATRIX, DISPLAY IT IN MATRIX FORM AND DETERMINE IF
   IT IS A LOWER TRIANGULAR MATRIX. (LOWER TRIANGULAR MATRIX IS A
   SQUARE MATRIX IN WHICH ALL THE ELEMENTS ABOVE THE PRINCIPAL
   DIAGONAL ARE ZEROES
*/
/* 28. INPUT A NxN MATRIX, DISPLAY IT IN MATRIX FORM AND DETERMINE IF
   IT IS A UPPER TRIANGULAR MATRIX. (UPPER TRIANGULAR MATRIX IS A
   SQUARE MATRIX IN WHICH ALL THE ELEMENTS BELOW THE PRINCIPAL
   DIAGONAL ARE ZEROES

/* 29. INPUT A NxN MATRIX, DISPLAY IT IN MATRIX FORM AND DETERMINE
   IF IT IS AN IDENTITY MATRIX.
*/

/* 30. INPUT TWO NxN MATRICES A AND B, DISPLAY A,B AND A*B
   (CREATE THREE FUNCTIONS TO READ, DISPALY AND CALCULATE A*B)
*/
*/
/* 33. USE RECURSION TO FIND THE FIRST N TERMS OF THE FIBONACCI
   SERIES
*/
#
/* 34. WRITE A RECURSIVE FUNCTION TO FIND THE FACTORIAL OF A NUMBER */

/* 35. WRITE A RECURSIVE FUNCTION TO FIND THE SUM OF N NATURAL
   NUMBERS
*/

/* 37. USE RECURSION TO FIND X^n WHERE X IS A REAL NUMBER AND n
   IS AN INTEGER. n CAN BE NEGATIVE, ZERO OR POSITIVE

 /* 38. FIND THE SOLUTION OF THE GIVEN QUADRATIC EQUATION. ( CREATE
    A MACRO WHICH CALCULATES THE DETERMINANT.
                                                      ____________
                                         -A  ±   B^2 - 4*A*C
   Formula used:-   X =  --------------------------------
                                                            2*A
*/

/* 39. FIND THE LARGEST AND SECOND LARGEST OF THREE INTEGERS.
    ( CREATE MACRO WHICH FINDS LARGEST OF TWO INTEGERS.USE THIS  
    MACRO MULTIPLE TIMES. USE A NESTED IF ELSE STRUCTURE.)
*/

/* 40. CREATE AN ARRAY OF TEN ELEMENTS WHERE EACH ELEMENT IS A 
    STRUCTURE WITH THE FOLLOWING FIELDS : IDNO, NAME,MARKS AND 
    AGE. READ DATA INTO THIS ARRAY. FIND THE AVERAGE MARKS OF THESE
   TEN STUDENTS AND ALSO THE NAME OF THE YOUNGEST STUDENT.
*//* 41. DECLARE THREE POINTER VARIABLES TO STORE A CHARACTER,
    A CHARACTER STRING AND AN INTEGER RESPECTIVELY. INPUT VALUES
    INTO THESE VARIABLES. OUTPUT THESE POINTER VARIABLES AS WELL
    AS THEIR CONTENTS.


/* 44. INPUT THREE INTEGERS X, Y AND N.PERFORM
               a. BIT WISE AND OF X AND Y
               b. BIT WISE INCLUSIVE OR OF X AND Y
               c. BIT WISE EXCLUSIVE OR OF X AND Y
               d. BIT WISE COMPLEMENT OF X
               e. LEFT SHIFT OF X BY N BITS
               f. RIGHT SHIFT OF Y BY N BITS

   DISPLAY X,Y AND THE RESULTS OF THE ABOVE OPERATIONS IN BIT
   FORMAT.


/* 45. CREATE A FILE OF TEN RECORDS WHERE EACH RECORD HAS
    THE FOLLOWING FIELD : IDNO,NAME,MARKS AND AGE.
    READ DATA INTO THIS FILE. FIND THE AVERAGE AGE OF
    THESE TEN STUDENTS AND ALSO THE NAME OF THE STUDENT
    WHO SCORED THE MAXIMUM MARKS.

/* 46. CONVERT ALL LOWER CASE LETTERS IN A FILE TO
               UPPER CASE LETTERS.

/* 47. WRITE A C PROGRAM TO COPY THE CONTENTS OF ONE FILE
       TO ANOTHER.
*/        
/*49. WRITE A C PROGRAM TO APPEND A FILE */


/* 50. CONSIDER TWO SORTED FILES FILE1 AND FILE2. WRITE A PROGRAM
   TO GENERATE FILE3 WHICH IS THE RESULT OF MERGING FILE1 AND FILE2
   IN THE SORTED ORDER.
*/
           
/* 51.WRITE A C PROGRAM TO DEMONSTRATE THE WORKING OF A STACK OF
    SIZE N USING AN ARRAY.THE ELEMENTS OF THE STACK MAY BE
    ASSUMED TO BE OF TYPE INTEGER OR REAL. THE OPERATIONS TO BE
    SUPPORTED ARE:
    a.PUSH       b.POP  C.DISPLAY
    THE SHOULD PRINT APPROPRIATE MESSAGES FOR STACK OVERFLOW,
    STACK UNDERFLOW AND STACK EMPTY. YOU MAY WRITE SEPERATE
    FUNCTIONS TO DETECT THESE CASES.

/*59. WRITE A PROGRAM TO SIMULATE THE WORKING OF A QUEUE OF  
   NAMES USING AN ARRAY.PROVIDE THE FOLLOWING OPERATIONS:
  a.CQINSERT b.CQDELETE c.CQDISPLAY
           
           

/* 60.USING DYNAMIC VARIABLES AND POINTERS, CONSTRUCT A
   SINGLY LINKED LIST CONSISTING OF THE FOLLOWING
   INFORMATION IN EACH NODE :
   a.LINSERT-INSERTING IN FRONT OF THE LIST
   b.LDELETE-DELETING A NODE BASED ON JOB-ID
   c.LSEARCH-SEARCHING A NODE BASED ON JOB-ID
   d.LDISPLAY-DISPLAYING ALL THE NODES IN THE LIST
*/

/*61. A DEQUE IS A LIST IN WHICH ITEMS CAN BE ADDED OR DELETED FROM
  EITHER END OF THE LIST.IMPLEMENT THE WORKING OF SUCH A DEQUE OF
  INTEGERS
            /* 63.USING POINTERS AND DYNAMIC VARIABLES, CONSTRUCT A
    BINARY SEARCH TREE (BST) OF INTEGERS.
    a.GIVEN A KEY, PERFORM A SEARCH IN THE BST.IF THE KEY IS
    FOUND THEN DISPLAY "KEY FOUND", ELSE INSERT THE KEY IN BST
    b.WHILE CONSTRUCTING THE BST, DO NOT ADD ANY DUPLICATES.
    c.DISPLAY THE TREE USING ANY ONE OF THE TRAVERSAL METHODS.
/* 66. WRITE A C PROGRAM TO SORT A LIST OF N ELEMENTS OF
   INTEGER TYPES USING THE QUICK SORT ALGORITHM.
*/
           
/*67. WRITE A C PROGRAM TO SIMULATE THE WORKING OF
  TOWERS OF  HANOI PROBLEM FOR N DISC.PRINT THE NUMBER OF
  MOVES BY YOUR PROGRAM.
           
/* C PROGRAM TO PRINT ASCII CODES */

* C PROGRAM TO PRINT BIOSKEY */


            

Saturday, November 24, 2012

Shortcut Formulae frequently used in solving Aptitude Question Papers


Given below are Shortcut Formulae frequently used in solving Aptitude Question Papers

1.     1+2+3+4…. +n = n (n+1) / 2

2.     12+22+32…. +n2 = n (n+1)(2n+1) / 6

3.     13+23…+n3 = [n2(n+1)2] / 4

4.     1+3+5…. 2n-1= n2

5.     Every prime number greater than 3 can be written using the formula (6k+1) or (6k-1)

6.     Number of factors present in a number is given as (p+1)(q+1)(r+1)…Where N=(ap)+(bq)+(cr)…
Where a, b, c are prime numbers and p, q, r are positive numbers

In the same way sum of all factors=[(a(p+1) / (a-1)][(b(q+1) / (b-1)]…

7.     If there is P volume of pure liquid initially in each operation and Q volume is taken out and replaced by Q volume of water then at the end of n such operations, the concentration k is given as K = [(P-Q) / P]n

8.     If successive increase in percentage is given p%, q%, r% then effective % increase is given as [(100+p)/100][(100+q)/100][(100+r)/100]-1}*100

9.     If an article is sold such that a article has a profit of p% on one and loss of p% on other then we have the net result to be loss and the loss percent is (p2) / 100                                                                                 
10.In a party each members shakes hand with other member. If total number of Hand shakes were N then Number of members in Party = Larger nearest whole squared number to N. E.g.: N=210, Larger nearest Square to 210 is 225. So Members = (225)1/2 = 15.

11.            If a person goes at X km/hr in forward direction and returns back at Y km/hr then the average speed is 2XY / (X+Y)

12.            If a person traveling between two points reaches p hours late traveling at u kmph and reaches early traveling at v kmph, the distance between two points is  [vu(p-q)] / (v-u)

13.            If we have a term of this sort “Apple” the number of possible arrangements possible are
5! /2!

14.            Number of ways of selecting one or more items from n given items is  (2n)-1

15.            If we are given problems based on number of squares possible all together then we have a generalized short cut method of doing it
Eg: given a chess board (8*8) how many squares can be formed the solution is (82) + (72) + (62) + (12)

19.            If a problem is given with some sequence (2, 4, 6...)And (3, 6, 9..) along with just 2 operations possible the answer is the number of Square terms.           

20.            In calendars the first day of the year after the leap year will be in this manner. If Jan 1 of 2006 was on Sunday then Jan 1 of 2005 will be on Saturday and that of Jan 1 of 2004 will be on Thursday this is because 2004 is a leap year so there is an extra gap of one.

21.            Given a circular track and both the riders ride in the same direction then the first time they meet is given as L / (a-b) for opposite direction it is L / (a+b)
Where L is the length of the track and a, b the speed of riders.

22.            If A can complete a work in a days and B can complete it in b days then A and B working together can complete it in ab / (a+b)

23.            If A can complete a work in a days and B can complete it in b days and C can complete it in c days then all working together can complete it in abc / (ab+bc+ca)                                                 
24.            If two trains start at the same time from two points A and B towards each other and after crossing they take x and y hrs to reach B and A respectively then (A speed): (B speed)=[(x)1/2] : [(y)1/2]                          
                            
25.            If Length of a rectangle is increased by I1% and Breadth is increased by I2% then The Percentage increase in Area is I1+I2+[(I1*I2) / 100]                                                                           
26.            If Length of a rectangle is increased by I% and Breadth is decreased by D% then Percentage increase or decrease in Area is I-D-[(I*D) / 100]                                                                                         
27.            If Length of a rectangle is decreased by D1% and Breadth is decreased by D2% then Percentage increase or decrease in Area is  D1-D2+[(D1*D2) / 100]       
                                                                  
28.            If A is R% more than B, the Percentage B less than A is (100*R)/(100+R)

29.            If A is R% less than B, the Percentage B more than A is (100*R)/(100-R)

34.            How many numbers are divisible by n between A and B. Solution is (A / n) – (B / n)

30.Let the present population of a town be P with an annual increase of R% then:
Population after n years =    P (1+R/100)n                                                         
Population n years ago   =    P / (1+R/100)n

30.            If the price of a commodity increases by R% then the reduction in consumption so as not to increase the expenditure is (100*R) / (100+R)     
                  
31.            If the price of a commodity decreases by R% then the increase in consumption so as not to decrease the expenditure is (100*R) / (100+R)              
         
32.            Let the present value of a machine be P. Suppose depreciates at the rate of R% per annum. Then
Value of Machine after n years   =   P(1-R/100)n
     Value of Machine n years ago     =   P / (1-R/100)n  

35.            In a examination A% registered Candidates are absent and B% failed out of those who are present. If successful Candidates are X then.
Number of Registered Candidates = (100*100*X ) / [(100-A)(100-B)]
             
36.                                       If a number divisible by D1 leaves a remainder R1, Then the same number when divided by D2 the remainder will be the remainder got in scomputing R 1 / D2.                                                                                                                     
37.            A reduction of A% in the price of a commodity enables the purchaser to obtain C kgs more for Rs. B. Then the price per kg of the commodity before reduction is (A*B) / [(100-A)*C]             
                                                                            
38.            When the price of a commodity decreased by A%, the sale increased by B%. The effect on Sale is A–B - (AB / 100)                                               
                            
39.            A number should be subtracted from numbers a, b, c, d so that the remainders may be proportional. Then the number is (AD-BC) / [(A+D)-(B+C)]                                                                    
40.            If N men takes X days to complete a work if M men left the team they complete the work in Y days. Then the number of men Left the team is M = [N(Y-X)] / Y.         
                                     
41.            If the Average age of N members is A. If M members are added to the team the Average becomes less by a value B. Then the Average age of Newcomers is A – [(N/M + 1) * B]                                                       
42.            If A number of men or B number of women can complete a work in X days. Then time taken to complete the same work by a number of men and b number of women is X / (a/A + b/B)
                                                         
43.            If P1 number of pipes working H1 number of hours can fill a tank in D1 days. Then number of hours H2 needed for P2 number of pipes to fill same tank in D2 number of days is  H2 = (P1 * H1 * D1) / (P2 * D2)               

44.            A and B together can do a piece of work in X days. A can do it alone in Y days.Then number of days needed by B to finish the work alone is XY/(Y-X)                                  
                                     
45.            Two pipes can fill a tank in X hours and Y hours respectively. The third pipe can empty it in Z hours. Then the number of hours needed to fill the tank if all pipes are opened simultaneously is XYZ / (YZ + ZX –XY)       

46.            A train with a speed of X kmph starts from a place. Another train starts from the same place after t hours with a speed of Y kmph . Then
     The time in which they meet is  (X*t)  /  (Y-X)
     The distance taken to meet is Y(X*t) / (Y-X)           
                  
47.            If a train passes the station of length X metres in T1 seconds but a person in T seconds. Then the length of the Train is (X*T1) / (T1-T)                            

48.            If the Cost price of X articles is equal to the Selling price of Y articles. Then the Gain Percent is [100(X-Y)] / X                               
         
49.            By selling B items one gains the selling price of A items. Then the Gain percent is (A*100) / (B-A)                                                        
         
50.            Selling price of an item is X.The Profit percent is equal to the Cost Price. Then the Cost Price is –50+[10*(25+X)1/2]                   
                            
51.            A certain sum of money at Simple interest amounts to Rs.A in a years and Rs.B in b years. Then Rate percent = [(B-A)*100] / [Ab-Ba].
Also Principal = (Ab-aB) / b-a                       
                            
52.            If a certain sum at simple interest is becoming m times in t years then it will become n times in [(n-1)*t] / [m-1] years                        
                                     
53.            If a certain sum at C becomes n times with rate percent R% then the number of years required is [(n-1)*100] / R years           
                            
54.            If a sum at simple interest becomes n times in T years then Rate percent is [(n-1)*100]/T

55.            The difference between S.I and C.I on a sum of money at R% per annum for n years is Rs.X. Then the principal is X[(100/R)n]

56.            The Compound interest value on a certain sum is C.I for n years for R% then the simple interest will be for same R% and n years is S.I = n * C.I /  (n+R/100)

WRITE A C PROGRAM TO SUM THE SERIES:


/* WRITE A C PROGRAM TO SUM THE SERIES:

                                                   x       x^2     x^3
                                e^x = 1 + ----- + ----- + ----- + ...
                                                   1!        2!       3!          */


#include<stdio.h>
#include<conio.h>
#include<math.h>

#define PI 3.143

long int fact(int n)  /* To find factorial */
{
            if(n==0)
                        return 1;
            else
                        return(n*fact(n-1));
}
void main()
{
            int i,n,term=1;
            float x,y,sum;
            clrscr();
            printf("\n Enter No. of Terms N [1-12] : ");
            scanf("%ld",&n);
            if(n>=1 && n<=12)
            {
                        printf("\n Enter the Value of 'X' in degrees : ");
                        scanf("%f",&y);

                        x=y*(PI/180.00); /* Converting degrees to radians */

                        sum=1;
                        for(i=1;term<=n;i++)
                        {
                                    sum+=pow(x,i)/(float)fact(i);
                                    term++;
                        }
                        printf("\n e^%.2f = %f",y,sum);
            }
            else
                        printf("Wrong entry!!!");
            getch();
}




/*         =====OUT PUT=====

       1.Enter No. of Terms N [1-12] : 8

             Enter the Value of 'X' in degrees : 60

             e^60.00 = 2.850986

       2.Enter No. of Terms N [1-12] : 12

             Enter the Value of 'X' in degrees : 90

             e^90.00 = 4.813863

       3.Enter No. of Terms N [1-12] : 9

             Enter the Value of 'X' in degrees : 0

             e^0.00 = 1.000000