Google Analytics

Friday 19 August 2011

FRP SAMPLE QUESTIONS WITH ANSWERS


FRP Sample Questions


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].

6 comments:

  1. These questions seems easy but they aren't. I look forward for more questions like this

    ReplyDelete
  2. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information. 
    python Training institute in Pune
    python Training institute in Chennai
    python Training institute in Bangalore

    ReplyDelete
  3. I was recommended this web site by means of my cousin. I am now not certain whether this post is written through him as nobody else recognise such precise about my difficulty. You're amazing! Thank you!
    Data Science course in rajaji nagar
    Data Science with Python course in chenni
    Data Science course in electronic city
    Data Science course in USA
    Data science course in pune | Data Science Training institute in Pune

    ReplyDelete
  4. Thanks For Sharing The Information Please Keep Updating us Information Shared Is Very Valuable Time Just Went On Reading The Article Python Online Training AWS Online Training Data Science Online Training Data Science Online Training Hadoop Online Training

    ReplyDelete

  5. This post is so interactive and informative.keep update more information...
    Salesforce Training in Chennai
    Salesforce Training in Anna Nagar

    ReplyDelete