0% found this document useful (0 votes)
6 views3 pages

C Programming Basics: Variables to Functions

Uploaded by

heonho2205
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

C Programming Basics: Variables to Functions

Uploaded by

heonho2205
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

Declare and Print Variables

Objective: Practice declaring variables and printing their values.

 Write a program to declare and initialize variables of the following types:


o int, float, char, and double.
 Print their values using printf().

2. Constants in C

Objective: Understand the use of constants.

 Define a constant using #define and const.


 Write a program that uses these constants to calculate the area of a circle ( Area = π *
r^2).

3. Input and Output Formatting

Objective: Practice formatted input and output.

 Write a program that:


1. Takes the user’s name and age as input.
2. Prints them in this format:

4. Arithmetic Operations

Objective: Use arithmetic operators.

 Write a program that takes two integers as input and calculates their:
o Sum
o Difference
o Product
o Quotient

5. Using stdio.h Functions

Objective: Explore functions from the stdio.h library.

 Use getchar() to take a single character as input and print it using putchar().

6. Data Type Sizes

Objective: Understand the size of different data types.


 Write a program to print the size of int, float, char, double, and long using the
sizeof() operator.

7. Escape Sequences

Objective: Learn how escape sequences work.

 Write a program that demonstrates the use of \n, \t, \\, and \" in strings.

8. Temperature Conversion

Objective: Work with formulas and formatted output.

 Write a program to convert a temperature from Celsius to Fahrenheit and vice versa:

9. String Input and Output

Objective: Work with strings in C.

 Write a program that:


1. Takes a string as input using scanf() and gets().
2. Prints the string using printf().

10. Random Number Generation

Objective: Use libraries in C.

 Use the stdlib.h library to generate and print 5 random numbers.


 Bonus: Seed the random number generator with srand(time(NULL)) from time.h.

11. BMI Calculator

Objective: Combine variables, constants, and I/O formatting.

 Write a program to calculate Body Mass Index (BMI):

 Take weight and height as input and print the BMI up to 2 decimal places.

12. Working with Arrays


Objective: Practice using arrays and loops.

 Write a program that:


1. Reads 5 integers into an array.
2. Calculates and prints their sum and average.

13. Prime Number Check

Objective: Work with conditional statements.

 Write a program to check whether a number entered by the user is a prime number.

14. Library Functions for Math

Objective: Use the math.h library.

 Write a program that calculates:


o Square root (sqrt())
o Power (pow())
o Sine and Cosine (sin(), cos())
 Take inputs for each operation.

15. Formatted Table

Objective: Practice complex output formatting.

 Write a program to display a table of conversions from kilometers to miles

You might also like