Representing float constants and valid integer constants


Question1)a) In the following C program, what are the functions used?

# include
# include
i n t main()
{
Char  s1[15] = "Hello World";
i f (strchr(s1, ’e’))
printf("The character e occurs in the string.\n");
else printf("The character e does not occur in the string.\n");
return 0;
}

b) Which of the following are valid integer constants? Give reasons for your answer.

i) 123456L

ii) 12.5

c) How will you represent the following as a float constants?

i) 29979925 X 104

ii) 661 X 10-29

d) Which of the following are valid C identifiers? Give reasons for your answer.

i) 2ABC

ii) _ABC

iii) Double

Question2)a) What are the errors in the following C program?

1 # include
2 int main()
3 {
4 float distance,speed,time;
5 printf("Enter Distance travelled in Km.\n"/* get distance travelled * /);
6 scanf("%f",&Distance);
7 printf("Enter time taken in hours.\n");
8 scanf("%f",time);
9 Speed = distance/time;
10 printf("The speed is %f Km/hr.",speed);
11 return 0;
12 }

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Representing float constants and valid integer constants
Reference No:- TGS02609

Expected delivery within 24 Hours