0% found this document useful (0 votes)
80 views5 pages

ASSIGNMENT PF Lab 01

The document contains an assignment for a programming fundamentals lab, which includes 4 questions asking the student to write C++ programs to swap numbers with and without a temporary variable, check if a character is a vowel or consonant, perform division and find the quotient and remainder of two integers, and calculate the length of an arc of a convex lens using the radius and angle. The student is asked to provide the code and answers for each question.

Uploaded by

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

ASSIGNMENT PF Lab 01

The document contains an assignment for a programming fundamentals lab, which includes 4 questions asking the student to write C++ programs to swap numbers with and without a temporary variable, check if a character is a vowel or consonant, perform division and find the quotient and remainder of two integers, and calculate the length of an arc of a convex lens using the radius and angle. The student is asked to provide the code and answers for each question.

Uploaded by

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

ASSIGNMENT

PROGRAMMING FUNDAMENTALS -
LAB

FROM:
Muhammad Iltamas Riasat

ASSIGNED TO:
Mrs. Aqsa Sarfaraz

SECTION:
BS Software Engineering, Sec – B

ROLL NO:
065

DATE:
27th – Nov – 2023
Ques 01: Write a program which contain two different
techniques to swap numbers in C ++ programming. The first
program uses temporary variable to swap numbers, whereas
second program doesn’t use temporary variable?
Ans:
#include<iostream>
using namespace std;

int main()
{
int first_num, second_num, temp;
cout<<"Enter 1st Number=";
cin>>first_num;

cout<<"Enter 2nd Number=";


cin>>second_num;

temp=first_num;
first_num=second_num;
second_num=temp;

cout<<"After swapping two integers are: \n "<<"First


Number= "<<first_num<<"\nSecond Number= "<<second_num;
}
Ques 02: Write a program in C++ to Check Vowel or a Consonant
Manully?
Ans:
#include<iostream>
using namespace std;

int main()
{
char a;
cout<<"Enter any alphabet: ";
cin>>a;
if(a=='A' || a=='E' || a=='I' || a=='O' || a=='U' )
cout<<"It is a vowel";
else if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u' )
cout<<"It is a vowel";
else
cout<<"It is a consonant";
}
Ques 03: In this program, user in asked to enter two intergers
(divisor and dividend) and computed the quotient and
remainder?
Ans:
#include<iostream>
using namespace std;

int main()
{
int dividend, divisor, quotient, remainder;
cout<<"Enter the dividend=";
cin>>dividend;

cout<<"Enter the divisor=";


cin>>quotient;

quotient= dividend / divisor;


remainder=dividend % divisor;

cout<<" Quotient is= "<<quotient<<endl;


cout<<" Remainder is= "<<remainder;

return 0;
}
Ques 04: Write a C++ program that calculates the are of length of
a concave lens by taking radius of are and angle made by are
Formula (Length= radius x angle)?
Ans:
#include<iostream>
using namespace std;

int main ()
{
double radius, angle, length;

cout<<"Enter the radius: ";


cin>>radius;

cout<<"Enter the angle (in degrees): ";


cin>>angle;

length = radius * angle;


cout << "The arc length of the convex lens is: " << length<<
endl;

return 0;
}

You might also like