Flowchart
A flowchart is a pictorial representation of a program.
Types:-
Eg.1. Draw a flowchart to print your name.
Eg.2. Draw a flowchart to print your address.
Memory Variable:- To initialize the value or in other words to give input.
Eg.3. Draw a flowchart to input your name and date of birth(dob). Display all.
Eg.4. Draw a flowchart to input name, fathers name, date of birth(dob) and qualification. Display all.
Eg.5. Draw a flowchart to input roll number, student name, marks of three subject(eng, hin, math). Display all.
Eg.6. Draw a flowchart to input book number, book name, author name, prize, number of copies . Display all.
Processing Box:-
Eg.7. Draw a flowchart to input roll number, name, marks of three subject. Calculate total and average. Display all.
Eg.8. Draw a flowchart to input book number, book name, author name, price, number of copies. Display all with their total.
Eg.9. Draw a flowchart to input principle amount, rate of interest, time. Calculate S.I and Display all.
Eg.10. Draw a flowchart to input the item number, item name, quantity, price .Calculate the total price where discount is 5%. Calculate its net total. Display all.
Eg.11. Draw a flowchart to input employee number, name, salary. Calculate HRA, PF, Total salary and next salary where HRA is 5% of salary and PF is 2% of salary. Display all.
Eg.12. Draw a flowchart to input temperature in Fahrenheit. Calculate the Celsius temperature. Display all.
Eg.13. Draw a flowchart to input the length and breadth of a rectangle and find the area of it. Display all.
Decision Box:-
Operators:-
E.g.14. Draw a flowchart to input roll number, name, marks of three subject. Find out the average if marks is above 50 then ‘pass’ else ‘fail’. Display all.
Eg.15. Draw a flowchart to find the distance between the points a, b, c. Display all.
Eg.16. Draw a flowchart to accept two numbers from user N1, N2 and find out the greatest among them.
Eg.17. Draw a flowchart to find out profit and loss on the basic of cost price or selling price depending on price. We purchased where profit. We purchased where profit is P = SP – CP and loss is L = CP – SP.
Eg.18. Draw flowchart to input item name, quantity in hand, transaction, quantity and type of transaction if type is = “Issue”
Tot = QH – TQ
Tot = QH + TQ
Multiple Decision Box:-
Eg.19. Draw a flowchart to input name, subject, net price of the book and discount is given depending upon the subject. Display all.
Subject Discount
Computer 20% of price
Science 25% of price
English 20% of price
Other 0
Eg.20. Draw a flowchart to input the value of a, b, c and find out d = b2 – 4ac.
Condition Display
if d=0 Real and equal
if d=0 Real and unequal
if d=0 Imaginary
Eg.21. Draw a flowchart to input name, salary of a person, HRA and PF depends on salary .Display all.
Subject HRA PF
>10000 8% 5%
>8000 5% 3%
>6500 4% 2%
>6000 2% O
Eg.22. Draw a flowchart to input name, year of service, basic pay. Increment is calculated according to the year of service. Display all.
Year Of Service Increment
>10 50% of basic pay
>8 25% of basic pay
>6 20% of basic pay
Otherwise 0
LOOPING:-
Eg.23. Draw a flowchart to display your name 10 times.
Eg.24. Draw a flowchart to display 100, 99, 98, 97, 96,……
Eg.25. Draw a flowchart to display 2, 4, 6, 8, ………, 20.
Eg.26. Draw a flowchart to display 1, 3, 5, 7, 9, 11, 13, 15.
Eg.27. Draw a flowchart to display 1, 8, 27, 64, 125, …………, 1000.
Eg.28. Draw a flowchart to display 1, 10, 100, 1000, ……….., 100000.
Eg.29. Draw a flowchart to display 100, 99, 97, 94, 90, 85, 79, …….........., 45.
Eg.30. Draw a flowchart to display 50, 100, 200, 350, ………, 6000.
Eg.31. Draw a flowchart to display 3, 7, 10, 13, 16, 19, …………., 31.
Eg.32. Draw a flowchart to display 0, 1, 1, 2, 3, 5, 8, ……… , 200.
Eg.33. Draw a flowchart to display 5, 10, 30, 120, …………., 1000.
Factorial:-
Eg.34. Draw a flowchart to display sum of factorial 8.
-------------------------------------------------------------------------------
C
History:
C language was designed and developed by Dennis Richie at AT & T’s Bell laboratories situated at USA in the year 1972. It was created as a success of B-language. A language earlier development by Ken Thomson at Bell laboratories for P.D.P – 7 computer Dennis Ritchie developed from already existing languages such as algo, Bept, B that used the Unix Os.
C is often consider to be a middle level language since it possesses features of high level language i.e. it combines the best element high level language with control and flexibility of an assembly language. It is also known as a language.
C is case sensitive language.
Structure of C:
Solutions:
Eg.C.1. Write a program to input name, roll number.
# include
# include
void main ( )
{
int r;
char n[20];
clrscr ( );
printf (“Enter the roll number:”);
scanf (“%d”, &r );
printf (“Enter the name:”);
scanf (“%s”, &n );
printf (“%d”, r);
printf (“%s”, n);
getch ( );
}
Eg.C.2. Write a program to input the name, roll number, marks of three subject. Calculate total and average.
# include
# include
void main ( )
{
int r, m1, m2, m3, tot, avg;
char n[20];
clrscr ( );
printf (“Enter the roll number:”);
scanf (“%d”, &r);
printf (“Enter the name:”);
scanf (“%d”, &n);
printf (“Enter the marks1:”);
scanf (“%d”, &m1);
printf (“Enter the marks2”);
scanf (“%d”, &m2);
printf (“Enter the marks3”);
scanf (“%d”, &m3);
{
tot = m1 + m2 + m3;
avg = tot / 3;
}
printf (“%d”, r);
printf (“%s”, n);
printf (“%d”, m1);
printf (“%d”, m2);
printf (“%d”, m3);
printf (“%d”, tot);
printf (“%d”, avg);
getch ( );
}
Eg.C.3. Write a program to input book number, name, author name, price, number of copies. Calculate total.
# include
# include
void main ( )
{
int bno, p, noc, tot;
char bnam[20], anam[20];
clrscr ( );
printf (“Enter the book number:”);
scanf (“%d”, &bno);
printf (“Enter the book name:”);
scanf (“%s”, &bnam);
printf (“Enter the author name:”);
scanf (“%s”, &anam);
printf (“Enter the price:”);
scanf (“%d”, &p);
printf (“Enter the number of copies:”);
scanf (“%d”, &noc);
tot = noc *p;
printf (“%d”, bno);
printf (“%s”, bnam);
printf (“%s”, anam);
printf (“%d”, p);
printf (“%d”, noc);
printf (“%d”, tot);
getch ( );
}
Eg.C.4. Write a program to find area of a circle.
# include
# include
void main ( )
{
float a, r;
clrscr ( );
printf (“Enter the value of r:”);
scanf (“%f”, &r);
a = 3.14 * r * r;
printf (“\n Area: %f ”, a);
getch ( );
}
If – Statement:- The if-statement is a control statement that test a particular condition. Whenever, the evaluated condition comes out to be true, then that action or the set of actions are carried out. Otherwise the set of actions are ignored and statement II is executed.
Syntax:
if (expression)
statement (s); ……………….I
else
statement (s); ………………II
Nested if /else – statement:- In a program to specify several conditions and take one out of them called a nested if/else – statement.
Syntax:
if (condition I)
statement;
else if (condition II)
statement;
else if (condition III)
statement;
:
:
:
else
statement;
The conditions are evaluated from top to bottom and whenever the evaluated condition is true, the corresponding statements are executed and the rest of the statements are skipped. The arrangement of statements in this manner is called “ if/else, if-ladder ”.
Eg.C.5. Write a program to input gender and print good morning Sir and M’am.
# include
# include
# include
void main ( )
{
char a[20];
clrscr ( );
printf (“Enter your gender male/female:”);
scanf (“%s”, &a);
if (strcmp(a, “male”)==0)
{
Printf (“Good Morning Sir”);
}
else
printf (“Good Morning M’am”, );
getch ( );
}