SlideShare a Scribd company logo
Problem Set for Sequential StructureProgramming Assignment 
Convert the following mathematical expressions into C++ Expressions. 
Algebraic Expression C++ Expression 
(a*b)-(c*d) 
(m+n)*(a+b) 
3*x*x+2(x)+5 
(a+b+c)/(d+e) 
[(2*b*y)/(d+1)-(x)/3(z+y)] 
Which of the following are invalid variable names and why? 
BASICSALARY valid variable. 
#MEAN is wrong because “#” is not allowed for variable. 
2015_DDay invalid variable. 
group. Is variable. 
basic-hra - is not allowed in variable. 
_basic is variable. 
422 numbers are not variables. 
Plot # 3 invalid statement “#” is not allowed in variable. 
hELLO is variable. 
population in 2006 spaces are not allowed in variable. 
over time is again wrong due space in variable. 
mindovermatter is variable. 
queue. . is not is variable. 
team’svictory ‘ is not allowed in variable. 
FLOAT is variable. 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030
Problem Set for Sequential StructureProgramming Assignment 
Evaluate the following expressions according to their precedence. 
Expression Evaluate C++ Expression 
(A)g = big / 2 + big * 4 / big - big + abc / 3 ; 
(abc = 2.5, big = 2, assume g to be a float) 
(B) on = ink * act / 2 + 3 / 2 * act + 2 + tig ; 
(ink = 4, act = 1, tig = 3.2, assume on to be an 
int) 
(C) s = qui * add / 4 - 6 / 2 + 2 / 3 * 6 / god ; 
(qui = 4, add = 2, god = 2, assume s to be an 
int) 
(D) s = 1 / 3 * a / 4 - 6 / 2 + 2 / 3 * 6 / g ; 
(a = 4, g = 3, assume s to be an int) 
float g=(big/2)+((big*4)/big)-((big+abc)/3); 
int on=((ink*act)/2)+(3/2*act)+2+tig; 
int s=((qui*add)/4)-(6/2)+((2/3)*(6/god)); 
int s=((1/3)*(a/4))-(6/2)+((2/3)*(6/g)); 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
(A) 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float g, big, abc; 
big=2; 
abc=5; 
g = big /( 2 + big * 4) /( big - big + abc )/ 3 ; 
cout<<g; 
} 
(B) 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main()
Problem Set for Sequential StructureProgramming Assignment 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
{ 
int ink, act; 
ink=4; 
act=1; 
float tig, on; 
tig=3.2; 
on = (ink * act )/( 2 + 3) / (2 * act + 2 + tig); 
cout<<on; 
} 
(C) 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
int qui,add,god,s; 
qui=4; add=2; god=2; 
s = (qui * add )/ (4 - 6 )/( 2 + 2) / (3 * 6)/ god ; 
cout<<s; 
} 
(D) 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
int a, g, s; 
a=4; g=3; 
s = 1 / (3 * a )/ (4 - 6 )/ (2 + 2)/ (3 * 6)/ g ; 
cout<<s; 
getch(); 
}
Problem Set for Sequential StructureProgramming Assignment 
Find the errors, if any in the following C++ statements. 
Errors C++ statements 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
(a) int = 314.562 * 150 ; 
(b) name = ‘Ajay’ ; 
(c) varchar = ‘3’ ; 
(d) 3.14 * r * r * h = vol_of_cyl ; 
(e) k=(a*b) (c+(2.5a+b)(d+e); 
(f) m_inst = rate of interest * 
amount in rs ; 
(g) si = principal * rateofinterest 
* numberofyears / 100 ; 
(h) area = 3.14 * r ** 2 ; 
(i) volume = 3.14 * r ^ 2 * h ; 
(j) k = (( a*b )+ c ) (2.5 * a + b ) ; 
(k) a = b = 3 = 4 ; 
(l) count = count + 1 ; 
(m) date = '2 Mar 04' ; 
Float=314.562*150; 
String=’Ajay’ 
Varchar=(3); 
Vol_of_cyl=3.14*r*r*h; 
is wrong because missing some opratus 
m_inst = rate_of_interest* 
amount_in rs; 
int si=principal*rateofinterest*numberofyears/100 ; 
float area=3.14*r*2; 
volume=3.14*r*r*h; 
k=((a*b)+c)*(2.5*a+b); 
a=3,b=4; 
count=count+1; is correct or we can write it as count++; 
string date=”2March04”; 
Convert the following equations into corresponding C++ statements. 
Equations C++ statements 
Z = 8.8(a+b)2/c-0.5+2a/(q+r) 
(a+b)*(1/m) 
X = -b+(b*b)+24ac 
2a 
R = 2v+6.22(c+d) 
g+v 
A = 7.7b(xy+a)/c-0.8+2b 
(x+a) (1/y) 
Z = 8.8(a+b)2/(c)-0.5+2(a)/(q+r)/(a+b)*(1/m) 
X = -(b)+(b*b)+2(4)(a*c)/2(a) 
R = 2(v)+6.22(c+d)/(g+v) 
A = 7.7(b)[(x*y)+a]/c-0.8+2(b)/(x+a)*(1/y)
Problem Set for Sequential StructureProgramming Assignment 
/*Trace out the output (A)*/ 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
int i=2,j=3,k,l; 
float a,b; 
k=i/j*j; 
l=j/i*i; 
a=i/j*j; 
b=j/i*i; 
cout<<k<<l<<a<<b; 
getch(); 
return 0; 
} 
/*Trace out the output (B)*/ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
int a,b; 
a=(-3)-(-3); 
b=(-3)+(-3); 
cout<<"a="<<a<<"b="<<b; 
getch(); 
return 0; 
}
Problem Set for Sequential StructureProgramming Assignment 
/*Trace out the output (c)*/ 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
cout<<"nnnn nnn"; 
printf( "nn/n/nnn/n"); 
getch(); 
return 0; 
} 
/*Trace out the output (D)*/ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
int p,q; 
cout<<"Enter Values of p and q"; 
cin>>p>>q; 
cout<<"p="<<p<<"tq="<<q; 
getch(); 
return 0; 
} 
Write a C++ program for the following 
/* (a) Rameez's basic salary is input through the keyboard. 
His dearness allowance is 40% of basic salaryand house rent allowance 
is 20% of basic salary.Write a program to calculate his gross salary.*/ 
# include<iostream> 
# include<stdio.h>
Problem Set for Sequential StructureProgramming Assignment 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float bs=0,da=0,hr=0,gs=0; 
cout<<" Enter Rameez's basic salary : "; 
cin>>bs; 
da=bs*40/100; 
hr=bs*20/100; 
gs=da; 
/*cout<<"n Basic salary : "; 
cout<<bs; 
cout<<"n Deaness allowance : "; 
cout<<da; 
cout<<"n House rent allowance : "; 
cout<<hr;*/ 
cout<<"n Gross salary : "; 
cout<<gs; 
getch(); 
return 0; 
} 
/*(b) The distance between two cities (in km.) is input through the keyboard. 
Write a program to convert and print this distance in meters, feet, inches 
and centimeters. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float km=0,m=0,f=0,i=0,cm=0; 
cout<<" Enter Kilometers : "; 
cin>>km; 
m=km*1000; 
f=km*3280.83989501; 
i=km*39370.1; 
cm=km*100000; 
cout<<"n Meters : "; 
cout<<m; 
cout<<"n Feets : "; 
cout<<f; 
cout<<"n Inches : ";
Problem Set for Sequential StructureProgramming Assignment 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
cout<<i; 
cout<<"n Centimeters : "; 
cout<<cm; 
getch(); 
return 0; 
} 
/*(c) If the marks obtained by a student in five different subjects are input 
through the keyboard, find out the aggregate marks and percentage marks 
obtained by the student.Assume that the maximum marks that can be obtained by 
a student in each subject is 100. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float che,phy,bio,eng,com,total=500,sum,agg=0,per=0; 
cout<<"n Chemistry : "; 
cin>>che; 
cout<<"n Physics : "; 
cin>>phy; 
cout<<"n Biology : "; 
cin>>bio; 
cout<<"n English : "; 
cin>>eng; 
cout<<"n Computer : "; 
cin>>com; 
sum=che+phy+bio+eng+com; 
agg=(sum/total)*100; 
cout<<"n Aggregate Marks : "; 
cout<<agg; 
per=(sum*100)/total; 
cout<<"n Percentage : "; 
cout<<per; 
getch(); 
return 0;
Problem Set for Sequential StructureProgramming Assignment 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
} 
/*(d) Temperature of a city in Fahrenheit degrees is input through the keyboard. 
Write a program to convert this temperature into Centigrade degrees. 
Tc = (5/9)*(Tf-32); */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float tf=0,tc=0,Div; 
cout<<"Enter Fahrehrit degrees : "; 
cin>>tf; 
Div=0.5555555555555556; 
tc=Div*(tf-32); 
cout<<"Centigrade degrees: "; 
cout<<tc; 
getch(); 
return 0; 
} 
/*(e) The length & breadth of a rectangle and radius of a circle are input 
through the keyboard. Write a program to calculate the area & perimeter of the 
rectangle, and the area & circumference of the circle. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{
Problem Set for Sequential StructureProgramming Assignment 
float len1=0,bre1=0,rad=0,rec1=0,area1=0,per1=0,area2=0,cir=0; 
cout<<" Enter lenght of rectangle : "; 
cin>>len1; 
cout<<" Enter breadth of rectangle : "; 
cin>>bre1; 
cout<<" Enter radius of circle : "; 
cin>>rad; 
area1=len1*bre1; 
per1=2*(len1+bre1); 
cout<<"n Area of rectangle : "; 
cout<<area1; 
cout<<"n Perimeter of rectangle : "; 
cout<<per1; 
area2=3.14159265*(rad*rad); 
cir=6.2831853*rad; 
cout<<"n Area of circle : "; 
cout<<bre1; 
cout<<"n Circumference of circle : "; 
cout<<cir; 
getch(); 
return 0; 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
} 
/*(f) Two numbers are input through the keyboard into two locations C and D. 
Write a program to interchange the contents of C and D. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float loc1=0,loc2=0,x=0; 
cout<<" Enter location C number : "; 
cin>>loc1; 
cout<<" Enter location D number : "; 
cin>>loc2; 
x=loc1; 
loc1=loc2; 
loc2=x;
Problem Set for Sequential StructureProgramming Assignment 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
cout<<"n Value of C locatio : "; 
cout<<loc1; 
cout<<"n Value of D Location : "; 
cout<<loc2; 
getch(); 
return 0; 
} 
/*(g) If a five-digit number is input through the keyboard, write a program 
to calculate the sum of its digits.*/ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float a=0,b=0,c=0,d=0,e=0,sum=0; 
cout<<" Enter 1st digit of a number : "; 
cin>>a,b,c,d,e; 
cout<<" Enter 2nd digit of a number : "; 
cin>>b; 
cout<<" Enter 3rd digit of a number : "; 
cin>>c; 
cout<<" Enter 4th digit of a number : "; 
cin>>d; 
cout<<" Enter 5th digit of a number : "; 
cin>>e; 
sum=a+b+c+d+e; 
cout<<"n Sum : "; 
cout<<sum; 
getch(); 
return 0; 
} 
/*(h) If a five-digit number is input through the keyboard, write a program 
to reverse the number. */
Problem Set for Sequential StructureProgramming Assignment 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float a=0,b=0,c=0,d=0,e=0; 
cout<<" Enter 1st digit number : "; 
cin>>a; 
cout<<" Enter 2nd digit number : "; 
cin>>b; 
cout<<" Enter 3rd digit number : "; 
cin>>c; 
cout<<" Enter 4th digit number : "; 
cin>>d; 
cout<<" Enter 5th digit number : "; 
cin>>e; 
cout<<"n 1st digit number : "; 
cout<<e; 
cout<<"n 2nd digit number : "; 
cout<<d; 
cout<<"n 3rd digit number : "; 
cout<<c; 
cout<<"n 4th digit number : "; 
cout<<b; 
cout<<"n 5th digit number : "; 
cout<<a; 
getch(); 
return 0; 
} 
/*(i) If a four-digit number is input through the keyboard, write a program 
to obtain the sum of the first and last digit of this number. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main()
Problem Set for Sequential StructureProgramming Assignment 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
{ 
float a=0,b=0,c=0,d=0,e=0,sum=0; 
cout<<" Enter 1st digit of a number : "; 
cin>>a; 
cout<<" Enter 2nd digit of a number : "; 
cin>>b; 
cout<<" Enter 3rd digit of a number : "; 
cin>>c; 
cout<<" Enter 4th digit of a number : "; 
cin>>d; 
cout<<" Enter 5th digit of a number : "; 
cin>>e; 
sum=a+e; 
cout<<"n Sum : "; 
cout<<sum; 
getch(); 
return 0; 
} 
/*(j) In a town, the percentage of men is 52. The percentage of total literacy 
is 48. If total percentage of literate men is 35 of the total population, write 
a program to find the total number of illiterate men and women if the 
population of the town is 80,000. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float tm,im,iw,tp=80000; 
cout<<" Total popuation in Town : "; 
cout<<tp; 
tm=(52.0/100.0)*tp; 
im=tm-iw; 
cout<<"n Total number of illeriate men : "; 
cout<<im; 
iw=tp-tm; 
cout<<"n Total number of illeriate women : "; 
cout<<iw; 
getch();
Problem Set for Sequential StructureProgramming Assignment 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
return 0; 
} 
/*(k)A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn 
isinput through the keyboard in hundreds, find the total number of currency notes of each 
denomination the cashier will have to give to the withdrawer. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float a=0,b=0,c=0,x=0; 
cout<<" Amount : "; 
cin>>x; 
a=x/10; 
cout<<"n Currency notes of 10 : "; 
cout<<a; 
b=x/50; 
cout<<"n Currency notes of 50 : "; 
cout<<b; 
c=x/100; 
cout<<"n Currency notes of 100 : "; 
cout<<c; 
getch(); 
return 0; 
} 
/*(l) If the total selling price of 15 items and the total profit earned on 
them is input through the keyboard, write a program to find the cost price 
of one item. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{
Problem Set for Sequential StructureProgramming Assignment 
float sp=0,tp=0,cp=0; 
cout<<" Total selling price : "; 
cin>>sp; 
cout<<"n Total Profit Earned : "; 
cin>>tp; 
cp=(sp+tp)/15; 
cout<<"n Cost price of one item : "; 
cout<<cp; 
getch(); 
return 0; 
Junaid Ahmed (BS-SE)1st semester 
Roll No: F14-030 
} 
/*(m) If a five-digit number is input through the keyboard, write a program to 
print a new number by adding one to each of its digits. */ 
# include<iostream> 
# include<stdio.h> 
# include<conio.h> 
using namespace std; 
int main() 
{ 
float dig=0,x=0,y=0; 
cout<<" Enter digits : "; 
cin>>dig; 
y=11111; 
x=y+dig; 
cout<<"n Output : "; 
cout<<x; 
getch(); 
return 0; 
}

More Related Content

PDF
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
DOCX
Let us c (by yashvant kanetkar) chapter 1 solution
DOC
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
DOCX
Computer Science Practical Science C++ with SQL commands
PDF
Let us c(by yashwant kanetkar) chapter 2 solution
PDF
54602399 c-examples-51-to-108-programe-ee01083101
DOCX
Let us C (by yashvant Kanetkar) chapter 3 Solution
PDF
C++ TUTORIAL 8
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Computer Science Practical Science C++ with SQL commands
Let us c(by yashwant kanetkar) chapter 2 solution
54602399 c-examples-51-to-108-programe-ee01083101
Let us C (by yashvant Kanetkar) chapter 3 Solution
C++ TUTORIAL 8

What's hot (20)

PDF
C++ TUTORIAL 6
DOCX
Chapter 8 c solution
PDF
Let us c chapter 4 solution
PDF
Aplikasi menghitung matematika dengan c++
PDF
Data Structure - 2nd Study
PDF
Nonlinear analysis of frame with hinge by hinge method in c programming
PDF
C++ TUTORIAL 1
PDF
C++ Programming - 14th Study
PDF
C++ Programming - 4th Study
PPTX
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
PDF
C++ Programming - 11th Study
PDF
C++ TUTORIAL 4
PPTX
Ee 3122 numerical methods and statistics sessional credit
DOCX
Printing different pyramid patterns of numbers,alphabets and stars using C.
PDF
LET US C (5th EDITION) CHAPTER 2 ANSWERS
PDF
C++ TUTORIAL 5
PDF
Naive application of Machine Learning to Software Development
TXT
Railwaynew
PDF
LET US C (5th EDITION) CHAPTER 1 ANSWERS
PDF
Development By The Numbers - ConFoo Edition
C++ TUTORIAL 6
Chapter 8 c solution
Let us c chapter 4 solution
Aplikasi menghitung matematika dengan c++
Data Structure - 2nd Study
Nonlinear analysis of frame with hinge by hinge method in c programming
C++ TUTORIAL 1
C++ Programming - 14th Study
C++ Programming - 4th Study
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
C++ Programming - 11th Study
C++ TUTORIAL 4
Ee 3122 numerical methods and statistics sessional credit
Printing different pyramid patterns of numbers,alphabets and stars using C.
LET US C (5th EDITION) CHAPTER 2 ANSWERS
C++ TUTORIAL 5
Naive application of Machine Learning to Software Development
Railwaynew
LET US C (5th EDITION) CHAPTER 1 ANSWERS
Development By The Numbers - ConFoo Edition
Ad

Similar to Junaid program assignment (20)

PDF
09 a1ec01 c programming and data structures
PDF
Mmt 001
PPT
Apclass (2)
PPT
PPT
Apclass (2)
DOCX
Oops practical file
PDF
Sample Paper 2 Class XI (Computer Science)
PDF
CBSE Question Paper Computer Science with C++ 2011
DOC
Useful c programs
PDF
Computer P-Lab-Manual acc to syllabus.pdf
DOCX
Fuzail_File_C.docx
DOCX
Listing modul 4
DOCX
Practical File of c++.docx lab manual program question
PPTX
oops practical file.pptx IT IS A PRACTICAL FILE
PDF
C and Data structure lab manual ECE (2).pdf
DOCX
Chapter 1 Programming Fundamentals Assignment.docx
DOCX
PDF
C++ TUTORIAL 2
09 a1ec01 c programming and data structures
Mmt 001
Apclass (2)
Apclass (2)
Oops practical file
Sample Paper 2 Class XI (Computer Science)
CBSE Question Paper Computer Science with C++ 2011
Useful c programs
Computer P-Lab-Manual acc to syllabus.pdf
Fuzail_File_C.docx
Listing modul 4
Practical File of c++.docx lab manual program question
oops practical file.pptx IT IS A PRACTICAL FILE
C and Data structure lab manual ECE (2).pdf
Chapter 1 Programming Fundamentals Assignment.docx
C++ TUTORIAL 2
Ad

Recently uploaded (20)

PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Classroom Observation Tools for Teachers
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Pre independence Education in Inndia.pdf
PPTX
Lesson notes of climatology university.
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
RMMM.pdf make it easy to upload and study
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Complications of Minimal Access Surgery at WLH
Abdominal Access Techniques with Prof. Dr. R K Mishra
O5-L3 Freight Transport Ops (International) V1.pdf
Classroom Observation Tools for Teachers
Sports Quiz easy sports quiz sports quiz
Final Presentation General Medicine 03-08-2024.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Pre independence Education in Inndia.pdf
Lesson notes of climatology university.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
VCE English Exam - Section C Student Revision Booklet
PPH.pptx obstetrics and gynecology in nursing
Microbial disease of the cardiovascular and lymphatic systems
RMMM.pdf make it easy to upload and study
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

Junaid program assignment

  • 1. Problem Set for Sequential StructureProgramming Assignment Convert the following mathematical expressions into C++ Expressions. Algebraic Expression C++ Expression (a*b)-(c*d) (m+n)*(a+b) 3*x*x+2(x)+5 (a+b+c)/(d+e) [(2*b*y)/(d+1)-(x)/3(z+y)] Which of the following are invalid variable names and why? BASICSALARY valid variable. #MEAN is wrong because “#” is not allowed for variable. 2015_DDay invalid variable. group. Is variable. basic-hra - is not allowed in variable. _basic is variable. 422 numbers are not variables. Plot # 3 invalid statement “#” is not allowed in variable. hELLO is variable. population in 2006 spaces are not allowed in variable. over time is again wrong due space in variable. mindovermatter is variable. queue. . is not is variable. team’svictory ‘ is not allowed in variable. FLOAT is variable. Junaid Ahmed (BS-SE)1st semester Roll No: F14-030
  • 2. Problem Set for Sequential StructureProgramming Assignment Evaluate the following expressions according to their precedence. Expression Evaluate C++ Expression (A)g = big / 2 + big * 4 / big - big + abc / 3 ; (abc = 2.5, big = 2, assume g to be a float) (B) on = ink * act / 2 + 3 / 2 * act + 2 + tig ; (ink = 4, act = 1, tig = 3.2, assume on to be an int) (C) s = qui * add / 4 - 6 / 2 + 2 / 3 * 6 / god ; (qui = 4, add = 2, god = 2, assume s to be an int) (D) s = 1 / 3 * a / 4 - 6 / 2 + 2 / 3 * 6 / g ; (a = 4, g = 3, assume s to be an int) float g=(big/2)+((big*4)/big)-((big+abc)/3); int on=((ink*act)/2)+(3/2*act)+2+tig; int s=((qui*add)/4)-(6/2)+((2/3)*(6/god)); int s=((1/3)*(a/4))-(6/2)+((2/3)*(6/g)); Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 (A) # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float g, big, abc; big=2; abc=5; g = big /( 2 + big * 4) /( big - big + abc )/ 3 ; cout<<g; } (B) # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main()
  • 3. Problem Set for Sequential StructureProgramming Assignment Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 { int ink, act; ink=4; act=1; float tig, on; tig=3.2; on = (ink * act )/( 2 + 3) / (2 * act + 2 + tig); cout<<on; } (C) # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { int qui,add,god,s; qui=4; add=2; god=2; s = (qui * add )/ (4 - 6 )/( 2 + 2) / (3 * 6)/ god ; cout<<s; } (D) # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { int a, g, s; a=4; g=3; s = 1 / (3 * a )/ (4 - 6 )/ (2 + 2)/ (3 * 6)/ g ; cout<<s; getch(); }
  • 4. Problem Set for Sequential StructureProgramming Assignment Find the errors, if any in the following C++ statements. Errors C++ statements Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 (a) int = 314.562 * 150 ; (b) name = ‘Ajay’ ; (c) varchar = ‘3’ ; (d) 3.14 * r * r * h = vol_of_cyl ; (e) k=(a*b) (c+(2.5a+b)(d+e); (f) m_inst = rate of interest * amount in rs ; (g) si = principal * rateofinterest * numberofyears / 100 ; (h) area = 3.14 * r ** 2 ; (i) volume = 3.14 * r ^ 2 * h ; (j) k = (( a*b )+ c ) (2.5 * a + b ) ; (k) a = b = 3 = 4 ; (l) count = count + 1 ; (m) date = '2 Mar 04' ; Float=314.562*150; String=’Ajay’ Varchar=(3); Vol_of_cyl=3.14*r*r*h; is wrong because missing some opratus m_inst = rate_of_interest* amount_in rs; int si=principal*rateofinterest*numberofyears/100 ; float area=3.14*r*2; volume=3.14*r*r*h; k=((a*b)+c)*(2.5*a+b); a=3,b=4; count=count+1; is correct or we can write it as count++; string date=”2March04”; Convert the following equations into corresponding C++ statements. Equations C++ statements Z = 8.8(a+b)2/c-0.5+2a/(q+r) (a+b)*(1/m) X = -b+(b*b)+24ac 2a R = 2v+6.22(c+d) g+v A = 7.7b(xy+a)/c-0.8+2b (x+a) (1/y) Z = 8.8(a+b)2/(c)-0.5+2(a)/(q+r)/(a+b)*(1/m) X = -(b)+(b*b)+2(4)(a*c)/2(a) R = 2(v)+6.22(c+d)/(g+v) A = 7.7(b)[(x*y)+a]/c-0.8+2(b)/(x+a)*(1/y)
  • 5. Problem Set for Sequential StructureProgramming Assignment /*Trace out the output (A)*/ Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { int i=2,j=3,k,l; float a,b; k=i/j*j; l=j/i*i; a=i/j*j; b=j/i*i; cout<<k<<l<<a<<b; getch(); return 0; } /*Trace out the output (B)*/ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { int a,b; a=(-3)-(-3); b=(-3)+(-3); cout<<"a="<<a<<"b="<<b; getch(); return 0; }
  • 6. Problem Set for Sequential StructureProgramming Assignment /*Trace out the output (c)*/ Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { cout<<"nnnn nnn"; printf( "nn/n/nnn/n"); getch(); return 0; } /*Trace out the output (D)*/ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { int p,q; cout<<"Enter Values of p and q"; cin>>p>>q; cout<<"p="<<p<<"tq="<<q; getch(); return 0; } Write a C++ program for the following /* (a) Rameez's basic salary is input through the keyboard. His dearness allowance is 40% of basic salaryand house rent allowance is 20% of basic salary.Write a program to calculate his gross salary.*/ # include<iostream> # include<stdio.h>
  • 7. Problem Set for Sequential StructureProgramming Assignment Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 # include<conio.h> using namespace std; int main() { float bs=0,da=0,hr=0,gs=0; cout<<" Enter Rameez's basic salary : "; cin>>bs; da=bs*40/100; hr=bs*20/100; gs=da; /*cout<<"n Basic salary : "; cout<<bs; cout<<"n Deaness allowance : "; cout<<da; cout<<"n House rent allowance : "; cout<<hr;*/ cout<<"n Gross salary : "; cout<<gs; getch(); return 0; } /*(b) The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inches and centimeters. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float km=0,m=0,f=0,i=0,cm=0; cout<<" Enter Kilometers : "; cin>>km; m=km*1000; f=km*3280.83989501; i=km*39370.1; cm=km*100000; cout<<"n Meters : "; cout<<m; cout<<"n Feets : "; cout<<f; cout<<"n Inches : ";
  • 8. Problem Set for Sequential StructureProgramming Assignment Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 cout<<i; cout<<"n Centimeters : "; cout<<cm; getch(); return 0; } /*(c) If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student.Assume that the maximum marks that can be obtained by a student in each subject is 100. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float che,phy,bio,eng,com,total=500,sum,agg=0,per=0; cout<<"n Chemistry : "; cin>>che; cout<<"n Physics : "; cin>>phy; cout<<"n Biology : "; cin>>bio; cout<<"n English : "; cin>>eng; cout<<"n Computer : "; cin>>com; sum=che+phy+bio+eng+com; agg=(sum/total)*100; cout<<"n Aggregate Marks : "; cout<<agg; per=(sum*100)/total; cout<<"n Percentage : "; cout<<per; getch(); return 0;
  • 9. Problem Set for Sequential StructureProgramming Assignment Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 } /*(d) Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees. Tc = (5/9)*(Tf-32); */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float tf=0,tc=0,Div; cout<<"Enter Fahrehrit degrees : "; cin>>tf; Div=0.5555555555555556; tc=Div*(tf-32); cout<<"Centigrade degrees: "; cout<<tc; getch(); return 0; } /*(e) The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() {
  • 10. Problem Set for Sequential StructureProgramming Assignment float len1=0,bre1=0,rad=0,rec1=0,area1=0,per1=0,area2=0,cir=0; cout<<" Enter lenght of rectangle : "; cin>>len1; cout<<" Enter breadth of rectangle : "; cin>>bre1; cout<<" Enter radius of circle : "; cin>>rad; area1=len1*bre1; per1=2*(len1+bre1); cout<<"n Area of rectangle : "; cout<<area1; cout<<"n Perimeter of rectangle : "; cout<<per1; area2=3.14159265*(rad*rad); cir=6.2831853*rad; cout<<"n Area of circle : "; cout<<bre1; cout<<"n Circumference of circle : "; cout<<cir; getch(); return 0; Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 } /*(f) Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float loc1=0,loc2=0,x=0; cout<<" Enter location C number : "; cin>>loc1; cout<<" Enter location D number : "; cin>>loc2; x=loc1; loc1=loc2; loc2=x;
  • 11. Problem Set for Sequential StructureProgramming Assignment Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 cout<<"n Value of C locatio : "; cout<<loc1; cout<<"n Value of D Location : "; cout<<loc2; getch(); return 0; } /*(g) If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits.*/ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float a=0,b=0,c=0,d=0,e=0,sum=0; cout<<" Enter 1st digit of a number : "; cin>>a,b,c,d,e; cout<<" Enter 2nd digit of a number : "; cin>>b; cout<<" Enter 3rd digit of a number : "; cin>>c; cout<<" Enter 4th digit of a number : "; cin>>d; cout<<" Enter 5th digit of a number : "; cin>>e; sum=a+b+c+d+e; cout<<"n Sum : "; cout<<sum; getch(); return 0; } /*(h) If a five-digit number is input through the keyboard, write a program to reverse the number. */
  • 12. Problem Set for Sequential StructureProgramming Assignment Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float a=0,b=0,c=0,d=0,e=0; cout<<" Enter 1st digit number : "; cin>>a; cout<<" Enter 2nd digit number : "; cin>>b; cout<<" Enter 3rd digit number : "; cin>>c; cout<<" Enter 4th digit number : "; cin>>d; cout<<" Enter 5th digit number : "; cin>>e; cout<<"n 1st digit number : "; cout<<e; cout<<"n 2nd digit number : "; cout<<d; cout<<"n 3rd digit number : "; cout<<c; cout<<"n 4th digit number : "; cout<<b; cout<<"n 5th digit number : "; cout<<a; getch(); return 0; } /*(i) If a four-digit number is input through the keyboard, write a program to obtain the sum of the first and last digit of this number. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main()
  • 13. Problem Set for Sequential StructureProgramming Assignment Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 { float a=0,b=0,c=0,d=0,e=0,sum=0; cout<<" Enter 1st digit of a number : "; cin>>a; cout<<" Enter 2nd digit of a number : "; cin>>b; cout<<" Enter 3rd digit of a number : "; cin>>c; cout<<" Enter 4th digit of a number : "; cin>>d; cout<<" Enter 5th digit of a number : "; cin>>e; sum=a+e; cout<<"n Sum : "; cout<<sum; getch(); return 0; } /*(j) In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of the total population, write a program to find the total number of illiterate men and women if the population of the town is 80,000. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float tm,im,iw,tp=80000; cout<<" Total popuation in Town : "; cout<<tp; tm=(52.0/100.0)*tp; im=tm-iw; cout<<"n Total number of illeriate men : "; cout<<im; iw=tp-tm; cout<<"n Total number of illeriate women : "; cout<<iw; getch();
  • 14. Problem Set for Sequential StructureProgramming Assignment Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 return 0; } /*(k)A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn isinput through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier will have to give to the withdrawer. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float a=0,b=0,c=0,x=0; cout<<" Amount : "; cin>>x; a=x/10; cout<<"n Currency notes of 10 : "; cout<<a; b=x/50; cout<<"n Currency notes of 50 : "; cout<<b; c=x/100; cout<<"n Currency notes of 100 : "; cout<<c; getch(); return 0; } /*(l) If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one item. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() {
  • 15. Problem Set for Sequential StructureProgramming Assignment float sp=0,tp=0,cp=0; cout<<" Total selling price : "; cin>>sp; cout<<"n Total Profit Earned : "; cin>>tp; cp=(sp+tp)/15; cout<<"n Cost price of one item : "; cout<<cp; getch(); return 0; Junaid Ahmed (BS-SE)1st semester Roll No: F14-030 } /*(m) If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. */ # include<iostream> # include<stdio.h> # include<conio.h> using namespace std; int main() { float dig=0,x=0,y=0; cout<<" Enter digits : "; cin>>dig; y=11111; x=y+dig; cout<<"n Output : "; cout<<x; getch(); return 0; }