FOP Practical
FOP Practical
Student must prepare handwritten workbook to solve definition. Each page must contain
the Enrollment number.
Student may use Online GDB editor, Netbeans IDE or SRIMoodle Virtual Lab Programming
to demonstrate solution of the problem definition.
Student should follow the Coding standard attached at end of document.
At time of submission student must submit scan copy of the respective question.
Student must submit the workbook exercise on given deadline.
Nature of submission is hand written for all the problem definition.
Practical work book must have index given.
Programs should be well-documented and must follows the Coding standards.
Workbook will be evaluated based on following given rubric parameters.
o Completeness of Solution
o Code Correctness
o Reusability
o Documentation
o Coding standard
o Demonstration
o Technical viva
Programming
C++ Java C++ Java
Language
1 2 2 1
3 4 4 3
5 6 6 5
7 8 8 7
Practical Number 9 10 10 9
11 12 12 11
13 14 14 13
15 16 16 15
17 18 18 17
Practical mapping with Unit, Course Outcomes, Program Outcomes, Program Educational
Objectives and Skill set:
INDEX
Total Marks
3. Do as directed.
a. In a Sport shop, Akash has bought three items such as Bat, Stump, Badminton Rackets. For that
how many variables are required? List them with data types to solve the problem.
b. Suggest variable names and data type for below mentioned Student information for Uka
Tarsadia University Student Management System.
Student Name Date of Admission
Enrollment Number Semester Fee
HSC Percentage Student City
Passing Year Of HSC Student Gender
4. State whether the following declaration statements are valid or invalid. If it is invalid, give an
appropriate reason and rewrite in correct way.
1. float a, b; 9. int p=5; q=6.4; r=40;
2. int x=50, b=x, c=b; 10. float x=y=z=70.37;
3. FLOAT T=99.3, y; 11. int A=80 q==9;
4. int X=Y=10=Z; 12. int p=54, int q=65;
5. float T= 99999; 13. int a= -88;
6. int a=5, c, b=a+b; 14. char temp1=’X’, char=’Y’;
7. Float Y; 15. char = temp1;
8. float A B C= A+B;
5. Write a statement to print following lines on output screen using single output statement
including punctuation marks:
1. Greetings of the day!!!
2. You’re a diamond, they can’t break you…
3. DON’T WORRY ABOUT FAILURES,
WORRY ABOUT THE CHANCE YOU MISS,
WHEN YOU DON’T EVEN TRY.
4. “FUTURE
depends on
what you do TODAY.”
5. Good\\to\see\you\\\again.
6. Temp=100, Test=200
7. /* Good Morning, Nice Day */ (Also print /* and */).
8. Score 1: 199
Score 2: 165
Score 3: 50
9. 1234 5678 93212
10. printf(“(Good Morning)”);
6. Write a snippet of code for each given problem.
1. Accept your Birth Year and weight and display it.
2. Accept your gender(M/F) and display it.
3. Accept mobile price and discount percentage using single and display it.
7. Write appropriate statement to take input for the followings using single input statement and
also display the entered value with proper message using single output statement.
1. The values for i, j and k which are all integer type.
2. The values for i and j are integer type and value for k is floating-point type.
3. The values for i, j and k are all character type.
4. The values for i is integer type, for j is floating point type and for k is character type.
e.
f.
4. Write a program for the below given algorithm to calculate the cost of colouring where
per square feet cost is 40 Rs. Customer wants to know the cost of the room’s to be
painted which is in squar shape. Customer has measured the length and width in meter.
[1 meter= 3.2804 feet]
Step 1: [Start of the algorithm]
START
Step 2: [Display message]
Print “Give the length of your room in meter:”
Step 3: [Accept length of room]
Input L.
Step 4: [Calculate the area of the room.]
Area=L*L
Step 5: [Covert square meters in to square feet.]
Algorithm:
Step-1 [Starting of algorithm]
Start
Step-2 [To accept age of human]
Input Age
Step-3 [Check whether the age is below 12 or not]
if Age<=12 than go to step - 4
otherwise go to step - 6
Step-4 [Display message “Child”]
Print “Child”
Step-5 [Transfer the control flow]
go to step – 13
Step-6 [Check whether the age is below 18 or not]
if Age<=18 than go to step - 7
otherwise go to step – 9
Step-7 [Display message “Adolescence” ]
Print “Adolescence”
Step-8 [Transfer the control flow]
go to step - 13
Step-9 [Check whether the age is below 59 or not]
if Age<=59 than go to step - 10
otherwise go to step - 12
Step-10 [Display message “Adult” ]
Print “Adult”
Step-11[Transfer the control flow]
go to step – 13
Step-12 [Display message “Senior Adult”]
print “Senior Adult”
step-13 [Ending of the algorithm]
End
Pre-requisite if statement
Objective(s) To use the conditional statement such as if statement and multiple if statements for solving the
problem.
Duration for 2 hours
3. What is the output of this program? 4. What is the output of this program?
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() int main()
{ {
float f1 = 0.5; int p = 10, q = 20, r;
double f2 = 0.5; if (r = p = q || q > 20)
if (f1 == 0.5f) cout<< r;
cout << "equal"; else
else cout<< "No Output\n";
cout << "not equal"; return 0;
return 0; }
}
Pre-requisite if…else, nested if statements
Objective(s) To implement the conditional statement namely if...else and nested if statements for solving the
problem.
Duration for 2 hours
completion
Solution must Hand written solution of each of the above questions and sample calculation with input and
contain output data for questions 4 and 5.
Evaluation: Criteria Rating (1- 4)
Problem 1. Write an algorithm and a Java program for a UTU Teacher for generating grade
Definition labels using following table.
Percentage range Grade Labels
0-50 Below Average
51-60 Average
61-75 Good
76-90 Very Good
91-100 Excellent
Sample Input/Output:
Input:
Enter percentage: 95.5
Output:
Grade: Excellent
2. Write a program according to given below flowchart using switch and if..elseif
statement.
2. Complete the following program code which accepts N positive integer numbers from
user and display minimum number in word among two-digit numbers only otherwise
display appropriate message.
#include <iostream>
using namespace std;
int main()
{
int n, min=0;
cout<<"How many positive integer numbers do you want to input?";
cin>>n;
for(i=1; i<=n; i++)
{
....... .......
}
if (min != 0)
{
cout<<"Minimum Number is:"<<min;
/*write a code to print each digit of minimum number in word
e.g. min=23 o/p: two three
*/
}
else
cout<<"2-digit number is not found.";
return 0;
}
Pre-requisite Loop, Conditional Statement
Algorithm:
Step-1 [ Starting of algorithm]
Start
Step-2 [ Accept the value of N which indicates that user want to process N different integer
numbers]
Input N
Step-3 [To intialize counter 'i' and 'sum' variable with 0]
Let sum=0
Let count=0
Let i=0
Step-4 [To check N integer numbers inputted or not]
if i<N than go to step - 5
otherwise go to step - 12
Step-5 [To accept integer number]
Input No
Step-6 [ To check inputted integer number is more than equal to 100 or not]
if No >= 50 than go to step - 7
otherwise go to step - 10
Step-7 [ To check inputted integer number is less than equal to 200 or not]
if No <= 250 than go to step - 8
otherwise go to step - 10
Step-8 [ To check inputted integer number is divisible by 9 or not]
if No mod 3 == 0 and No mod 5 == 0 than go to step - 9
otherwise go to step - 10
Step-9 [ To add integer number into 'sum' variable]
sum=sum + No
Step-10 [ To increase the ‘count’ variable value by 1]
count=count + 1
Step-11 [ To increase the value of counter variable 'i' by 1]
i=i+1
Step-11 [ To transfer flow control]
go to step - 4
Step-12 [To display average of all integer numbers which are between 100 and 200,
also divisible by 3 and 5 ]
print sum/count
step-13 [Ending of algorithm]
Stop
2. If other than positive number is entered by user, then don’t accept that number and ask
user to enter the valid positive number till the positive number is entered by user in
above practical 1. Also add code for the same in above program. Draw the flowchart for
the same.
Which loop is preferable to add data validation among three different looping
statements? Why? List three differences between event driven loop and counter control
2. Write a user defined function which accept the Programme name and convert it into
TOGGL CASE. Prototype of the function is : void tOGGLcASE(char title[])
Sample Input/Output:
Enter the Programme Name: Bachelor OF Computer APPLICATION
Programme Name is: bACHELOR OF cOMPUTER aPPLICATION
Example
float sumOfSquares = 0;
Counter Example
float Sum = 0;
float sumofsquares = 0;
float sum_of_squares = 0;
float qw = 0;
Comments: Classes
Guidelines
Every class should be preceded with a descriptive comment using the “JavaDoc” notational
convention. The comment should name the class, describe its purpose, and name the author.
Example
/**
* Haiku, prints a haiku.
* @author Suzuki, Susan
*/
public class Haiku {
// ...
Comments: Methods
Guidelines
Every method should be preceded with a descriptive comment using the “JavaDoc”
notational convention. The comment should name the method, describe its purpose,
comment all arguments, the return value, and any exceptions using JavaDoc keywords.
(Omit @return and @exception, if the return value is void or there are no exceptions
thrown.)
Example
/**
* Attempts to print a word. Indicates whether printing was possible.
* @param word to print, must not contain spaces
* @return true if printer is available, false otherwise
* @exception SpacesFoundException if there are any spaces in the word
*/
public boolean printWord(String word) throws SpacesFoundException {
// ...
}
Example
Comments: In-line
Guidelines
In-line comments should be used to explain complicated sections of code, such as loops. Use
the // comment delimiter for in-line comments. Do not comment generally known features
of the java language.
Example
Counter Example
i++; // increments i
// the variable "i" loops from 0 to the length of matrix
for (int i = 0; i < matrix.length; i++) {
// ...
}
Example
Example
Counter Example
Indentation
Guidelines
Indent two spaces when beginning a new block.
Open braces (i.e. “{“) do not start a new line.
Close braces (i.e. “}”) do start a new line, and are indented with the code they close.
Comments line up with the block they comment.
Example
Counter Example
class MeanStandardDeviation
private Vector getNewVector(Vector oldVector) {
Counter Example