The document outlines an assignment focused on the basics of C programming. It includes tasks such as declaring and validating variables, initializing variables with values, and printing those values in various formats. Each task requires the addition of comments to the code for clarity.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
Assignment 2
The document outlines an assignment focused on the basics of C programming. It includes tasks such as declaring and validating variables, initializing variables with values, and printing those values in various formats. Each task requires the addition of comments to the code for clarity.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
ASSIGNMENT -2 (BASICS OF C PROGRAMMING)
Basic instruction: Check every line of your program for
semicolon (;). 1. Write a C program that does the following task. Add comments Declare following variables and check for valid and invalid variables. int a; int 0a; int ZeroNumber; int _first; int 009; int year@22; int sept21; int YahooGoogle; int else; int int; int float; int double; int char; int intOne;
2. Write a C program that does the following task:
Add comments Declare one variable[Give it some name] Initialize the variable with a value, say 10. Print this value on the screen. Output should be “Value of the variable is 10 “ [Do not print double quotes] 3. Write a C program that does the following task: Add comments Declare two variables[Give them some name] Initialize the variables with values 10 and 20 respectively. Print these values on the screen separately in different lines. For example: o Value of the first variable is 10 o Value of the second variable is 20 4. Write a C program that does the following task: Add comments Declare three variables[Give them some name] Initialize the variables with values 5, 6 and 7 respectively. Print these values on the screen all in one line. For example: Value of first variable is 5 and value of second variable is 6 and value of third variable is 7 5. Write a C program that does the following task: Add comments Declare four variables[Give them some name] Initialize the variables with Integer constants 15, 16, 17 and 18 respectively. Print these values on the screen, each in different line. For example: First variable holds an integer constant 15 Second variable holds an integer constant 16 Third variable holds an integer constant 17 Fouth variable holds an integer constant 18