1
Q:

# We want to round off x, a $\inline \fn_jvn {\color{Blue} Float}$to an $\inline \fn_jvn {\color{Blue} Int}$ value. The correct way to do so would be

 A) Y = ( int ) ( x + 0.5 ) ; B) Y = int ( x + 0.5) ; C) Y = ( int ) x + 0.5; D) Y = ( int ) ( ( int ) x + 0.5 )

Answer:   A) Y = ( int ) ( x + 0.5 ) ;

Explanation:

Rounding off a value means replacing it by a nearest value that is approximately equal or smaller or greater to the given number.

y = (int)(x + 0.5); here x is any float value. To roundoff, we have to typecast the value of x by using (int)

Example:

#include <stdio.h>

int main ()

{

float x = 2.6;

int y = (int)(x + 0.5);

printf ("Result = %d\n", y );

return 0;

}

Result : 3

Subject: Programming
Q:

In programming, repeating some statements is usually called  ?

 A) Running B) Structure C) Looping D) Control structure

Explanation:

Filed Under: Programming
Job Role: Analyst , IT Trainer

6 104
Q:

Write a quick script for launching a new activity within your application.

An explicit intent explicitly defines the activity the developer wishes to start.

Script code :

Intent myIntent = new Intent(this, MyNewActivity.class);

startActivity(myIntent);

Subject: Programming

144
Q:

A source program is the program written in which level language  ?

 A) Alpha Numeric B) High-Level C) Symbolic D) Machine

Explanation:

Filed Under: Programming
Exam Prep: Bank Exams
Job Role: Analyst , Database Administration , IT Trainer

2 215
Q:

What's the difference between the functions rand(), random(), srand() and randomize()?

rand()  returns a random number

random()  returns a random number in a specified range

srand()  initialise a random number generator with a given seed value

randomize()   initializes a random number generator with a random value based o time.

Subject: Programming

657
Q:

How would you use the function memmove()?

#include "mem.h"

#include "alloc.h"

main()

{

int area;

char *dest;

char src[] = "Life is the camera and you are the target"

"so keep smiling always";

area = sizeof (src);

dest = malloc (area);

memmove (dest, src, area);

printf("\n%s", dest);

printf("\n%s",src);

}