Vous êtes sur la page 1sur 6

NAME: RAVI BHARGAV COURSE

CODE: CSE 101

FACULTY MEMBER:SHIVALI CHOPRA REGD.


NO.:11002518

SECTION: B6001 DATE OF


ALLOTMENT-21/1/2011

ROLL NO: RB6001A16 DATE OF


SUBMISSION-7/2/2011

DECLARATION

I hereby declare that assignment is my own work. That I have not copied from
anyone.

Not does any part of this assignment has been done by any other individual
except me.

PART –A

Ques: 1

Write an algorithm that is showing the use of all the arithmetic operators. All the
operators should be implacable to the integer and float data types and should be
display in the sequence of BODMAS method.

ANS:

An algorithm is defined as a finite sequence of instructions defining the solution


of a particular problem, where each instruction is numbered.

The algorithm is used for the calculations, data processing and automated
reasoning.

The algorithm for the arithmetic operators:

Step 1: Input the number a, b, c, d and e

Step 2: if equation contains “()” then solves it if not go to step 3

Step 3: if equation contains “/” then solves it if not go to step 4


Step4: if equation contains “*” then solves it if not go to step 5

Step5: if equation contains “+” then solves it if not go to step 6

Step 6:if equation contains “– “then solves it

Step 7: stop

Ques: 2

What do you mean by a flow chart? What are its uses? Make a flowchart
for the problem described in question number 1.

ANS:

Another name of flowchart is flow diagram.

A flowchart is a pictorial representation of an algorithm. A flowchart uses


different shapes to denote different instructions. These shapes are
connected by directed lines to indicate the sequence in which instructions
are to be executed.

There are many uses of the flow chart in the daily life.

Some of uses are:

1.It use to explaining the step pictorially and in a simple manner.

2. Flow chart are used in designing and documenting complex process.

3. It’s also acts like a roadmap for a programmer.

Ques: 3

Why we called the term “pseudo code” as the described name. Why we
use it in the field of computer science. Write a pseudo code for the traffic
light system.

ANS:

The word pseudo means imitation or false and the word code refers to the
instruction written in a programming language. Pseudo code , therefore is
an imitation of actual computer instructions. These pseudo instructions
are phrases written in English like statements.

It describes the entire logic of the algorithm so that implementation


becomes a rote mechanical task of translating it line by line into source
code. In simple language it is just a false imitation of the c program which
is to be implementing.

The traffic system is to be design for a maximum of 100 vehicles.


Begin

Read : A

A=>100

If (A=>60)

Print”light is green”

else if (60<A>85)

print ”light is yellow”

else (A=>85)

print “light is red”

end if

end

Ques:4

What are the various phases involved during the development of a C


program. Explain with diagram and example.

ANS: The various steps involved during the development of any c program
are the following:

1. Defining the problem

2. Designing the problem

3. Building the program

4. Testing the program


5. Documenting the program

6. Deploying the program and maintenance

Example:

Like if in a daily life, if i am a game programmer and a “EA” company


have order me to design a game.

1. To make a game(Defining the problem)

2. What functions do we want in a game and what accessories do we


want(designing the problem)

3. To make the program for the game(Building the program)

4. Then we test the program of game: that whether it is working or not


or all stages are clear or not(Testing the program)

5. Making the code of the various applications in the


game(Documenting the program)

6. Then going to give the game to the “EA” company and will provide
them with a manual and telling them basic necessities

Also giving the guarantee (deploying the program and maintenance)

Ques:5

Write a program that can calculate the area and perimeter of


geometric objects like circle, triangle, and rectangle etc. (mention at
least 10 such objects). Make sure that both the data type i.e. integer
and float should be use.

ANS:

#include<stdio.h>

#include<conio.h>

void main()

float r,a,b;

clrscr();

printf("enter the value");


scanf("%f",&r);

a=3.14*r*r;

b=2*3.14*r;

printf("the value of the area and the perimeter respectively:%f\n


%f\n",a,b);

getch();

The 10 other objects are

1. Circle

2. Triangle

3. Rectangle

4. Parallogram

5. Square

6. Rhombus

7. Hexagon

8. Pentagon

9. Heptagon

10. Trapezium

Ques:6

Write a program that show all the credentials that you see on your UMS
screen.

Ans:

#include<stdio.h>

#include<conio.h>

void main()

int a;
int b;

clrscr();

printf("enter your ID");

scanf("%10d",&a);

printf("enter your password");

scanf("%5d",&b);

printf("welcome to lovely professional university UMS");

getch();

Vous aimerez peut-être aussi