You are on page 1of 1

CSE 1201 – Introduction to Programming with C

Lab 1 – C Fundamentals

Objectives

By the end of this lab sessions students should be able to:

• Install a C Programming Environment


• Write, save, run simple C programs
• Use the printf() function in C
• Write simple C programs that uses variables to store various types of data
• Write simple C programs that uses basic mathematical operators
• Perform basic input using scanf() function

Tasks

1. Write, save, run a C program that prints “hello world” to the screen
2. Modify the above program so that it prints additional text output to the screen
3. Write a C program that finds and prints the sum of two numbers. These numbers are hard-
coded in the program
4. Modify the program in 3 above to find the product and average of these two numbers.
5. Write a program in C that collects TWO values from the keyboard and repeat problem 4 above.
Use a single scanf() for all data entry
6. Re-write the program in 5 above using functions as appropriate. Call these function from main()

Homework

1. Write a program in C that collects two numeric values from the user via the keyboard and finds
the sum of the two numbers if the first number entered is greater than the second OR the
product of the two numbers if the second is greater than the first. These two numbers are to be
stored in variables called first_num and second_num. This program must use functions.

You might also like