Exercise 5
Exercise 5
{
printf(My User friendly Guide to the C Programming\n);
}
b. read the value of the integer variable first_int from the users input.
main()
{
int first_int;
scanf( %d, &first_int);
}
c. read the value of a float variable first_float from the users input.
main()
{
float first_float;
scanf( %f, &first_float);
}
d. display the value of the float variable first_float.
main()
{
int first_float;
scanf( %f, &first_float);
printf( %f\n, first_float);
}
e. display the value of the integer variable first_int.
main()
{
int first_int;
scanf(%d,&first_int);
printf(%d\n,first_int);
}
6. Describe the following console input/output functions (conio.h):
gets()This function takes the name of the string as an argument and
reads characters from the keyboard until ENTER key is pressed.
ENTER key is not stored as byte instead it is replaces by the null
terminator.
getch()reads a character with echo. Does not wait for carriage return or
ENTER key.
getche()- reads a character without echo. Does not wait for carriage return
or ENTER key.
puts()writes a string to the screen, followed by a newline. It can only
output a string of characters. It cannot output numbers or do
format conversion. It takes up less space and run faster.
putschar( writes a string (character) to the screen.
)clrscr()used to clear the output screen.
Subprogram section: The subprogram section contains all the userdefined functions that are called in the main () function. User-defined
functions are generally placed immediately after the main () function,
although they may appear in any order.
Note: All section, except the main () function section may be absent when
they are not required.
B.
I
What will be the output of the following statements:
printf(Hello!\n);
Hello!
printf(The value of %5d is
The value of 5.00000 is five.
five.,5);
printf(\n\n Do you know the
next number? \n);
printf(\n %5d %6.2f, 6 ,6.5);
printf( Then followed by %d.,
7);
II.
6.5
Then followed by 7.