Home » Talent Transformation At WIPRO, Tech Corner

FRP Sample Questions

4 September 2009 10 Comments Posted By:LG

FRP Sample Questions

1. main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf(“Hello”);
else
printf(“Welcome”);
}

Answer:
Welcome
Explanation:
For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Note:
Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .

2.
#define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf(“%d”,i);
}

Answer:
64
Explanation:
The macro call square(4) will substituted by 4*4 so the expression becomes i = 64/4*4 . Since / and * has equal priority the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64.

3.
main()
{
int i;
printf(“%d”,scanf(“%d”,&i)); // value 10 is given as input here
}
Answer:
1
Explanation:
Scanf returns number of items successfully read and not 10. Here 10 is given as input which should have been scanned successfully. So number of items read is 1.

4.
main(int argc, char **argv)
{
printf(“enter the character”);
getchar();
sum(argv[1],argv[2]);
}
sum(num1,num2)
int num1,num2;
{
return num1+num2;
}

Answer:
Compiler error.
Explanation:
argv[1] & argv[2] are strings. They are passed to the function sum without converting it to integer values.atoi() is used to convert a string to integer.
5.
main()
{
char s[ ]=”man”;
int i;
for(i=0;s[ i ];i++)
printf(“\n%c%c%c%c”,s[ i ],*(s+i),*(i+s),i[s]);
}

Answer:
mmmm
aaaa
nnnn
Explanation:
s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].

Once you get through the exams,please do help others as well, you can post questions and answers with explanations and any suggestions over here as comments, or if you really want to share something and help please contact us.We will surely provide platform for your suggestions.

 

Related posts:

  1. Managing Input and Output Operations
  2. Operators & Expressions
  3. Unix Sample Questions
  4. Pointers
  5. TALENT TRANSFORMATION AT WIPRO-FRP

10 Comments »

  • Namit said:

    good …………..i really appericiate ur attempt…

  • Namit said:

    Thanks…

  • Allhad said:

    thanks ! for ur pricelesss help

  • shefali said:

    hy
    plz tell me,which book i prefer to clear my FRP test.i am doing my practice by check your c skills.Is this enough to clear the test.
    reply me through my mail id.

  • yashika said:

    this is all fuck..its not lik tht at all..they ll take the PET marks in consideration…pls dont leave any information without being known to tht….

  • Lloyd (author) said:

    @yashika…I appologize if my info reached to you in a wrong way, but i never intended…..
    But 1 thing i would like to mention as its my responsibilty to the reader-”Dont take everythg you come across, one should be wise enough to choose, these info over here will be of help if you change your perspective towards the articles”

  • Hari said:

    Hi myself Hari Krishnan working in Wipro.. i have joined wipro three months back.. i hav attended my FRP, the questions given above are the questions found in the book given by Wipro which is of no use for FRP, to clear it u should really work hard in the training. Wipro has a big database of 10,000 questions in the FRP’S conducted , So its very lucky that if u get one in the FRP., Prepare urself well in DATA STRUCTURES., which draws u a gud mark in the FRP., PET programs are also of the same kind.. To be very precise (“IF U ARE LUCKY ENUF, U WILL WIN THE CONTEST”)

  • LG (author) said:

    @ all who come across these articles..
    The questions and other articles given over here are the authors’ experiences…its not a must that d same will be asking for exams..these are just samples…just to show the reader how thgs are happing….

  • hari said:

    C Programming :: Declarations and Initializations
    @ : Home > C Programming > Declarations and Initializations > General Questions

    1. Is the following statement a declaration or definition?
    extern int i;
    A.
    Declaration
    B.
    Definition
    C.
    Function D.
    Error
    Answer & Explanation
    Answer: Option A
    Explanation:
    Declaring is the way a programmer tells the compiler to expect a particular type, be it a variable, class/struct/union type, a function type (prototype) or a particular object instance. (ie. extern int i)
    Declaration never reserves any space for the variable or instance in the program’s memory; it simply a “hint” to the compiler that a use of the variable or instance is expected in the program. This hinting is technically called “forward reference”.
    View Answer Workspace Report Discuss in Forum

    ________________________________________
    2. Identify which of the following are declarations
    1 : extern int x;
    2 : float square ( float x ) { … }
    3 : double pow(double, double);

    A.
    1 B.
    2
    C.
    1 and 3
    D.
    3
    Answer & Explanation
    Answer: Option C
    Explanation:
    extern int x; – is an external variable declaration.

    double pow(double, double); – is a function prototype declaration.

    Therefore, 1 and 3 are declarations. 2 is definition.
    View Answer Workspace Report Discuss in Forum

    ________________________________________
    3. In the following program where is the variable a getting defined and where it is getting declared?
    #include
    int main()
    {
    extern int a;
    printf(“%d\n”, a);
    return 0;
    }
    int a=20;
    A.
    extern int a is declaration, int a = 20 is the definition

    B.
    int a = 20 is declaration, extern int a is the definition
    C.
    int a = 20 is definition, a is not defined
    D.
    a is declared, a is not defined
    Answer & Explanation
    Answer: Option A
    Explanation:
    - During declaration we tell the datatype of the Variable.
    - During definition the value is initialized.
    View Answer Workspace Report Discuss in Forum

    ________________________________________
    4. When we mention the prototype of a function are we defining the function or declaring it?
    A.
    Defining B.
    Declaring

    C.
    Prototyping D.
    Calling
    Answer & Explanation
    Answer: Option B
    Explanation:
    A function prototype in C or C++ is a declaration of a function that omits the function body but does specify the function’s name, argument types and return type.
    While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface.
    View Answer Workspace Report Discuss in Forum

    ________________________________________
    5. What’s the difference between following declarations?
    1 : extern int fun();
    2 : int fun();

    A.
    extern int fun(); is in another file
    B.
    No difference, except extern int fun(); is in another file

    C.
    int fun(); is overrided with extern int fun();
    D.
    None of these
    Answer & Explanation
    Answer: Option B
    Explanation:
    extern int fun(); declaration in C is to indicate the existence of a global function and it is defined externally to the current module or in another file.
    int fun(); declaration in C is to indicate the existence of a function inside the current module or in the same file

    6. What are the types of linkages?
    A.
    Internal and External B.
    External, Internal and None

    C.
    External and None D.
    Internal
    Answer & Explanation
    Answer: Option B
    Explanation:
    External Linkage-> means global, non-static variables and functions.
    Internal Linkage-> means static variables and functions with file scope.
    None Linkage-> means Local variables.
    View Answer Workspace Report Discuss in Forum

    ________________________________________
    7. Which of the following special symbol allowed in a variable?
    A.
    * (asterisk) B.
    | (pipeline)
    C.
    - (hyphen) D.
    _ (underscore)

    Answer & Explanation
    Answer: Option D
    Explanation:
    Variable names in C are made up of letters (upper and lower case) and digits. The underscore character (“_”) is also permitted. Names must not begin with a digit.
    Examples of valid (but not very descriptive) C variable names:
    => foo
    => Bar
    => BAZ
    => foo_bar
    => _foo42
    => _
    => QuUx
    View Answer Workspace Report Discuss in Forum

    ________________________________________
    8. By default a real number is treated as a
    A.
    float B.
    double

    C.
    long double D.
    far double
    Answer & Explanation
    Answer: Option B
    Explanation:
    In computing, ‘real number’ often refers to non-complex floating-point numbers. It include both rational numbers, such as 42 and 3/4, and irrational numbers such as pi = 3.14159265…
    When the accuracy of the floating point number is insufficient, we can use thedouble to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float.
    To extend the precision further we can use long double which occupies 10 bytes of memory space.
    View Answer Workspace Report Discuss in Forum

  • renma said:

    good prac

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>