SlideShare a Scribd company logo
Manual # 2
Topic:
Programming Fundamental Assignment
Subject:
Programming Fundamental
For BS(CS), BS(EE), DAE(Computer Science), BSC(14 Years)
Author:
Sunawar Khan Ahsan MS(Computer Vision)
Mehwish Shabbir
Program 1: Write a program that prints a text of 4 lines consisting of characters, integer values
and floating point value using cout statement.
Program 2: Write a program that inputs name, age and address from the user and display it on
the screen.
Program 3: Write a program that inputs base height from the user and calculates area of a
triangle by using the formula Area = ½ * Base *Height.
Program 4: Write a program that inputs temperature from the using Celsius and converts it
into Fahrenheit using the formula F = 9/5 * C + 32.
Program 5: Write a program that inputs 4 numbers and calculates the sum, average, and product
of all the numbers
Program 6: write a program that converts a person’s height from inches to centimeters using
the formula 2.54 *height.
Program 7: Write a program that inputs radius from the user and calculates area and
circumference of circle using formula Area = πr2.
Program 8: Write a program that inputs two numbers and exchange their values the
program should display the values before and after exchange.
Program 9: Write a program that inputs radius from the user and calculates area and
circumference of sphere using formula Area = 4πr2 Circumference = 4/3πr3.
Program 10: Write a program that inputs a three digit number from the user and displays it
in reverse order. For example if the user enter 123, it displays 321.
Program 11: Write a program that inputs miles from the user and converts miles into kilometers. One mile is equal
to 1.609km.
are given. It inputs values of a, b and c. Formula for the area of triangle is Area = √( − )( − 0( −
Program 12: Write a program that finds area of triangle when three sides a, b and c of the triangle
) Where s = (a + b + c)/2.
Program 13: Write a program that inputs temperature in Fahrenheit and convert it into Celsius.
Program 14: Write a program that inputs a number and finds whether it is even or odd using if-
else structure.
Program 15: Write a program that inputs salary and grade. It adds 50% bonus if grade is
greater than 15. It adds 25% bonus if grade is 15 or less and then displays the salary.
Program 16: Write a program that inputs salary. If salary is 20000 or more, it deducts 7% of salary.
If salary is 10000 or more or more but less than 20000, it deducts 1000. If salary is less than 10000,
it deducts nothing and then displays net salary.
Program 17: Write a program that inputs from user and determines whether it is positive,
negative or zero.
Program 18: Write a program that inputs test score of a student and displays his grade on
the following scale
Test Score Grade
>=90 A
80-90 B
70-79 C
60-69 D
Below 50 F
Program 19: Write a program that inputs radius. It calculates area of circle if user enters1 as
choice. It calculates circumference if the user enters 2 as choice. It displays error message in case
of any other choice.
Program 20: Write a program that inputs temperature and displays a message according to
following table:
Temperature Message
Greater than 35 Hot Day
Between 25 and 25 Pleasant Day
Less than 25 Cool Day
Program 21: Write a program that inputs three numbers and displays the smallest number by
using nested if condition.
Program 22: Write a program that inputs three numbers and displays the maximum number
by using logical operators.
Program 23: Write a program that inputs a character and displays whether it is vowel or
consonant using switch statement.
Program 24: Write a program that inputs two numbers and one arithmetic operator. It
applies arithmetic operation on two numbers on the basis of operator entered by user using
switch statement.
Program 25: Write a program that displays counting from 1 to 10 using while loop.
Program 26: Write a program that displays first five numbers and their sum using while loop.
Program 27: Write a program that displays first five numbers with their squares using while
loop.
Program 28: Write a program that inputs two numbers and exchange their values the program
should display the values of variables before and after exchange.
Program 29: Write a program that inputs a number from the user and displays a table of
that number using while loop.
Program 30: Write a program that inputs a number from the user and displays the factorial of
that number using while loop.
Program 31: Write a program that displays the sum of following series using while
loop. 1 + 1 / 2 + 1 / 4 + 1 / 6 + . . . . . . . + 1 / 100.
Program 32: Write a program that displays sum of following series using do-while loop.
Program 33: Write a program that inputs starting and ending point from the user and displays
all odd numbers in the given range using do-while loop.
Program 34: Write a program that inputs two numbers from the user and displays the result of
first number raise to the power of second number using do-while loop.
Program 35: Write a program that produces the following output:
0 1
1 2
2 4
3 8
4 16
5 32
6 64
Program 36: Write a program that inputs a number from the user and displays the factorial of
that number using do-while loop.
Program 37: Write a program that displays alphabets from A to Z using for loop.
Program 38: Write a program that displays product of all odd numbers from 1 to 10 using for
loop.
Program 39: Write a program that inputs a number from the user and displays the factorial of
that number using for loop.
Program 40: Write a program that inputs table number and length of table and then displays
the table using for loop.
Program 41: Write a program that inputs a positive integer number from the keyboard and
displays it’s in reverse number. For example, the reverse of 345 is 543.
Program 42: Write a program that calculates and displays the sum of following series using for
loop.
Program 43: Write a program that finds sum of the squares of integers from 1 to n. Where n is
appositive value entered by the user (i.e. sum = 12 + 22 + 32 + ….. + n2)
Program 44: Write a program that displays the following shape using while loop.
Program 45: Write a program that calculates and displays sum of the following series using for
loop: 1! + 2! + 3! + 4! + 5! Where “!” represents factorial of the number.
Program 46: Write a program that calculates and displays the sum of the following series using
for loop: 1 + 2x +3x2 + 4x3 + 5x4
Program 47: Write a program that calculates and displays the sum of the following series using
for loop: 1/2 + 2/3 + 3/4 +. . . . . . + 99/100
Program 48: Write a program that inputs five values and displays their squares and cubes
using loop.
Program 49: Write a program that inputs two numbers and displays greatest common divisor of
the numbers.
Program 50: Write a program that displays the following shape using nested loops. The outer
loop should be for loop and inner loop should be while loop.
*******
******
*****
****
***
**
*
Program 51: Write a program that displays the following block using nested for loop.
*****
*****
*****
*****
*****
Program 52: Write a program that displays the following shape using nested for loop.
*******
* *
* *
* *
*******
Program 53: Write a program that displays the following shape using nested do-while loop.
4 4 4 4
3 3 3
2 2
1
Program 54: Write a program that displays the following shape using nested for loop.
*
**
***
****
*****
Program 55: Write a program that displays the following shape using nested for loop.
0 01 012
0123
01234
012345
Program 56: Write a program that displays the following shape using nested for loop.
*****
****
***
**
*
Program 57: Write a program that displays the following shape using nested for loop.
*
**
***
****
*****
Program 58: Write a program that displays the following shape using nested for loop.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Program 59: Write a program that displays the following shape using nested for loop.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Program 60: Write a program that inputs an integer and displays whether it is a prime number or
not.
Program 61: Write a program that inputs a number from the user and displays all prime numbers
which are less than the input number using any loop.
Program 62: Write a program that inputs two numbers in main function and passes these numbers
to a function. The function displays the maximum number.
Program 63: Write a program that inputs a number in main function and passes the number to a
function. The function displays the factorial of that number.
Program 64: Write a program that inputs a number in main function and passes the number to a
function. The function displays the table of that number.
Program 65: Write a program that inputs two numbers in main function and passes these numbers
to a function. The function displays first number raised to the power of second number.
Program 66: Write a program that prompts the user to enter a number and reverse it. Write a
function Reverse () to reverse the number. For example, if the user enters 2765, the function
should reverse it so that it becomes 5672. The function should accept the number as a parameter
and return the reverse number.
Program 67: Write a function GCD that has two input parameters and returns the greatest common
divisor of two numbers passed to it. Write a program that inputs two numbers and calls GCD to
compute greatest common divisor of the number.
Program 68: Write a program that inputs two integers and then passes them to four function add,
subtract multiply and divide one by one.
Program 69: Write a function is prime that has an input parameter num and returns a value of 1 if
it is prime otherwise it returns the value of 0.
Program 70: Write a program that prompts user for Cartesian coordinates of two points x1, y1 and
x2, y2 and displays distance between them. Write a function Distance () with four parameters to
compare the distance. The function uses the following formula to compute the distance and returns
the result to call function:
Distance = sqrt ((a2 – a1)2 + (b2 – b1)2)
-----------------------------------------------------------------------------------------------------------
S u n a w a r K h a n A h s a n
For solution contact me at 03334892200
Mail: sk_ahsan38@yahoo.com
-----------------------------------------------------------------------------------------------------------
ALL CREDIT GOES TO MEHWISH SHABBIR
I LOVE HER

More Related Content

DOC
Programming qns
DOCX
c++ Question
DOCX
COMP 122 Entire Course NEW
DOC
Md university cmis 102 week 4 hands on lab new
DOC
Md university cmis 102 week 4 hands on lab new
PDF
Cp manual final
PDF
Lab no 3 haris
PDF
Tbp dca1 -2021-2
Programming qns
c++ Question
COMP 122 Entire Course NEW
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
Cp manual final
Lab no 3 haris
Tbp dca1 -2021-2

What's hot (16)

PDF
csharp repitition structures
DOCX
Lab no 2 haris
DOCX
Programming questions
PPT
test(3)arithmetic in c
PPT
Tcs nqt 2019 p 2
PPT
Tcs nqt 2019 p 1
DOCX
Oop lab assignment 01
PDF
Final project report
PDF
selection structures
PDF
AER494 Course: Project No.1
PDF
Cpph exam a_2019_s1
PDF
escape sequences and substitution markers
PPT
PPS
C programming session 04
DOC
Implementation of halstead
DOC
Comp 328 final guide (devry)
csharp repitition structures
Lab no 2 haris
Programming questions
test(3)arithmetic in c
Tcs nqt 2019 p 2
Tcs nqt 2019 p 1
Oop lab assignment 01
Final project report
selection structures
AER494 Course: Project No.1
Cpph exam a_2019_s1
escape sequences and substitution markers
C programming session 04
Implementation of halstead
Comp 328 final guide (devry)
Ad

Similar to Programming Fundamental handouts (20)

DOC
Course Breakup Plan- C
DOCX
List of programs to practice for ICSE
DOCX
Conditional structure problems
DOCX
Best c programs
PDF
Simple c-programs
PPTX
loops in Python with examples and different problems
DOCX
Important C program of Balagurusamy Book
DOC
Practical java
DOCX
Java Practice Set
DOCX
Chapter 8Exercise1.Design an application that accept.docx
DOCX
Pseudocode.docx angel
PDF
Assignment 1 for 2nd sem
DOC
Report in Java programming and SQL
PDF
Sample Program file class 11.pdf
PDF
PDF
PDF
best notes in c language
PDF
Sasin nisar
Course Breakup Plan- C
List of programs to practice for ICSE
Conditional structure problems
Best c programs
Simple c-programs
loops in Python with examples and different problems
Important C program of Balagurusamy Book
Practical java
Java Practice Set
Chapter 8Exercise1.Design an application that accept.docx
Pseudocode.docx angel
Assignment 1 for 2nd sem
Report in Java programming and SQL
Sample Program file class 11.pdf
best notes in c language
Sasin nisar
Ad

More from International Islamic University (20)

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PPTX
Cell Structure & Organelles in detailed.
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Pre independence Education in Inndia.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Lesson notes of climatology university.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Institutional Correction lecture only . . .
Cell Structure & Organelles in detailed.
Microbial disease of the cardiovascular and lymphatic systems
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Basic Mud Logging Guide for educational purpose
O7-L3 Supply Chain Operations - ICLT Program
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
STATICS OF THE RIGID BODIES Hibbelers.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Pre independence Education in Inndia.pdf
Pharma ospi slides which help in ospi learning
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Anesthesia in Laparoscopic Surgery in India
Lesson notes of climatology university.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf

Programming Fundamental handouts

  • 1. Manual # 2 Topic: Programming Fundamental Assignment Subject: Programming Fundamental For BS(CS), BS(EE), DAE(Computer Science), BSC(14 Years) Author: Sunawar Khan Ahsan MS(Computer Vision) Mehwish Shabbir
  • 2. Program 1: Write a program that prints a text of 4 lines consisting of characters, integer values and floating point value using cout statement. Program 2: Write a program that inputs name, age and address from the user and display it on the screen. Program 3: Write a program that inputs base height from the user and calculates area of a triangle by using the formula Area = ½ * Base *Height. Program 4: Write a program that inputs temperature from the using Celsius and converts it into Fahrenheit using the formula F = 9/5 * C + 32. Program 5: Write a program that inputs 4 numbers and calculates the sum, average, and product of all the numbers Program 6: write a program that converts a person’s height from inches to centimeters using the formula 2.54 *height. Program 7: Write a program that inputs radius from the user and calculates area and circumference of circle using formula Area = πr2. Program 8: Write a program that inputs two numbers and exchange their values the program should display the values before and after exchange. Program 9: Write a program that inputs radius from the user and calculates area and circumference of sphere using formula Area = 4πr2 Circumference = 4/3πr3. Program 10: Write a program that inputs a three digit number from the user and displays it in reverse order. For example if the user enter 123, it displays 321. Program 11: Write a program that inputs miles from the user and converts miles into kilometers. One mile is equal to 1.609km. are given. It inputs values of a, b and c. Formula for the area of triangle is Area = √( − )( − 0( − Program 12: Write a program that finds area of triangle when three sides a, b and c of the triangle ) Where s = (a + b + c)/2. Program 13: Write a program that inputs temperature in Fahrenheit and convert it into Celsius. Program 14: Write a program that inputs a number and finds whether it is even or odd using if- else structure. Program 15: Write a program that inputs salary and grade. It adds 50% bonus if grade is greater than 15. It adds 25% bonus if grade is 15 or less and then displays the salary. Program 16: Write a program that inputs salary. If salary is 20000 or more, it deducts 7% of salary. If salary is 10000 or more or more but less than 20000, it deducts 1000. If salary is less than 10000,
  • 3. it deducts nothing and then displays net salary. Program 17: Write a program that inputs from user and determines whether it is positive, negative or zero. Program 18: Write a program that inputs test score of a student and displays his grade on the following scale Test Score Grade >=90 A 80-90 B 70-79 C 60-69 D Below 50 F Program 19: Write a program that inputs radius. It calculates area of circle if user enters1 as choice. It calculates circumference if the user enters 2 as choice. It displays error message in case of any other choice. Program 20: Write a program that inputs temperature and displays a message according to following table: Temperature Message Greater than 35 Hot Day Between 25 and 25 Pleasant Day Less than 25 Cool Day Program 21: Write a program that inputs three numbers and displays the smallest number by using nested if condition. Program 22: Write a program that inputs three numbers and displays the maximum number by using logical operators. Program 23: Write a program that inputs a character and displays whether it is vowel or consonant using switch statement. Program 24: Write a program that inputs two numbers and one arithmetic operator. It applies arithmetic operation on two numbers on the basis of operator entered by user using switch statement. Program 25: Write a program that displays counting from 1 to 10 using while loop. Program 26: Write a program that displays first five numbers and their sum using while loop. Program 27: Write a program that displays first five numbers with their squares using while loop. Program 28: Write a program that inputs two numbers and exchange their values the program should display the values of variables before and after exchange.
  • 4. Program 29: Write a program that inputs a number from the user and displays a table of that number using while loop. Program 30: Write a program that inputs a number from the user and displays the factorial of that number using while loop. Program 31: Write a program that displays the sum of following series using while loop. 1 + 1 / 2 + 1 / 4 + 1 / 6 + . . . . . . . + 1 / 100. Program 32: Write a program that displays sum of following series using do-while loop. Program 33: Write a program that inputs starting and ending point from the user and displays all odd numbers in the given range using do-while loop. Program 34: Write a program that inputs two numbers from the user and displays the result of first number raise to the power of second number using do-while loop. Program 35: Write a program that produces the following output: 0 1 1 2 2 4 3 8 4 16 5 32 6 64 Program 36: Write a program that inputs a number from the user and displays the factorial of that number using do-while loop. Program 37: Write a program that displays alphabets from A to Z using for loop. Program 38: Write a program that displays product of all odd numbers from 1 to 10 using for loop. Program 39: Write a program that inputs a number from the user and displays the factorial of that number using for loop. Program 40: Write a program that inputs table number and length of table and then displays the table using for loop. Program 41: Write a program that inputs a positive integer number from the keyboard and displays it’s in reverse number. For example, the reverse of 345 is 543. Program 42: Write a program that calculates and displays the sum of following series using for loop.
  • 5. Program 43: Write a program that finds sum of the squares of integers from 1 to n. Where n is appositive value entered by the user (i.e. sum = 12 + 22 + 32 + ….. + n2) Program 44: Write a program that displays the following shape using while loop. Program 45: Write a program that calculates and displays sum of the following series using for loop: 1! + 2! + 3! + 4! + 5! Where “!” represents factorial of the number. Program 46: Write a program that calculates and displays the sum of the following series using for loop: 1 + 2x +3x2 + 4x3 + 5x4 Program 47: Write a program that calculates and displays the sum of the following series using for loop: 1/2 + 2/3 + 3/4 +. . . . . . + 99/100 Program 48: Write a program that inputs five values and displays their squares and cubes using loop. Program 49: Write a program that inputs two numbers and displays greatest common divisor of the numbers. Program 50: Write a program that displays the following shape using nested loops. The outer loop should be for loop and inner loop should be while loop. ******* ****** ***** **** *** ** * Program 51: Write a program that displays the following block using nested for loop. ***** ***** ***** ***** ***** Program 52: Write a program that displays the following shape using nested for loop. ******* * * * * * *
  • 6. ******* Program 53: Write a program that displays the following shape using nested do-while loop. 4 4 4 4 3 3 3 2 2 1 Program 54: Write a program that displays the following shape using nested for loop. * ** *** **** ***** Program 55: Write a program that displays the following shape using nested for loop. 0 01 012 0123 01234 012345 Program 56: Write a program that displays the following shape using nested for loop. ***** **** *** ** * Program 57: Write a program that displays the following shape using nested for loop. * ** *** **** ***** Program 58: Write a program that displays the following shape using nested for loop. 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
  • 7. Program 59: Write a program that displays the following shape using nested for loop. 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 Program 60: Write a program that inputs an integer and displays whether it is a prime number or not. Program 61: Write a program that inputs a number from the user and displays all prime numbers which are less than the input number using any loop. Program 62: Write a program that inputs two numbers in main function and passes these numbers to a function. The function displays the maximum number. Program 63: Write a program that inputs a number in main function and passes the number to a function. The function displays the factorial of that number. Program 64: Write a program that inputs a number in main function and passes the number to a function. The function displays the table of that number. Program 65: Write a program that inputs two numbers in main function and passes these numbers to a function. The function displays first number raised to the power of second number.
  • 8. Program 66: Write a program that prompts the user to enter a number and reverse it. Write a function Reverse () to reverse the number. For example, if the user enters 2765, the function should reverse it so that it becomes 5672. The function should accept the number as a parameter and return the reverse number. Program 67: Write a function GCD that has two input parameters and returns the greatest common divisor of two numbers passed to it. Write a program that inputs two numbers and calls GCD to compute greatest common divisor of the number. Program 68: Write a program that inputs two integers and then passes them to four function add, subtract multiply and divide one by one. Program 69: Write a function is prime that has an input parameter num and returns a value of 1 if it is prime otherwise it returns the value of 0. Program 70: Write a program that prompts user for Cartesian coordinates of two points x1, y1 and x2, y2 and displays distance between them. Write a function Distance () with four parameters to compare the distance. The function uses the following formula to compute the distance and returns the result to call function: Distance = sqrt ((a2 – a1)2 + (b2 – b1)2)
  • 9. ----------------------------------------------------------------------------------------------------------- S u n a w a r K h a n A h s a n For solution contact me at 03334892200 Mail: sk_ahsan38@yahoo.com ----------------------------------------------------------------------------------------------------------- ALL CREDIT GOES TO MEHWISH SHABBIR I LOVE HER