08.01.2023 Views

Learn to Program with C_ Learn to Program using the Popular C Programming Language ( PDFDrive )

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1 ■ Elementary Programming Concepts

11. Name five data types commonly used in programming and give examples of

constants of each type.

12. What are the different classes into which characters can be divided? Give examples

in each class.

13. What is the purpose of comments in a program?

14. Write a program to print Welcome to C on the screen.

15. Write a program to print the following:

There is a tide in the affairs of men

Which, taken at the flood, leads on to fortune

16. Write a program to print any four lines of your favorite song or poem.

17. Same as exercise 16, but print a blank line after each line.

18. If a is 29 and b is 5, what is printed by each of the following statements?

printf("The product of %d and %d is %d\n", a, b, a * b);

printf("%d + %d = %d\n", a, b, a + b);

printf("%d - %d = %d\n", a, b, a - b);

printf("%d x %d = %d\n", a, b, a * b);

19. If a is 29 and b is 14, what is printed by the following statements?

printf("%d + \n", a);

printf("%d\n", b);

printf("--\n");

printf("%d\n", a + b);

20. If rate = 15, what is printed by

(a) printf("rate\n")?

(b) printf("%d\n", rate)?

21

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!