0% found this document useful (0 votes)
26 views4 pages

Assignment 2

Uploaded by

talent.thread
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)
26 views4 pages

Assignment 2

Uploaded by

talent.thread
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
You are on page 1/ 4

ASSIGNMENT -2 (BASICS OF C PROGRAMMING)

Basic instructions:
1. Never copy and paste. Always start from the scratch and
write each line of code by yourself only.
2. Add comments in every program. Do not copy and paste the
comments.
3. Every day complete your assignment.
4. Check every line of your program for semicolon (;). In C
program, the semicolon is a statement terminator. That is,
each individual statement must end with a semicolon.
5. Follow the following outline for your programs.
/* Add your comments here
Author:
Date:
Aim:
Language:
*/
------------------------------------------------------------------------------------
1. Write a C program that does the following task.
 Add comments
 Declare the following variables and check for valid and
invalid variables.
int a;
int 0a;
wrong
int ZeroNumber;
int _first;
int 009;
wrong bcoz no.
int year@22;
wrong bcoz @ is special symbol secial symbol not
allowed in identifier
int sept21;
int YahooGoogle;
{int else;
int int;
int float;
int double;
int char;
int intOne;}
none will work as they are datatypes are reseved
words

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

You might also like