Library Functions

Q1:
What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    char *i = '55.555';
    int result1 = 10;
    float result2 = 11.111;
    result1 = result1+atoi(i);
    result2 = result2+atof(i);
    printf('%d, %f', result1, result2);
    return 0;
}

A 55, 55.555

B 66, 66.666600

C 65, 66.666000

D 55, 55

ANS:A - 55, 55.555

Function atoi() converts the string to integer.
Function atof() converts the string to float. result1 = result1+atoi(i);
Here result1 = 10 + atoi(55.555);
result1 = 10 + 55;
result1 = 65; result2 = result2+atof(i);
Here result2 = 11.111 + atof(55.555);
result2 = 11.111 + 55.555000;
result2 = 66.666000;
So the output is '65, 66.666000' .



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.