Saturday, 5 November 2011

Program Using Switch Case

A Maruthi car dealer maintains a record of sales of various vehicles in the following form:

Vehicle type             Month of sales           Price(Rs)

Maruthi-800                 02/87                      75,000

Maruthi-van                 07/87                       95,000

Maruthi-DX                  04/88                      1,10,000

Gypsy                             08/88                      85,000

Write a c program to read this data in to a table of strings and o/p the details of particular  vehicle sold during a specified period the program should request the user to input the  vehicle type and the period.(starting month and ending month)

Algorithm:

Step 1: Start

Step 2: Enter your choice

Step 3: Read ch value

Step 4: if ch =1 then

4.1 printf "Month of sales is : 02/87”


4.2 printf "Price is : 75,000"


Step 5: if ch =2 then

5.1 print "Month of sales is : 07/87 "


5.2 print "Price is  : 95,000”


step 6: if ch=3 then

6.1 print "Month of sales is  : 04/88 "


6.2 print " Price is  : 1,10,000"


Step 7:

7.1 print "Month of sales is : 08/88 "

7.2 print " Price is  : 85,000"


Step 8 : end

Program:

Write a program to read x and to compute y=1 for x>0,y=0 for x=0 and y=-1 for x

Algorithm:

 Step1:         Start


Step2:         Read the value of x.


Step3:         if (x>0) y-1 else if (x=0) y=0 else x<0) y=-1


Step4:         Print y


Step5:         Stop.



Program:

evaluate the expression 2.5 log(x) +cos(a)+|x2-y2|+2(xy)1/2

Algorithm:

Step1:         Start


Step2:         Read the values of x,y and a.


Step3:         p=2.5*log(x)+ cos(a*3.14/180)+sqrt(2*x*y)+(x*x-y*y)


Step4:         Print p


Step5:         Stop.


 

 

Program:

Friday, 4 November 2011

What is Native Image Generator (Ngen.exe)?

The Native Image Generator utility (Ngen.exe) allows you to run the JIT compiler on your assembly's MSIL and generate native machine code which is cached to disk. After the image is created .NET runtime will use the image to run the code rather than from the hard disk. Running Ngen.exe on an assembly potentially allows the assembly to load and execute faster, because it restores code and data structures from the native image cache rather than generating them dynamically.

Below are some points to be remembered for Native Image Generator:-

What is the difference between Convert.ToString and .ToString() method ?

Just to give an understanding of what the above question means seethe below code.

int i =0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));


We can convert the integer “i” using “i.ToString()” or “Convert.ToString” so what’s the difference.

The basic difference between them is “Convert” function handles

How to prevent my .NET DLL to be decompiled?

By design .NET embeds rich Meta data inside the executable code using MSIL. Any one can easily decompile your DLL back using tools like ILDASM (owned by Microsoft) or Reflector for .NET which is a third party. Secondly there are many third party tools which make this decompiling process a click away. So any one can easily look in to

Thursday, 3 November 2011

Predict the output or error(s) for the following:

class base

{

        public:


        int bval;


        base(){ bval=0;}


        };

 

class deri:public base

{

        public:


        int dval;


        deri(){ dval=1;}


        };

void SomeFunc(base *arr,int size)

{

for(int i=0; i<size; i++,arr++)


        cout<<arr->bval;

cout<<endl;


}

 

int main()

{

base BaseArr[5];


SomeFunc(BaseArr,5);


deri DeriArr[5];


SomeFunc(DeriArr,5);


}

Answer:

 00000


 01010


Explanation: