Você está na página 1de 12

HCL PROJECT

SUBMITTED BY: SUBMITTED TO:


Manish MR. KAILASH
CSE/09/321 MR. AMIT
(HCL TRAINERS)
INDEX
SNO. TOPIC.
1. FLOW CHART.
2. DESCRIPTION OF PROGRAM.
3. ALGORITHM.
4. SOURCE CODE.
5. OUTPUT SCREEN.
Description of the code
This is a program to find out the number of days between the
two given dates.
In this program I have used six variables with data type integer
and a flag to show on or off state.
Starting from entering the first date and then the second date
and then the use of array is there.
The use of while statement is there whose code is like this:
While (condition)
{
Statements;
}
Then further in the program there is the use of if statements
and if else statements.
Finally the output is observed on the output screen.
Use of getch( ) is there it is used to hold the screen

Header file used


#include <stdio.h>
This statement signals C that we are going to use the
standard I/O packa
ge. The statement is a type of data declaration.[1] Later we
use the
functionprintf from this package

Use of semicolan
C uses a semicolon (; ) to end a statement in much the
same way we use a period to end a sentence. Unlike line-
oriented languages
such as BASIC, an end-o f-line does not end a statement.
Variables and Storage :

C allows us to store values in variables . Each variable is


identified by a
variable name.
In addition, each variable has a variable type. The type tells
C how the
variable is going to be used and w hat kind of numbers (real,
integer) it
can hold. Names start with a letter or underscore ( _ ),
followed by any
number of letters, digits, or underscores.
Most C programmers use all-lowercase variable names.
Some names likeint,
while, for, andfloat have a special meaning to C and are
considered
reserved words . They cannot be used for variable names.

Variable Declarations :

Before you can use a variable in C, it must be defined in


a declaration statement .
A variable declaration serves three purposes:
1. It defines the name of the variable.
2. It defines the type of the variable (integer, real, character,
etc.).
3. It gives the programmer a description of the variable
The keyword int tells C that this variable contains an integer
value.
(Integers are defined below.) The variable name is answer.
The semicolon
( ;) marks the end of the statement, and the comment is
used to define this
variable for the programmer.

Assignment Statements

Variables are given a value through the use of assignment


statements. For example:
answer = (1 + 2) * 4;
is an assignment. The variable answer on the left side of the
equal sign (=)
is assigned the value of the expression (1 + 2) * 4 on the
right side. The
semicolon (;) ends the statement.

printf Function:

The library function printf can be used to print the results.

Special characters

The special characters %d are called the integer conversion


specification .
When printf encounters a %d, it prints the value of the next
expression in
the list following the format string. This is called
the parameter list .
The general form of the printf statement is:
printf(format, expression-1, expression-2, ...);
Algorithm
 Firstly the declaration of variables is done that is
variables are declared as integer type and flag is
initialized as 0.
 Then the first date is entered by the user and then the
second date.
 An array named says is taken of data type integer.
 While loop is applied taking (c! =f| | b! =e | | a! =d).
 If the condition is verified then the loop while execute as
with increment in a i.e. a++.
 Use of if statement i.e., if ((b= =4)| | (b= =6)| | (b= =8)| |
(b= =11)) if this condition is verified then the code will
take the value of f = 30 otherwise another condition will
be applied i.e. if (b= =2)
 If this condition is verified then another condition will
applied i.e. if (d%4==0) then the value of f will be 29 else
it will be 28.
 And if all these conditions are not verified then the value
of f will be 31.
 Then a condition is checked that if (a>f), if this condition
is verified then an increment on b will be there that is b++
and a=1.
 If not then one more condition will be checked that is if
(b= =13), if verified then an increment on c will be c++
and b will be given the value 1. Otherwise an increment
on flag will be there.
 If while condition is not verified then flag will be printed.

#include<stdio.h>
Source code
#include<conio.h>
void main()
{
int a,b,c,d,e,f,flag=0;
const int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
printf("Enter first date");
scanf("%d%d%d",&a,&b,&c);
printf("Enter second date");
scanf("%d%d%d",&d,&e,&f);

while(c!=f||b!=e||a!=d)

{
a++;
if((b==4)||(b==6)||(b==9)||(b==11))
f=30;
else if(b==2)
{
if(d%4==0)
f=29;
else
f=28;
}
else
f=31;
if(a>f)
{
b++;
a=1;
}
if(b==13)
{
c++;
b=1;
}
flag++;
}
printf("%d",flag);
getch();
}

Output screen
Enter first date12
8
1999
Enter second date3
5
1995
2475
start

Read a,b,c,d,e,f,flag

Flag=0

Write “enter first


date”

Read a,b,c

Write”enter second date”

Read d,e,f

Read days [13]

While(c
! = f or
b!= e or
a!= d

a ++
if((b==4)|
if(b==2 F=31
|(b==6)||
(b==9)|| )
(b==11))

F = 30 if(d
%4== F=29
0)

if(a>
f)
F= 28

if(b=
b++; a=1;
=13)

flag
Write “flag”

c++; b=1; Read flag

stop
Flowchart

Você também pode gostar