Exp 1
Exp 1
============
Aim-Introduction to C programming.
----------------------------------
1.1 Write a C program to print the following message using printf:
Welcome to C Programming!
1.2 Write a C program to print your biodata.
Your biodata contain name, regd. no., address, Educational qualifications etc.
1.3 Write a C program that declares an integer, a float, and a character. Assign
values to them and print the variables using printf.
Example:
Integer: 5
Float: 3.14
Character: 'A'
*Hint:* Use format specifiers like %d, %f, and %c.
1.4 Write a C program to print the value of pi (3.14159) with two decimal places
using printf.
*Hint:* Use %.2f to format the float value.
1.5 Write a C program to take a character input from the user and print its ASCII
value.
Example:
Input: 'A'
Output: 65
*Hint:* Use the %d format specifier to print the ASCII value of the character.
1.6 Write a C program to print a table of squares of numbers from 1 to 5 using
printf.
Example:
Number Square
1 1
2 4
3 9
4 16
5 25
1.7 Write a C program to print the following text using escape sequences:
"Hello, World!"
This is a new line.
Let's tab -> here.
*Hint:* Use \n for a new line, \" for double quotes, and \t for tab.
1.8 Write a C program to print an integer in both decimal and hexadecimal format.
Example:
Input: 255
Output: Decimal: 255, Hexadecimal: FF
*Hint:* Use %d for decimal and %X for hexadecimal.
1.9 Write a C program to print a floating-point number in different field widths
using printf.
Example:
Input: 3.14159
Output:
Default width: 3.141590
Width 10: 3.141590
Width 10 with 2 decimal places: 3.14
*Hint:* Use %.nf for precision and %width.nf for field width and precision.
1.10 Write a C program to add, subtract, multiply, and divide two numbers.
1.11 Write a C program to calculate area and perimeter of a rectangle.