Showing posts with label PROGRAMS. Show all posts
Showing posts with label PROGRAMS. Show all posts

Saturday, 21 June 2014

Write a C++ Program for converting temperature from fahrenheit to celsius or the revese way depends on user's Choice.




Program for converting temperature from fahrenheit to celsius or the revese way depends on user's Choice.





#include<iostream.h>
int main()
{
int choice;
float temp,countp;
cout<<"Temperature conversion Menu "<<"\n";
cout<<1.Fahrenheit to celsius "<<"\n";
cout<<"Enter the choice";
cin>>choice;
if(choice= =1)
{
cout<<"\n"<<Enter temp. fahren.:";
cin>>temp;
countp=(temp - 32)/1.8;
cout<<"The temp. in celsius is :"<<countp<<"\n";
}
else
{
cout<<"\n"<<"Enter temp . in centigrade";
cin<<temp;
countp=1.8*temp+32;
cout<<"The temp. in fahre. is : "<<countp<<"\n";
}
return 0;
}




Output :

Temperature conversion Menu
1. Fahrenheit to celsius
2. celsius to  Fahrenheit
Enter the choice :2
Enter temp. centigrade:37
The temp. in fahre. is : 98.6




 

Thursday, 19 June 2014

TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON JAVA - SET 4






     TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON JAVA - SET 4





1. Exceptions that are expected to possibly occur are called

(A)  checked exceptions
(B) unchecked eceptions
(C) runtime exceptions
(D) errors



2. The following statements

String wer = "12\u3456\u78910 ";
System .out .println (wer. lenght());


(A)  print 4
(B) print 13
(C) print5
(D) print 15



3.Garbage collectors frees the programmer from worrying about

(A) memory leaks
(B) dangling refrences
(C) creating new objects
(D)  recursion




TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON JAVA - SET 3






TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON JAVA - SET 3




1.The given statements

   double whatIsThis = -1.0/0.0;
    system .out .println(whatIsThis);


(A) -Math .floor(-x)
(B)  -Math .cell(-x)
(c)  prints -Infinity
(D)  prints a garbage value




2.Math .cell(X) has the same value as


(A)  -Math .floor(-x)
(B) -Math .cell(-x)
(C) -Math .floor(-x)
(D) -Math .cell(x)




3. Let m be a variable of datatype byte .The value of m<<4 is same as


(A)  m x 2^4        (B)  4m             (C)   m^4              (D)   4+ m




Write a program to find a factorial of an integer.








PROGRAM TO FIND FACTORIAL OF AN INTEGER



#include<iostream.h>
#include<stdlib.h>
int main()
{
int i,num,fact =1;
cout<< "\n Enter integer : ";
cin>>num;
i = num;
while(num)
{
fact*=num;
--num;
}
cout<<" The factorial is";
cout<<fact;
return 0;
}

Write a program using for loop to print first 10 natural numbers





To print first 10 natural numbers Using for Loop





#include<iostream.h>

int main()
{
system("cls");
int i;
for(i=1;i<=10;i++)
{
cout<<i<<"\t";
}
return 0;
}

Wednesday, 18 June 2014

TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON C++ -- SET 5



SET 5  TECHNICAL INTERVIEW QUESTIONS ON C++


1.  Select the correct Statements

(a)  A destructor is not inherited                         (b)  A constructor cannot be called explicitly

(c) A destructor can be called explicitly             (d) A contructor is not  inherited



CLICK HERE TO SEE THE ANSWER

ANSWER IS (a) , (b) and (d)


2.  The compiler identifies a virtual function to be pure

(a)  by the presence of keyword  PURE             (b)  by its location in the program

(c) if it is equated to 0                                       (d) none of the above


3.  A class having no name


(a)  is not allowed

(b) cannot have a contructor

(c)  cannot have a destructor

(d) cannot be passed as argument


CLICK HERE TO SEE THE ANSWER

ANSWER IS (b) , (c) and (d)


TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON C++ -- SET 4







SET 4 TECHNICAL INTERVIEW QUESTIONS ON C++


1. Consider the following code

void main()
{
int x =10;
int &p=x;
cout<< &p<<&x;
}

(a) prints 10 and the adress of x                                (b)  results in run time error

(c)  prints the address of x twice                                (d)  prints the adress of p twice.


CLICK HERE TO SEE THE ANSWER

ANSWER IS   (C) AND (D)


2. Which of the following is not an storage class in c++

(a)  register               (b)  auto                   (c) mutable                    (d)  dynamic



3. Consider the following program segment

static char x[3] = " 1234";
cout<<x;


These two segments with complete program will print

(a) prints 123                                           (b) prints 12345

(c)  prints 1234 followed by some junk         (d)   will give a compilation error


TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON C++ -- SET 3






SET 3 QUESTIONS FOR TECHNICAL INTERVIEW  ON C++

1.  Suppose many functions have the same name, which of the following information , if there , will be used by the compiler to invoke  the correct function to be used ?

(a)  The operator ::                                                          (b)  The return value of the function

(c)  Function signature                                                     (d)  None of the above


CLICK HERE TO SEE THE ANSWER

ANSWER IS (a ) and ( c).


2. A constructor  is called  whenever

(a)  a class is used                                                             (b)  an object is used

(c) all of these                                                                    (d) an object is declared


CLICK HERE TO SEE THE ANSWER

ANSWER IS  ( D)


3. Which of the following are correct for constructors and destructors ?

(a)  Constructors can take arguments but destructors cannot.

(b) Constructors can be overloaded but destructors cannot.

(c) All of these

(d)  Destructors can take arguments but constructors cannot.


CLICK HERE TO SEE THE ANSWER

ANSWER IS (A) and (B)


TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON C++ -- SET 2


 TECHNICAL INTERVIEW AND PRACTICE QUESTIONS ON C++
 -- SET 2 --


 1. The following C++ code results in

#include "iostream.h"
void main(void)
{
cout<<(int i = 5)<<(int j=6);
}

(a)  compilation error                          (b) run time error

(c) link time error                               (d)  none of the above




2.  Reusability is a desirable feature of a language as it

(a)  decrease the testing time                   (b) lowers the maintence cost

(c)  reduces the compilation time             (d) reduces the execution time



3. Choose the correct statements regarding inline functions.

(a)  It speeds up execution                      (b)  It slows down execution

(c)  It increases the code size                  (d)  It decreases the code size



Write a Program in c++ to find the radius of a circle ,calculate the area and perimeter and display them.



C++ Program to Find Radius,Area and Perimeter of Circle



#include<iostream.h>
#include<stdlib.h>
int main()
{
double radius,area,perimeter;
cout<<"Enter the radius of circle:";
cin>>radius;
perimeter=2*3.14*radius;

WRITE A C++ PROGRAM TO READ COORDINATES OF TWO POINTS AND CALCULATE DISTANCE B/W THEM BY GIVEN FORMULA.



Program to Read coordinates of two Points and Calculate Distance b/w the by given Formula.



GIVEN FORMULA : sqrt((x1-x2)^2 + (y1+y2)^2)


PROGRAM

#include<iostream.h>
#include<stdlib.h>
#include<math.h>
int main()
{
double distance,x1,y1,x2,y2;
cout<<"Enter the coordinates of point1: ";
cin>>x1>>y1;
cout<<"Enter the coordinates of point2:";
cin>>x2>>y2;