0% found this document useful (0 votes)
7 views16 pages

ANAS Lab Task (PF Theory)

Uploaded by

anasfarooqui505
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views16 pages

ANAS Lab Task (PF Theory)

Uploaded by

anasfarooqui505
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Programming Fundamentals

Assignment 1
Name: M. Anas Farooqui
Roll no:103

1.Problem: Take temperature in Fahrenheit as


input and convert it into Centigrade and
Kelvin.

Output:

2.Problem : Prompt the user for the diameter


of a circle in centimeters and find out its area
in square meters.

Output:
Programming Fundamentals
Assignment 1

3.Input a real number from the user and round


it.

Output:

4.Problem : Input two characters char1 and


char2 and interchange their values i.e. swap.
Programming Fundamentals
Assignment 1
Output:

5.Problem : If a five-digit number is input


through the keyboard, write a program to
calculate the sum of its digits. (Hint: Use the
remainder operator i.e. %

Output:

6.Problem : C++ Program to take a value from


the user as input any character and check
whether it is the alphabet, digit or special
character. Using if-else.
Output:
Programming Fundamentals
Assignment 1

7.Problem: C++ Program to take a value from


the user as input the month number and
print number of days in that month. Using if-
else.
Programming Fundamentals
Assignment 1

Output:

8. Problem : Write a program to swap the


values of two number if values of both
variables are not the same using if-else
statement

Output:

9. Problem : Using the if-else, C++ Program to take a value


from the user as input electricity unit charges and calculate
Programming Fundamentals
Assignment 1
total electricity bill according to the given condition: For the
first 50 units Rs. 0.50/unit.............For the next 100 units Rs.
0.75/unit.....For the next 100 units Rs.
1.20/unit ...............For unit above 250 Rs. 1.50/unit.........An
additional surcharge of 20% is added to
the bill.

Output:

10. Problem # 10: Input the Salary of an employee and


make the following deductions before printingit out:

If salary is less than or equal to 10,000 then no deduction are


done.

If salary is more than 10,000 and less than 25,000 then


deduct Rs. 1,000.
Programming Fundamentals
Assignment 1
If salary is equal to or more than 25,000 then deduct 5 % of
the salary.

Code:

11. Problem : Find out whether the input number is even or


odd and if the number is even, display its square and if the
number is odd display the cube.
Programming Fundamentals
Assignment 1

Output:

12. Problem: Ask the user for his/her age and display the
message according to the following criteria:
If age is less than 16, display "You can't drive."
age is less than 18, display "You can't vote."
age is less than 25, display "You can't rent a car."
age is 25 or over, display "You can do anything that's legal.".
Programming Fundamentals
Assignment 1

Output:

13. Problem # 13: Write a program in C++ to display n


terms of natural numbers and their sum.
Sample Output:
Input a number of terms: 7
The natural numbers upto 7th terms are:
1234567
The sum of the natural numbers is: 28
Programming Fundamentals
Assignment 1

Output:

14. Problem: Write a program in C++ to


calculate the sum of the series (1*1) + (2*2)
+ (3*3) +(4*4) + (5*5) + ... + (n*n).
Programming Fundamentals
Assignment 1

Output:

15. Problem : Write a program in C++ to calculate the series


(1)+(1+2)+(1+2+3)+(1+2+3+4) + ... + (1+2+3+4+...+n).

Output:
Programming Fundamentals
Assignment 1

16. Problem : Write a C++ program to print all numbers


between a and b (a and b inclusive) using for loops.
Programming Fundamentals
Assignment 1
Output:

17. Problem: Write a program in C++ to find the factorial


of a number.

Output:

18. Problem : Write a C++ program to calculate the area of


Circle, Square, and Rectangle using switch statement.
Programming Fundamentals
Assignment 1

Output:
Programming Fundamentals
Assignment 1
19. Problem : Write a C++ program to input month number
and print number of days in that month using switch case
structure.

Output:
Programming Fundamentals
Assignment 1
20. Problem : Write a C++ program to input day number
between 1 and 7 and print day of week using switch case
structure.

Output:

You might also like