PPA Assignment
PPA Assignment
Assignments
Page 1 of 25
Programming Principles and Algorithm
Assignments
Table of Contents
S# Session Page No.
1. Basics of C 3
2. Variables and Data Types 4
3. Variables and Data Types (Lab) 5
4. Operators and Expressions 6
5. Operators and Expressions (Lab) 7
6. Input and Output in C 8
7. Condition 10
8. Condition (Lab) 12
9. Loop 13
10. Loop (Lab) 14
Page 2 of 25
Programming Principles and Algorithm
Assignments
Basics of C
Sr. No. Assignment Question
1
What is programming Language. Explain types of Programming language.
Page 3 of 25
Programming Principles and Algorithm
Assignments
Column A Column B
abc Double
1. int a=4^4
2. int a=23.34
3. a = 10
b = a + a++
4. a=-5
b=-a
Page 4 of 25
Programming Principles and Algorithm
Assignments
2
Write a C program that accepts the salary and age from the user and
displays the
same on the screen as output.
Page 5 of 25
Programming Principles and Algorithm
Assignments
Basic salary : $
12000 DA : 12% of
$150
TA : $120
Others : $450
Page 6 of 25
Programming Principles and Algorithm
Assignments
– (PF + IT)
Page 7 of 25
Programming Principles and Algorithm
Assignments
2
Write a program which will take the input as a floating (real) number.
This number represents the centimeters. Print out the equivalent
number of feet (floating, 1 decimal) and inches (floating, 1 decimal),
with feet and the inches given to an accuracy of one decimal place.
Page 8 of 25
Programming Principles and Algorithm
Assignments
#include <stdio.h>
void main()
{
int breadth;
float length, height; scanf(“%d%f
%6.2f”,breadth,&length,height); printf(“%d %f
%e”,&breadth, length, height);
}
Page 9 of 25
Programming Principles and Algorithm
Assignments
Calculate salary and then print the result under the following
headings. (SalaryName
to be printed to the nearest dollar.)
Basic Salary
5
Write a program that asks for your first name and last name, and then
prints the
names in the format last name, first name
Page 10 of 25
Programming Principles and Algorithm
Assignments
Condition
Sr. No. Assignment Question
1
Write a program that accepts two numbers a and b and checks whether or
not a is divisible by b.
2
Write a program to accept 2 numbers and tell whether the product of
the two numbers is equal to or greater than 1000.
3
Write a program to accept 2 numbers. Calculate the difference between
the two values.
If the difference is equal to any of the values entered, then display the
following message:
If the difference is not equal to any of the values entered, display the
following message:
4
Montek company gives allowances to its employees depending on their
grade as follows:
Grade Allowance
A 300
B 250
Others 100
Calculate the salary at the end of the month. (Accept Salary and Grade
from the user)
5
Write a program to evaluate the Grade of a student for the following
constraints:
Page 11 of 25
Programming Principles and Algorithm
Assignments
If 60 < marks < 75 – grade B If 45 < marks<60 – grade C If 35 < marks<45 - grade D
If marks < 35 – grade E
Page 12 of 25
Programming Principles and Algorithm
Assignments
Condition (Lab)
Sr. No. Assignment Question
1 Declare two variables x and y. Assign values to these variables. Number x should
be printed only if it is less than 2000 or greater than 3000, and number y should
be printed only if it is between 100 and 500.
2 Write a program to show your computer’s capabilities. The user types in a letter of
the alphabet and your program should display the corresponding language or
package available. Some sample input and output are given below:
Input Output
A or a Ada
B or b Basic
C or c Cobol
D or d dBase III
f or F Fortran
p or P Pascal
V or V Visual C++
Using the ‘switch’ statement to choose and display the appropriate message. Use
the default label to display a message if the input does not match any of the
above letters.
Page 13 of 25
Programming Principles and Algorithm
Assignments
Loop
Sr. No. Assignment Question
1 Write a program to print the series 100, 95, 90, 85,.............., 5.
2 Accept two numbers num1 and num2. Find the sum of all odd numbers between
the two numbers entered.
3 Write a program to generate the Fibonacci series. (1,1,2,3,5,8,13,).
4 Write a program to display the following patterns.
*******
******
*****
****
***
**
*
Page 14 of 25
Programming Principles and Algorithm
Assignments
Loop (Lab)
Sr. No. Assignment Question
1 Declare a variable which has the age of the person. Print the user’s name as many
times as his age.
2 Write a program to generate the following pattern:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 67
1 2 3 4 5 678
1 2 3 4 5 6789
Page 15 of 25
Programming Principles and Algorithm
Assignments
Page 16 of 25