SlideShare a Scribd company logo
Manual # 1
Topic:
Use of Formula`s
Input & Output
Subject:
C & C++
Classes:
2nd
Year & 3rd
Year
Author:
Sunawar Khan Ahsan
MS(Computer Vision)
Author2:
Mehwish Shabbir
---------------------------------------------------------------------------------
Q#1:Write a program, which will display your name.
---------------------------------------------------------------------------------
Q # 2: Execute the following formula`s in C++:
Use of Addition, Subtraction, Multiplication & Division
Addition: cout<<4+2<<"n";
Subtraction: cout<<2-6<<”n”;
Multiplication: cout<<3*8<<”n”;
Division: cout<<6/3<<”n”;
For Formula below, you have to include the header file: math.h (#include<math.h>)
Absolute: cout<<abs(-8)<<”n” ;means that it will give modulus of value given i.e. +ive
value
Exponent: cout<<exp(6)<<”n”;
Power: cout<<pow(2,9)<<"n"; means that 2 raise to power 9 i.e. 2^9.
Square Root: cout<<sqrt(16)<<”n”;
Logarithm & Trigonometric Functions:
Natural Algorithum: cout<<log(3)<<”n”; Gives the natural logarithm of 3.
Sine: cout<<sin(45)<<”n”; Gives the Sine value of 45 degrees in radians.
Cosine: cout<<cos(45)<<”n”; Gives the cosine value of 45 degrees in radians.
Tangent: cout<<sin(45)<<”n”; Gives the Tangent value of 45 degrees in radians.
Inverse of Sine: cout<<asin(30)<<”n”;Gives the inverse sine of 30 degrees in radians.
Inverse of Cosine: cout<<acos(30)<<”n”;Gives the inverse cosine of 30 degrees in
radians.
Inverse of Tangent: cout<<atan(30)<<”n”;Gives the inverse tangent of 30 degrees in
radians.
Hyperbolic Sine: cout<<sinh(60)<<”n”; Gives the hyperbolic sine of 60 degrees
in radians.
Hyperbolic Cosine: cout<<cosh(60)<<”n”; Gives the hyperbolic cosine of 60 degrees
in radians.
Hyperbolic Tangent: cout<<tanh(60)<<”n”; Gives the hyperbolic tangent of 60 degrees
in radians.
------------------------------------------------------------------------------------------------------------
1. Declarationof Variable of Data Type (Integer)
(a). Assigning a Fixed Value to Variable
#include <iostream.h>
int main()
{
int length;
length = 7;
cout<<"The Length is: ";
cout<<length;
cout<<"nn";
return 0;
}
(b). Assign the Value to Variable through Keyboard
Remember to take value from keyboard, we use cin with operator >>.
#include <iostream.h>
int main()
{
int length;
cin>>length;
cout<<"The Length is: ";
cout<<length;
cout<<"nn";
return 0;
}
2. Calculate the Area of the Box
#include <iostream.h>
int main()
{
int length;
int width;
length=7;
width=5;
cout<<"The area is: ";
cout<<length*width;
cout<<"nn";
return 0;
}
// The above program can also be written as:
#include <iostream.h>
int main()
{
int length, width, area; //you can declare the variable in one line.
length=7;
width=5;
area = length * width; //you can store the result of multiplication in another
//variable
cout<<"The area is: ";
cout<<area;
cout<<"nn";
return 0;
}
// Program should take the value of length and width from User
#include <iostream.h>
int main()
{
int length, width, area; //you can declare the variable in one line.
cin>>length;
cin>>width;
area = length * width;
cout<<"The area is: ";
cout<<area;
cout<<"nn";
return 0;
}
// You can take the value from User in one line as Well.
#include <iostream.h>
int main()
{
int length, width, area; //you can declare the variable in one line.
cin>>length>>width;
area = length * width;
cout<<"The area is: ";
cout<<area;
cout<<"nn";
return 0;
}
// Now, from here on you should write your program in such a way, that it will give
the proper information.
#include <iostream.h>
int main()
{
int length, width, area; //you can declare the variable in one line.
cout<<"Enter the Length: ";
cin>>length;
cout<<"Enter the Width: ";
cin>>width;
area = length * width;
cout<<"The area is: ";
cout<<area;
cout<<"nn";
return 0;
}
------------------------------------------------------------------------------------------------------------
Q1: Write a program which will calculate the Volume of the Box. The program should be
able to take values of length, width and height of the box from the user and then display
the result.
------------------------------------------------------------------------------------------------------------
DeclarationofVariable of Data Type (Float)
What is the difference of float data type from integer data type??
#include <iostream.h>
int main()
{
int a, b, c;
a=10;
b=3;
c=a/b;
cout<<"Answer is: ";
cout<<c;
cout<<"nn";
return 0;
}
// The output of this program is 3, but actually 10/3 = 3.33333, but whenever fraction
comes the int variable always takes the lower value like 10/6=1.66667 but the int variable
will not convert it to 2 it will take the lower value i.e. 1 and excludes the fraction.
So, for that the variable can be declared with float.
#include <iostream.h>
int main()
{
float a, b, c;
a=10;
b=3;
c=a/b;
cout<<"Answer is: ";
cout<<c;
cout<<"nn";
return 0;
}
//Answer is 3.3333, the float variable will show the result upto five decimals places.
------------------------------------------------------------------------------------------------------------
Q2: Write a program which will convert the feet into meters. The program should be able
to take the feet value from the user and then converts it into meter.
Forumla is: meters = feet / 3.28
------------------------------------------------------------------------------------------------------------
Q3: Write a program which will calculate the value a from the following formulae:
a = p ( 1 + k)^r, where k = 10% of p.
Enter the value of p and r from the user.
------------------------------------------------------------------------------------------------------ -----
Casting: (Leave it: We`ill Discuss it Later)
#include <iostream.h>
int main()
{
int a, b, c;
a=10;
b=3;
c=a/b;
cout<<"Answer is: ";
cout<<(float) c;
cout<<"n";
cout<<"Answer is: ";
cout<<(float) a/b;
cout<<"nn";
return 0;
}
------------------------------------------------------------------------------------------------------------
Q4: Write a program for the calculation of the roots of Quardatic Equation. The program
should be designed in such a way that user should be able to enter the values of a, b, & c.
And the formula to calculate the roots of Quadratic Equation.
------------------------------------------------------------------------------------------------------------
Q5:If a five digit number enter is input through keyboard. Write a program to calculate
the sum of its digits.
------------------------------------------------------------------------------------------------------------
Q6:If a five digit number enter is input through keyboard. Write a program to find its
reverse.
------------------------------------------------------------------------------------------------------------
Q7:If a four digit number enters through the keyboard. Write a program to obtain sum of
the first and last digit of that number.
------------------------------------------------------------------------------------------------------------
Q8:in a town percentage of man is 52. The percentage of total literacy is 48. If total
percentage of literate men is 35 of the total population to find the total number of
illiterate men and women if the population of the town is 80,000.
------------------------------------------------------------------------------------------------------------
Q9:if the total selling price of 15 items and total profit earned on item is input through
keyboards. Write a program to find the cost price of one item.
------------------------------------------------------------------------------------------------------------
Q10: One large chemical company pays its salesperson on a commission basis. The
company pays salesman $200 per week plus 9 percent of his gross sale of that week.
For example, a salesperson sales $5000 worth of chemicals in a week, so company
pays him $200 + 9% of $5000 = $650.
Write a program for the company which will take the value from the user of total
worth in dollars sailed by the salesperson in one week and calculate his total earning of
that week.
------------------------------------------------------------------------------------------------------------
Q11: A company pays Rs: 10,000 per month to its employee. If he worked extra hours
then the company paid Rs 35 for each extra hour.
Write a program which will take the total number of extra hours of a month from the
user and then calculate the total earning of an employee of that month.
Q12:Write a program that generates the following output:
10
20
19
Use an integer constant for the 10, an arithmetic assignment operator to generate 20, and
a decrement operator to generate 19
------------------------------------------------------------------------------------------------------------
Q13: Write a program to get current year and birth year of a person and display current
age.
Q14:Write a program to convert 2.5 miles into kilometers and print the result on the
screen.
Hint: 1 mile= 1.609 Kilometer
-----------------------------------------------------------------------------------------------------------
Q15:Write a program to interchange the values of two variable using
-----------------------------------------------------------------------------------------------------------
Q16: Write a program to separate the integral and fractional parts of given real number
and print the result on the screen.
-----------------------------------------------------------------------------------------------------------
Q17:Write a program that input a character and display its ASCII code.
-----------------------------------------------------------------------------------------------------------
Q18: Write a program that input ASCII code between (0-255) and display corresponding
character against given value.
-----------------------------------------------------------------------------------------------------------
Q19: Write a program to calculate simple interest. It input principle amount, rate of
interest, and the number of years and display the simple interest.
Hint: i= (p*r*t)/100
------------------------------------------------------------------------------------------------------------
Q20:Write a program that input dividend and divisor it then calculate and display
quotient and remainder.
-----------------------------------------------------------------------------------------------------------
Q21:Write a program that input the distance travelled and the speed of vehicle. It
calculates time required to reach destination and display it.
-----------------------------------------------------------------------------------------------------------
Q22:The distance between two cities (K.M.) is input through keyboard. Write a program
to convert and print this distance in meters, feet and centimeters.
-----------------------------------------------------------------------------------------------------------
Q23:Write a program that input time in seconds and convert it into hh-mm-ss format.
-----------------------------------------------------------------------------------------------------------
Q24: Write a program that inputs three digit number from the user and display following
Output:
Enter Three Digit Number 456
Number Enter by the User Is 456
Number in Reverse Order Is 654
Number Display in Separate Line
4
5
6
-----------------------------------------------------------------------------------------------------------
Q25: Write a program that will prompt the user to enter number of hours it computes and
display the number of weeks, days.
-----------------------------------------------------------------------------------------------------------
Q26: Write a program that prompt age in years and display it in months, days and weeks.
-----------------------------------------------------------------------------------------------------------
Q27: Write a program that prompt marks obtained by a student in five subjects. It then
calculates and then displays the total marks and percentage.
-----------------------------------------------------------------------------------------------------------
Q28:Write a program that input basic salary and calculate 35% dearness allowance, 33.3
house rent and then display the gross salary.
-----------------------------------------------------------------------------------------------------------
Q29:Write a program that input five digit numbers and calculate its sum, average and
product.
-----------------------------------------------------------------------------------------------------------
Q30:Write a program that input two times in hh-mm-ss format, add both time and then
displays total time.
-----------------------------------------------------------------------------------------------------------
Q31:Write a program that input the X, Y co-ordinates for two points and compute the
distance between two points.
Hint: √( 𝒙𝟐 − 𝒙𝟏) 𝟐 + (𝒚𝟐 − 𝒚𝟏)𝟐
-----------------------------------------------------------------------------------------------------------
Q32:Write a program that find out the area of triangle when three sides a,b and c of the
triangle are given.
Hint: √ 𝒔( 𝒔 − 𝒂)( 𝒔 − 𝒃)(𝒔 − 𝒄) where c=a+b+c/2
-----------------------------------------------------------------------------------------------------------
Q33:Write a program that input temperature from the user in Fahrenheit and convert it
into Celsius using formula c=5/9(f-32).
-----------------------------------------------------------------------------------------------------------
Q34:Write a program that input temperature from the user in Celsius and convert it into
Fahrenheit using formula f=9/5(c+32).
-----------------------------------------------------------------------------------------------------------
Q35:Write a program that input total number of student in a class and fee per student it
displays total fee collection from class.
-----------------------------------------------------------------------------------------------------------
Q36:A car can travel 5.3 miles in 1 liter. Write a program that input petrol in liter and
display total distance cover by car.
-----------------------------------------------------------------------------------------------------------
Q37:Write a program to calculate volume (V) of a cube using formula
V=length*width*height.
-----------------------------------------------------------------------------------------------------------
Q38:Write a program that input a number and compute its square and cube.
-----------------------------------------------------------------------------------------------------------
Q39:Write a program that input total pages of a book, number of pages a person read in
one day and number of days a person has read the book. It displays number of pages that
have been read and number of pages remaining.
-----------------------------------------------------------------------------------------------------------
Q40:Write a program that input radius of sphere from the user calculate its volume and
area using formula 𝐴 = 4𝜋𝑟2
and 𝐶 = 4/3𝜋𝑟3
-----------------------------------------------------------------------------------------------------------
Q41: Write a program that displays following statement
The character ‘x’
The name S.K.Ahsan
The number 786
-----------------------------------------------------------------------------------------------------------
Q 42: K.E. 1/2m.v2
-----------------------------------------------------------------------------------------------------------
Q 43: S=vit+1/2at2
-----------------------------------------------------------------------------------------------------------
Q 44: vf=vi+at
-----------------------------------------------------------------------------------------------------------
Q 45: K.E. 1/2m.v2
-----------------------------------------------------------------------------------------------------------
Q 46: a=vf-vi/t
-----------------------------------------------------------------------------------------------------------
Q 48: v=d/t , d=vt
-----------------------------------------------------------------------------------------------------------
Q 49: A cashier has currency notes of denominations 10, 50,100. If the amount to be
withdrawn is input through the keyboard. Find the total number of currency notes of each
denominations the cashier will have give to the withdrawer.
-----------------------------------------------------------------------------------------------------------
Q50:Write a program to calculate the Units of demand will be demanded if the price is
Rs. 18.00? The formula p = 90(5)-q/10 applies to the demand of a product, where “q” is
the number of units and “p” is the price of one unit.
-----------------------------------------------------------------------------------------------------------
Q51:Write a program to calculate the values of l& m. If the expression lx3+ mx2 + 4
leaves the remainder of -3 and 12 when divided by (x - 1) & (x + 2) respectively.
-----------------------------------------------------------------------------------------------------------
Q52:Write a program that print the double of a number of a number that is entered by a
user. For example if user enter 702 than its calculated double number is 1404.
-----------------------------------------------------------------------------------------------------------
Q53:Write a program which shows the output as follow:
What's your name? Sunawar Khan Ahsan
Hello Sunawar Khan Ahsan.
What is your favorite team? The Isotopes
I like The Isotopes too!
-----------------------------------------------------------------------------------------------------------
Q54:Write a program to find the Length of AD& Area of ABC Of the isosceles , the
base BC = 28 cm, and AB = AC = 50 cm, If AD| BC.
-----------------------------------------------------------------------------------------------------------
Q56: Write a program that separate a string into letters/alphabets, such as input string is
Hello, and separated string is:[H][e][l][l][o][!]
-----------------------------------------------------------------------------------------------------------
Q57: Write a program to prove the Right Distributive Law Of the Production by using
dynamic input.
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
Q58:Write a program that convert the entered choice into vice versa into hexadecimal
number, octal & integer. For example if user enter 18 then this number is converted into
hexa or octal number system.
-----------------------------------------------------------------------------------------------------------
Q60:Write a program that swap the entered number without using third variable.
-----------------------------------------------------------------------------------------------------------
Q61: Write a program which accepts amount as integer and display total number of
Notes of Rs. 500, 100, 50, 20, 10, 5 and 1.For example, when user enter a number, 575,
the results would be like this...
500: 1
100: 0
50: 1
20: 1
10: 0
5: 1
1: 0
-----------------------------------------------------------------------------------------------------------
Q62: Write a program which accepts a character and display its next character.
-----------------------------------------------------------------------------------------------------------
Q63: What is the Output of following:
int result = 4 + 5 * 6 + 2;
cout<<result;
int a = 5 + 7 % 2;
cout<<a;
-----------------------------------------------------------------------------------------------------------
Q64: Write a program which accepts days as integer and display total number of years,
months and days in it.
-----------------------------------------------------------------------------------------------------------
Q65:What is the output of following:
-----------------------------------------------------------------------------------------------------------
int x = 10,y;
y = x++;
cout<<y;
int x = 10,y;
y = x++;
cout<<x;
int x = 10;
x++;
cout<<x;
int x = 10,y;
y = ++x;
cout<<y;
int x = 10;
cout<<++x;
int x = 10;
cout<<x++;
Q66:What is the output of the following?
main(){
int count=10;
cout<<"count="<<count<<endl;
cout<<"count="<<count++<<endl;
cout<<"count="<<count<<endl;
cout<<"count="<<++count<<endl;
return 0;
}
main(){
int count=10;
cout<<"count="<<count<<endl;
cout<<"count="<<count--<<endl;
cout<<"count="<<count<<endl;
cout<<"count="<<--count<<endl;
return 0;
}
int main(){
int ans=27;
ans+=10;
cout<<ans<<",";
ans-=7;
cout<<ans<<",";
ans*=2;
cout<<ans<<",";
ans/=3;
cout<<ans<<",";
ans%=3;
return 0;
}
int main(){
int i=2, j=3, k,i;
float a,b;
k=i/j*j;
i=j/j*i;
a=i/j*j;
b=j/i*i;
return 0;
}
Q67:What is the output of following program?
int x = 10;
cout<<x<<x++;
int x = 10;
cout<<++x<<x++<<x;
int x = 10;
cout<<x++<<x<<++x;
int x = 10,y;
y = x + x++;
cout<<y;
int x = 10,y;
y = ++x + x++ + x;
cout<<y;
int x = 10,y;
y = x++ + x + ++x;
cout<<y;
-----------------------------------------------------------------------------------------------------------
Q68: Write a program that takes length as input in feet and inches. The program should
then convert the lengths in centimeters and display it on screen. Assume that the given
lengths in feet and inches are integers.
/********************************************************
Purpose :This program converts measurement in feet and inches into centimeters.
@Author :Sunawar Khan Ahsan
********************************************************/
#include <iostream.h> //Header file
const double CENTIMETERS_PER_INCH = 2.54; //Named constants
const int INCHES_PER_FOOT = 12; //Named constants
int main ()
{
int feet, inches;
int totalInches;
double centimeter;
cout<< "Enter two integers, one for feet and one for inches: ";
cin>> feet>> inches;
cout<< endl;
cout<< "The numbers you entered are " << feet<< " for feet and " << inches<< "
for inches. " << endl;
totalInches = INCHES_PER_FOOT * feet + inches;
cout<< "The total number of inches = " << totalInches<< endl;
centimeter = CENTIMETERS_PER_INCH * totalInches;
cout<< "The number of centimeters = " << centimeter<< endl;
return 0;
}
-----------------------------------------------------------------------------------------------------------
Summary:
 A function named main () is always the first one executed when a program is
executed.
 Expression is combination of Operator and Operand e.g. sum=a+b
 Output is handled by printf and input is handled by scanf object in C.
 Output is handled by cout and input is handled by cin object in C++.
 The variable is no longer a variable but a constant.
 A function body is delimited by {}.
 A function name must be followed by parenthesis otherwise compiler read it as
variable.
 The three primary constants and variable types in c are integer, float and character
 A variable name can be of maximum 31 characters.
 Don’t use keyword as variable.
 A C++ compiler produces code that can be directly executed by the computer.
 A header contains information used by the program.
 <iostream>,<stdio> is the header the supports I/O. The statement includes the
<iostream>, <stdio> header in a program. C++ & C
 A variable is a named memory location. The contents of a variable can be
changed during the execution of a program.
 A variable is a named memory location. The contents of a variable can be
changed during the execution of a program.
 The keyword is for. In C++, all keywords are in lowercase.
 A C++ identifier can contain letters, digits, and the underscore.
 C++ is case sensitive.
 Type parentheses ’( )’ and braces ‘{ }’ in pairs
 Use parentheses for clarification in arithmetic expressions
 Don’t forget semicolon at the end of each statement.
 Analyze the problem properly, and then start coding (first think and then write).
-----------------------------------------------------------------------------------------------------------
S una w a r K ha n Ahs a n
For solution contact me at 03334892200
Mail: sk_ahsan38@yahoo.com
-----------------------------------------------------------------------------------------------------------

More Related Content

What's hot

Oracle ERP Personalization for control master items list
Oracle ERP Personalization for control master items listOracle ERP Personalization for control master items list
Oracle ERP Personalization for control master items listAhmed Elshayeb
 
Modul mengamankan jaringan dhcp server menggunakan arp reply only menggunakan...
Modul mengamankan jaringan dhcp server menggunakan arp reply only menggunakan...Modul mengamankan jaringan dhcp server menggunakan arp reply only menggunakan...
Modul mengamankan jaringan dhcp server menggunakan arp reply only menggunakan...Een Pahlefi
 
Spring MVC - Web Forms
Spring MVC  - Web FormsSpring MVC  - Web Forms
Spring MVC - Web FormsIlio Catallo
 
linux_Commads
linux_Commadslinux_Commads
linux_Commadstastedone
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013Sergey Petrunya
 
Spring MVC - Wiring the different layers
Spring MVC -  Wiring the different layersSpring MVC -  Wiring the different layers
Spring MVC - Wiring the different layersIlio Catallo
 
Spring MVC - The Basics
Spring MVC -  The BasicsSpring MVC -  The Basics
Spring MVC - The BasicsIlio Catallo
 
01c. Starting A Router
01c.  Starting A  Router01c.  Starting A  Router
01c. Starting A RouterNghiep Lam
 
12c Database TEMPORAL VALIDITY & FLASHBACK ARCHIVE Testing
12c Database TEMPORAL VALIDITY & FLASHBACK ARCHIVE Testing12c Database TEMPORAL VALIDITY & FLASHBACK ARCHIVE Testing
12c Database TEMPORAL VALIDITY & FLASHBACK ARCHIVE TestingMonowar Mukul
 
Linux networking commands short
Linux networking commands shortLinux networking commands short
Linux networking commands shortSayed Ahmed
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatFranck Pachot
 

What's hot (13)

Oracle ERP Personalization for control master items list
Oracle ERP Personalization for control master items listOracle ERP Personalization for control master items list
Oracle ERP Personalization for control master items list
 
Modul mengamankan jaringan dhcp server menggunakan arp reply only menggunakan...
Modul mengamankan jaringan dhcp server menggunakan arp reply only menggunakan...Modul mengamankan jaringan dhcp server menggunakan arp reply only menggunakan...
Modul mengamankan jaringan dhcp server menggunakan arp reply only menggunakan...
 
Spring MVC - Web Forms
Spring MVC  - Web FormsSpring MVC  - Web Forms
Spring MVC - Web Forms
 
linux_Commads
linux_Commadslinux_Commads
linux_Commads
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
 
Spring MVC - Wiring the different layers
Spring MVC -  Wiring the different layersSpring MVC -  Wiring the different layers
Spring MVC - Wiring the different layers
 
Spring MVC - The Basics
Spring MVC -  The BasicsSpring MVC -  The Basics
Spring MVC - The Basics
 
01c. Starting A Router
01c.  Starting A  Router01c.  Starting A  Router
01c. Starting A Router
 
7 de abril
7 de abril7 de abril
7 de abril
 
12c Database TEMPORAL VALIDITY & FLASHBACK ARCHIVE Testing
12c Database TEMPORAL VALIDITY & FLASHBACK ARCHIVE Testing12c Database TEMPORAL VALIDITY & FLASHBACK ARCHIVE Testing
12c Database TEMPORAL VALIDITY & FLASHBACK ARCHIVE Testing
 
Linux networking commands short
Linux networking commands shortLinux networking commands short
Linux networking commands short
 
Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor format
 

Similar to Input output

C program that prompts user to enter two floating point t.pdf
  C program that prompts user to enter two floating point t.pdf  C program that prompts user to enter two floating point t.pdf
C program that prompts user to enter two floating point t.pdfaoneonlinestore1
 
Cis 115 Education Redefined-snaptutorial.com
Cis 115 Education Redefined-snaptutorial.comCis 115 Education Redefined-snaptutorial.com
Cis 115 Education Redefined-snaptutorial.comrobertledwes38
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxAASTHA76
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALPrabhu D
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEWshyamuopeight
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++cpjcollege
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsnoahjamessss
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringscskvsmi44
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment systempranoy_seenu
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 solIIUM
 
VISWAPAVAN _2015_v1
VISWAPAVAN _2015_v1VISWAPAVAN _2015_v1
VISWAPAVAN _2015_v1viswa pavan
 
Ecet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.comEcet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.comamaranthbeg80
 
Ecet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.comEcet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.comamaranthbeg120
 
Ecet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.comEcet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.comamaranthbeg100
 
Ecet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.comEcet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.comamaranthbeg60
 
GSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.comGSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.comclaric119
 
GSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.comGSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.comclaric169
 

Similar to Input output (20)

C program that prompts user to enter two floating point t.pdf
  C program that prompts user to enter two floating point t.pdf  C program that prompts user to enter two floating point t.pdf
C program that prompts user to enter two floating point t.pdf
 
Cis 115 Education Redefined-snaptutorial.com
Cis 115 Education Redefined-snaptutorial.comCis 115 Education Redefined-snaptutorial.com
Cis 115 Education Redefined-snaptutorial.com
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
C++
C++C++
C++
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment system
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
Conditional structure
Conditional structureConditional structure
Conditional structure
 
VISWAPAVAN _2015_v1
VISWAPAVAN _2015_v1VISWAPAVAN _2015_v1
VISWAPAVAN _2015_v1
 
Ecet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.comEcet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.com
 
Ecet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.comEcet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.com
 
Ecet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.comEcet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.com
 
Ecet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.comEcet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.com
 
GSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.comGSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.com
 
GSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.comGSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.com
 

More from International Islamic University (20)

Hash tables
Hash tablesHash tables
Hash tables
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Graph 1
Graph 1Graph 1
Graph 1
 
Graph 2
Graph 2Graph 2
Graph 2
 
Graph 3
Graph 3Graph 3
Graph 3
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Quick sort
Quick sortQuick sort
Quick sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
Linear timesorting
Linear timesortingLinear timesorting
Linear timesorting
 
Facial Expression Recognitino
Facial Expression RecognitinoFacial Expression Recognitino
Facial Expression Recognitino
 
Lecture#4
Lecture#4Lecture#4
Lecture#4
 
Lecture#3
Lecture#3 Lecture#3
Lecture#3
 
Lecture#2
Lecture#2 Lecture#2
Lecture#2
 
Case study
Case studyCase study
Case study
 
Arrays
ArraysArrays
Arrays
 
Pcb
PcbPcb
Pcb
 
Data transmission
Data transmissionData transmission
Data transmission
 
Basic organization of computer
Basic organization of computerBasic organization of computer
Basic organization of computer
 
Sorting techniques
Sorting techniquesSorting techniques
Sorting techniques
 

Recently uploaded

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxjmorse8
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptxmansk2
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resourcesdimpy50
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...Denish Jangid
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...sanghavirahi2
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxCapitolTechU
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportAvinash Rai
 

Recently uploaded (20)

B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 

Input output

  • 1. Manual # 1 Topic: Use of Formula`s Input & Output Subject: C & C++ Classes: 2nd Year & 3rd Year Author: Sunawar Khan Ahsan MS(Computer Vision) Author2: Mehwish Shabbir
  • 2. --------------------------------------------------------------------------------- Q#1:Write a program, which will display your name. --------------------------------------------------------------------------------- Q # 2: Execute the following formula`s in C++: Use of Addition, Subtraction, Multiplication & Division Addition: cout<<4+2<<"n"; Subtraction: cout<<2-6<<”n”; Multiplication: cout<<3*8<<”n”; Division: cout<<6/3<<”n”; For Formula below, you have to include the header file: math.h (#include<math.h>) Absolute: cout<<abs(-8)<<”n” ;means that it will give modulus of value given i.e. +ive value Exponent: cout<<exp(6)<<”n”; Power: cout<<pow(2,9)<<"n"; means that 2 raise to power 9 i.e. 2^9. Square Root: cout<<sqrt(16)<<”n”; Logarithm & Trigonometric Functions: Natural Algorithum: cout<<log(3)<<”n”; Gives the natural logarithm of 3. Sine: cout<<sin(45)<<”n”; Gives the Sine value of 45 degrees in radians. Cosine: cout<<cos(45)<<”n”; Gives the cosine value of 45 degrees in radians. Tangent: cout<<sin(45)<<”n”; Gives the Tangent value of 45 degrees in radians. Inverse of Sine: cout<<asin(30)<<”n”;Gives the inverse sine of 30 degrees in radians. Inverse of Cosine: cout<<acos(30)<<”n”;Gives the inverse cosine of 30 degrees in radians. Inverse of Tangent: cout<<atan(30)<<”n”;Gives the inverse tangent of 30 degrees in radians. Hyperbolic Sine: cout<<sinh(60)<<”n”; Gives the hyperbolic sine of 60 degrees in radians. Hyperbolic Cosine: cout<<cosh(60)<<”n”; Gives the hyperbolic cosine of 60 degrees in radians. Hyperbolic Tangent: cout<<tanh(60)<<”n”; Gives the hyperbolic tangent of 60 degrees in radians. ------------------------------------------------------------------------------------------------------------ 1. Declarationof Variable of Data Type (Integer) (a). Assigning a Fixed Value to Variable #include <iostream.h> int main() { int length; length = 7; cout<<"The Length is: "; cout<<length; cout<<"nn"; return 0; } (b). Assign the Value to Variable through Keyboard Remember to take value from keyboard, we use cin with operator >>. #include <iostream.h>
  • 3. int main() { int length; cin>>length; cout<<"The Length is: "; cout<<length; cout<<"nn"; return 0; } 2. Calculate the Area of the Box #include <iostream.h> int main() { int length; int width; length=7; width=5; cout<<"The area is: "; cout<<length*width; cout<<"nn"; return 0; } // The above program can also be written as: #include <iostream.h> int main() { int length, width, area; //you can declare the variable in one line. length=7; width=5; area = length * width; //you can store the result of multiplication in another //variable cout<<"The area is: "; cout<<area; cout<<"nn"; return 0; } // Program should take the value of length and width from User #include <iostream.h> int main() {
  • 4. int length, width, area; //you can declare the variable in one line. cin>>length; cin>>width; area = length * width; cout<<"The area is: "; cout<<area; cout<<"nn"; return 0; } // You can take the value from User in one line as Well. #include <iostream.h> int main() { int length, width, area; //you can declare the variable in one line. cin>>length>>width; area = length * width; cout<<"The area is: "; cout<<area; cout<<"nn"; return 0; } // Now, from here on you should write your program in such a way, that it will give the proper information. #include <iostream.h> int main() { int length, width, area; //you can declare the variable in one line. cout<<"Enter the Length: "; cin>>length; cout<<"Enter the Width: "; cin>>width; area = length * width; cout<<"The area is: "; cout<<area; cout<<"nn"; return 0; } ------------------------------------------------------------------------------------------------------------ Q1: Write a program which will calculate the Volume of the Box. The program should be able to take values of length, width and height of the box from the user and then display the result. ------------------------------------------------------------------------------------------------------------
  • 5. DeclarationofVariable of Data Type (Float) What is the difference of float data type from integer data type?? #include <iostream.h> int main() { int a, b, c; a=10; b=3; c=a/b; cout<<"Answer is: "; cout<<c; cout<<"nn"; return 0; } // The output of this program is 3, but actually 10/3 = 3.33333, but whenever fraction comes the int variable always takes the lower value like 10/6=1.66667 but the int variable will not convert it to 2 it will take the lower value i.e. 1 and excludes the fraction. So, for that the variable can be declared with float. #include <iostream.h> int main() { float a, b, c; a=10; b=3; c=a/b; cout<<"Answer is: "; cout<<c; cout<<"nn"; return 0; } //Answer is 3.3333, the float variable will show the result upto five decimals places. ------------------------------------------------------------------------------------------------------------ Q2: Write a program which will convert the feet into meters. The program should be able to take the feet value from the user and then converts it into meter. Forumla is: meters = feet / 3.28 ------------------------------------------------------------------------------------------------------------ Q3: Write a program which will calculate the value a from the following formulae: a = p ( 1 + k)^r, where k = 10% of p. Enter the value of p and r from the user. ------------------------------------------------------------------------------------------------------ ----- Casting: (Leave it: We`ill Discuss it Later) #include <iostream.h> int main() { int a, b, c; a=10; b=3; c=a/b; cout<<"Answer is: "; cout<<(float) c; cout<<"n";
  • 6. cout<<"Answer is: "; cout<<(float) a/b; cout<<"nn"; return 0; } ------------------------------------------------------------------------------------------------------------ Q4: Write a program for the calculation of the roots of Quardatic Equation. The program should be designed in such a way that user should be able to enter the values of a, b, & c. And the formula to calculate the roots of Quadratic Equation. ------------------------------------------------------------------------------------------------------------ Q5:If a five digit number enter is input through keyboard. Write a program to calculate the sum of its digits. ------------------------------------------------------------------------------------------------------------ Q6:If a five digit number enter is input through keyboard. Write a program to find its reverse. ------------------------------------------------------------------------------------------------------------ Q7:If a four digit number enters through the keyboard. Write a program to obtain sum of the first and last digit of that number. ------------------------------------------------------------------------------------------------------------ Q8:in a town percentage of man is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of the total population to find the total number of illiterate men and women if the population of the town is 80,000. ------------------------------------------------------------------------------------------------------------ Q9:if the total selling price of 15 items and total profit earned on item is input through keyboards. Write a program to find the cost price of one item. ------------------------------------------------------------------------------------------------------------ Q10: One large chemical company pays its salesperson on a commission basis. The company pays salesman $200 per week plus 9 percent of his gross sale of that week. For example, a salesperson sales $5000 worth of chemicals in a week, so company pays him $200 + 9% of $5000 = $650. Write a program for the company which will take the value from the user of total worth in dollars sailed by the salesperson in one week and calculate his total earning of that week. ------------------------------------------------------------------------------------------------------------ Q11: A company pays Rs: 10,000 per month to its employee. If he worked extra hours then the company paid Rs 35 for each extra hour. Write a program which will take the total number of extra hours of a month from the user and then calculate the total earning of an employee of that month. Q12:Write a program that generates the following output: 10 20 19 Use an integer constant for the 10, an arithmetic assignment operator to generate 20, and a decrement operator to generate 19 ------------------------------------------------------------------------------------------------------------ Q13: Write a program to get current year and birth year of a person and display current age. Q14:Write a program to convert 2.5 miles into kilometers and print the result on the screen. Hint: 1 mile= 1.609 Kilometer ----------------------------------------------------------------------------------------------------------- Q15:Write a program to interchange the values of two variable using ----------------------------------------------------------------------------------------------------------- Q16: Write a program to separate the integral and fractional parts of given real number and print the result on the screen. ----------------------------------------------------------------------------------------------------------- Q17:Write a program that input a character and display its ASCII code. ----------------------------------------------------------------------------------------------------------- Q18: Write a program that input ASCII code between (0-255) and display corresponding character against given value.
  • 7. ----------------------------------------------------------------------------------------------------------- Q19: Write a program to calculate simple interest. It input principle amount, rate of interest, and the number of years and display the simple interest. Hint: i= (p*r*t)/100 ------------------------------------------------------------------------------------------------------------ Q20:Write a program that input dividend and divisor it then calculate and display quotient and remainder. ----------------------------------------------------------------------------------------------------------- Q21:Write a program that input the distance travelled and the speed of vehicle. It calculates time required to reach destination and display it. ----------------------------------------------------------------------------------------------------------- Q22:The distance between two cities (K.M.) is input through keyboard. Write a program to convert and print this distance in meters, feet and centimeters. ----------------------------------------------------------------------------------------------------------- Q23:Write a program that input time in seconds and convert it into hh-mm-ss format. ----------------------------------------------------------------------------------------------------------- Q24: Write a program that inputs three digit number from the user and display following Output: Enter Three Digit Number 456 Number Enter by the User Is 456 Number in Reverse Order Is 654 Number Display in Separate Line 4 5 6 ----------------------------------------------------------------------------------------------------------- Q25: Write a program that will prompt the user to enter number of hours it computes and display the number of weeks, days. ----------------------------------------------------------------------------------------------------------- Q26: Write a program that prompt age in years and display it in months, days and weeks. ----------------------------------------------------------------------------------------------------------- Q27: Write a program that prompt marks obtained by a student in five subjects. It then calculates and then displays the total marks and percentage. ----------------------------------------------------------------------------------------------------------- Q28:Write a program that input basic salary and calculate 35% dearness allowance, 33.3 house rent and then display the gross salary. ----------------------------------------------------------------------------------------------------------- Q29:Write a program that input five digit numbers and calculate its sum, average and product. ----------------------------------------------------------------------------------------------------------- Q30:Write a program that input two times in hh-mm-ss format, add both time and then displays total time. ----------------------------------------------------------------------------------------------------------- Q31:Write a program that input the X, Y co-ordinates for two points and compute the distance between two points. Hint: √( 𝒙𝟐 − 𝒙𝟏) 𝟐 + (𝒚𝟐 − 𝒚𝟏)𝟐 ----------------------------------------------------------------------------------------------------------- Q32:Write a program that find out the area of triangle when three sides a,b and c of the triangle are given. Hint: √ 𝒔( 𝒔 − 𝒂)( 𝒔 − 𝒃)(𝒔 − 𝒄) where c=a+b+c/2 ----------------------------------------------------------------------------------------------------------- Q33:Write a program that input temperature from the user in Fahrenheit and convert it into Celsius using formula c=5/9(f-32). ----------------------------------------------------------------------------------------------------------- Q34:Write a program that input temperature from the user in Celsius and convert it into Fahrenheit using formula f=9/5(c+32). ----------------------------------------------------------------------------------------------------------- Q35:Write a program that input total number of student in a class and fee per student it displays total fee collection from class. ----------------------------------------------------------------------------------------------------------- Q36:A car can travel 5.3 miles in 1 liter. Write a program that input petrol in liter and display total distance cover by car.
  • 8. ----------------------------------------------------------------------------------------------------------- Q37:Write a program to calculate volume (V) of a cube using formula V=length*width*height. ----------------------------------------------------------------------------------------------------------- Q38:Write a program that input a number and compute its square and cube. ----------------------------------------------------------------------------------------------------------- Q39:Write a program that input total pages of a book, number of pages a person read in one day and number of days a person has read the book. It displays number of pages that have been read and number of pages remaining. ----------------------------------------------------------------------------------------------------------- Q40:Write a program that input radius of sphere from the user calculate its volume and area using formula 𝐴 = 4𝜋𝑟2 and 𝐶 = 4/3𝜋𝑟3 ----------------------------------------------------------------------------------------------------------- Q41: Write a program that displays following statement The character ‘x’ The name S.K.Ahsan The number 786 ----------------------------------------------------------------------------------------------------------- Q 42: K.E. 1/2m.v2 ----------------------------------------------------------------------------------------------------------- Q 43: S=vit+1/2at2 ----------------------------------------------------------------------------------------------------------- Q 44: vf=vi+at ----------------------------------------------------------------------------------------------------------- Q 45: K.E. 1/2m.v2 ----------------------------------------------------------------------------------------------------------- Q 46: a=vf-vi/t ----------------------------------------------------------------------------------------------------------- Q 48: v=d/t , d=vt ----------------------------------------------------------------------------------------------------------- Q 49: A cashier has currency notes of denominations 10, 50,100. If the amount to be withdrawn is input through the keyboard. Find the total number of currency notes of each denominations the cashier will have give to the withdrawer. ----------------------------------------------------------------------------------------------------------- Q50:Write a program to calculate the Units of demand will be demanded if the price is Rs. 18.00? The formula p = 90(5)-q/10 applies to the demand of a product, where “q” is the number of units and “p” is the price of one unit. ----------------------------------------------------------------------------------------------------------- Q51:Write a program to calculate the values of l& m. If the expression lx3+ mx2 + 4 leaves the remainder of -3 and 12 when divided by (x - 1) & (x + 2) respectively. ----------------------------------------------------------------------------------------------------------- Q52:Write a program that print the double of a number of a number that is entered by a user. For example if user enter 702 than its calculated double number is 1404. ----------------------------------------------------------------------------------------------------------- Q53:Write a program which shows the output as follow: What's your name? Sunawar Khan Ahsan Hello Sunawar Khan Ahsan. What is your favorite team? The Isotopes I like The Isotopes too! ----------------------------------------------------------------------------------------------------------- Q54:Write a program to find the Length of AD& Area of ABC Of the isosceles , the base BC = 28 cm, and AB = AC = 50 cm, If AD| BC. ----------------------------------------------------------------------------------------------------------- Q56: Write a program that separate a string into letters/alphabets, such as input string is Hello, and separated string is:[H][e][l][l][o][!] ----------------------------------------------------------------------------------------------------------- Q57: Write a program to prove the Right Distributive Law Of the Production by using dynamic input. -----------------------------------------------------------------------------------------------------------
  • 9. ----------------------------------------------------------------------------------------------------------- Q58:Write a program that convert the entered choice into vice versa into hexadecimal number, octal & integer. For example if user enter 18 then this number is converted into hexa or octal number system. ----------------------------------------------------------------------------------------------------------- Q60:Write a program that swap the entered number without using third variable. ----------------------------------------------------------------------------------------------------------- Q61: Write a program which accepts amount as integer and display total number of Notes of Rs. 500, 100, 50, 20, 10, 5 and 1.For example, when user enter a number, 575, the results would be like this... 500: 1 100: 0 50: 1 20: 1 10: 0 5: 1 1: 0 ----------------------------------------------------------------------------------------------------------- Q62: Write a program which accepts a character and display its next character. ----------------------------------------------------------------------------------------------------------- Q63: What is the Output of following: int result = 4 + 5 * 6 + 2; cout<<result; int a = 5 + 7 % 2; cout<<a; ----------------------------------------------------------------------------------------------------------- Q64: Write a program which accepts days as integer and display total number of years, months and days in it. ----------------------------------------------------------------------------------------------------------- Q65:What is the output of following: ----------------------------------------------------------------------------------------------------------- int x = 10,y; y = x++; cout<<y; int x = 10,y; y = x++; cout<<x; int x = 10; x++; cout<<x; int x = 10,y; y = ++x; cout<<y; int x = 10; cout<<++x; int x = 10; cout<<x++; Q66:What is the output of the following? main(){ int count=10; cout<<"count="<<count<<endl; cout<<"count="<<count++<<endl; cout<<"count="<<count<<endl; cout<<"count="<<++count<<endl; return 0; } main(){ int count=10; cout<<"count="<<count<<endl; cout<<"count="<<count--<<endl; cout<<"count="<<count<<endl; cout<<"count="<<--count<<endl; return 0; } int main(){ int ans=27; ans+=10; cout<<ans<<","; ans-=7; cout<<ans<<","; ans*=2; cout<<ans<<","; ans/=3; cout<<ans<<","; ans%=3; return 0; } int main(){ int i=2, j=3, k,i; float a,b; k=i/j*j; i=j/j*i; a=i/j*j; b=j/i*i; return 0; }
  • 10. Q67:What is the output of following program? int x = 10; cout<<x<<x++; int x = 10; cout<<++x<<x++<<x; int x = 10; cout<<x++<<x<<++x; int x = 10,y; y = x + x++; cout<<y; int x = 10,y; y = ++x + x++ + x; cout<<y; int x = 10,y; y = x++ + x + ++x; cout<<y; ----------------------------------------------------------------------------------------------------------- Q68: Write a program that takes length as input in feet and inches. The program should then convert the lengths in centimeters and display it on screen. Assume that the given lengths in feet and inches are integers. /******************************************************** Purpose :This program converts measurement in feet and inches into centimeters. @Author :Sunawar Khan Ahsan ********************************************************/ #include <iostream.h> //Header file const double CENTIMETERS_PER_INCH = 2.54; //Named constants const int INCHES_PER_FOOT = 12; //Named constants int main () { int feet, inches; int totalInches; double centimeter; cout<< "Enter two integers, one for feet and one for inches: "; cin>> feet>> inches; cout<< endl; cout<< "The numbers you entered are " << feet<< " for feet and " << inches<< " for inches. " << endl; totalInches = INCHES_PER_FOOT * feet + inches; cout<< "The total number of inches = " << totalInches<< endl; centimeter = CENTIMETERS_PER_INCH * totalInches; cout<< "The number of centimeters = " << centimeter<< endl; return 0; } -----------------------------------------------------------------------------------------------------------
  • 11. Summary:  A function named main () is always the first one executed when a program is executed.  Expression is combination of Operator and Operand e.g. sum=a+b  Output is handled by printf and input is handled by scanf object in C.  Output is handled by cout and input is handled by cin object in C++.  The variable is no longer a variable but a constant.  A function body is delimited by {}.  A function name must be followed by parenthesis otherwise compiler read it as variable.  The three primary constants and variable types in c are integer, float and character  A variable name can be of maximum 31 characters.  Don’t use keyword as variable.  A C++ compiler produces code that can be directly executed by the computer.  A header contains information used by the program.  <iostream>,<stdio> is the header the supports I/O. The statement includes the <iostream>, <stdio> header in a program. C++ & C  A variable is a named memory location. The contents of a variable can be changed during the execution of a program.  A variable is a named memory location. The contents of a variable can be changed during the execution of a program.  The keyword is for. In C++, all keywords are in lowercase.  A C++ identifier can contain letters, digits, and the underscore.  C++ is case sensitive.  Type parentheses ’( )’ and braces ‘{ }’ in pairs  Use parentheses for clarification in arithmetic expressions  Don’t forget semicolon at the end of each statement.  Analyze the problem properly, and then start coding (first think and then write). ----------------------------------------------------------------------------------------------------------- S una w a r K ha n Ahs a n For solution contact me at 03334892200 Mail: sk_ahsan38@yahoo.com -----------------------------------------------------------------------------------------------------------