technical Stuff

Q.1  file Stucture from c?

Answer:-


File Structure  In c:
typedef struct
{
 short level ;
 short token ;
 short bsize ;
 char fd ;
 unsigned flags ;
 unsigned char hold ;
 unsigned char *buffer ;
 unsigned char * curp ;
 unsigned istemp;
}FILE ;


 Q2 how to change JVM memory in eclipse ?

Answer:-
           Step to increase memory on jvm in eclips:

Step1:   Select Run / Open Run Dialog
Step 2:   select the configuration for launching your application
Step 3: Click the Arguments tab
Step 4:   in the box "VM arguments" add something like "-Xmx256M" to give your application 256 MB of memory.


Q 3 Why array index start with 0? Ans:-
             It starts at 0 because the index value tells the computer how far it needs to move away from the starting point in the array. If you use an array you are really only referring to the memory address of the starting point of the array. When you reference a specific value in the array, you are telling the programming language to start at the memory address of the beginning of the array and then move up the memory address as needed. So suppose a program allocates space in the memory between address numbers 1024 and 2048 and it starts at 1024 and each item in the array is 8 bytes long. Then saying arrayName[0] is the same as telling it to look at the data stored at the memory address of (1024 + (0 * 8)), or 1024. If you want the value stored at arrayName[1], then it looks at the value held at (1024 + (1*8)), which is 1032. If you wanted the value held at arrayName[10], then it would look at the data stored in the memory address of 1024 + (10 * 8), which is 1104.



 Q.4 How to create header file in C? Ans:-
        Create a file and save it as .h extension
      e.g.
           int add(int a,int b)
          {
              return(a+b);
          }
       Save as  myheader.h
   
   In another program include this header file.

    e.g.
           #include<stdio.h>
           #include"myheader.h"
          void main()
         {
           int no1=30,no2=40,no3;
           num3=add(no1,no2);
            printf("Addition is =%d",no3);
          }


Q.5 What are the different approaches of programming?
Ans:-
        1)Object Oriented Programming
        2)Object Base Programming
        3)Procedure Oriented Programming
        4)Logical Programming
        5)Functional Programming

        6) Modular Programming

Q.6 Difference between while and for?
Ans:-
       While is dynamic and it is use when condition is not fixed.
       For is static and it is use when condition is fixed.


Q. 7   if we have array of integer which containing age for 10,000 people.Sort that array with optimised way. Ans:
            Program:-

                public class Sort
              {
                  static int a[]=new int[120];
                  public static void main(String[] args)
                 {
                      int age[]={10,15,17,20,10,13,12,15,15,40};
                      for(int i=0;i<age.length;i++)
                     {
                        int b=age[i];
                         a[b]=a[b]+1;       
                      }
                      for(int j=0;j<a.length;j++)
                     {
                       int r=a[j];
                         for(;r>0;r--)
                          {
                              System.out.println(j);
                          }
                     }

               }

          }

Q.8  if you have 2 dice and you have to show date from 00-31 Ans:-
      Write on dice
         Dice 1-  0,1,2,3,4,5
         Dice 2-  0,1,2,6,7,8
      for displaying 9 rotate number 6.


  Parameters for switch are Integer and character.
      1)Using Integer

          #include<stdio.h>
          void main()
          {
                int n;
                printf("\n enter choice");
                scanf("%d",&n);
                switch(n)
               {
                  case 1:
                            printf("\n A is greater");
                            break;
                  case 2:
                            printf("\n B is greater");
                            break;
                 default:
                            printf("\n both are same");
                            exit(0);
                  }
            }




      2)Using Character

            #include<stdio.h>
            void main()
            {
                   char c;
                   printf("\n enter choice");
                   scanf("%c",&c);
                   switch(c)
                   {
                      case 'a':
                            printf("\n A is greater");
                            break;
                     case 'b':
                            printf("\n B is greater");
                            break;
                      default:
                            printf("\n both are same");
                            exit(0);
                      }
                }

Q.9 Diffrernce between if and switch?


IF: it works under the Boolean literal whereas

SWITCH: it works under the integer/character literal


if statement is used when we have to check two condition for example
if the condition associated to if is satiafied than the statement associated with that is executed.
void main()
{
int i ;
printf ("enter the value of i");
scanf("%d",&i);
if (i==1)
{
printf("the no is one ");
}
printf("no is not one ");
}


switch:-switch is a multiconditional control statement .in this we check different conditions
in this we uses different cases if case is satisfied the statement associated to that case is executed.


 void main()
          {
                int n;
                printf("\n enter choice");
                scanf("%d",&n);
                switch(n)
               {
                  case 1:
                            printf("\n A is greater");
                            break;
                  case 2:
                            printf("\n B is greater");
                            break;
                 default:
                            printf("\n both are same");
                            exit(0);
                  }
            }


Q.10 what is use of curly bracket of if??


This is because it would not be useful code. If you have an if-statement without curly braces ({}), only the first line / statement after the if is executed. So if you only declare a local variable, it cannot be used anywhere else.

if(proceed)
{ int i= 0; // variable i can be used here
}

if (proceed)
int i; // i can not be used anywhere as it is a local variable.


Q.11 how we declare array in c/c++?

an array need to be declare so that the compiler will know what kind of an array and how large an array we want.
There are different type of array
1. one dimensional
2. multi dimensional

In our programming, we have done with the statement:

one dimensional

syntax:   data type array_name[size];
e.g.   int mark[30];

multi dimensional

syntax:   data type  array_name[size][size];

e.g int stud[5][5];


Q12. What is Singleton design pattern??


The singleton pattern is a design pattern that restricts the Instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects.


Q13 what are different alogorithm available for garbage collection??

Q.5.Why main is starting point of program??can we change it??





Q.9 program for ten bottle containg size of 10 gram. assume that one of them is 9 gram how to find it?



Q14 if we have array of 13 integer sort it with optimize way
condition
1.we cannot declare another array
2. you cannot modify array
3.you cannot delcare more than 5 variable



Q16
Q17 Ques.1 - You are working on critical mission project, as a part of the project,it is required to write a function in c which accept two co-ordinates(x1,y1) for a given point p, you need to determine which quadrant given point belongs, e.g. (10,15)(both are positive hence it in Quadrant I,where as point(-10,15) in Quadrant II. In all the there are nine possibilities as given below:
I Quadrant,II Quadrant,III Quadrant, IV Quadrant, +X Axis, -ve X Axis, +Y Axis, -Y Axis and Origin(0,0).





Unfortunately compiler on your computer has developed strange behaviour, it can't compile any conditional statements like If........then else,switch.....case, therefore you can't write any conditional statement. It is very urgent that we need to write the function and can't wait for your compiler to get fixed. Write program /function in c or VB which will accept 2 co-ordinates and return one of the 9 possible values given above. Please remember that you can't write any conditional statement in your function/program.







No comments:

Post a Comment