0% found this document useful (0 votes)
4 views

Assignment-1

The document outlines an assignment consisting of five programming questions. The first question requires creating a menu-driven program for basic arithmetic operations using specific functions. Subsequent questions involve output prediction for given code snippets, character type checking, finding the largest of three numbers using a ternary operator, and converting a number of days into years, months, and days.

Uploaded by

sumoshravan35
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Assignment-1

The document outlines an assignment consisting of five programming questions. The first question requires creating a menu-driven program for basic arithmetic operations using specific functions. Subsequent questions involve output prediction for given code snippets, character type checking, finding the largest of three numbers using a ternary operator, and converting a number of days into years, months, and days.

Uploaded by

sumoshravan35
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment-1

Q.1. Write a program that lets the user perform arithmetic operations on two numbers.
Your program must be menu driven, allowing the user to select the operation (+, -, *, or
/) and input the numbers. Furthermore, your program must consist of following
functions:

1) Function showChoice: This function shows the options to the user and explains how to
enterdata.
2) Function add: This function accepts two number as arguments and returns sum.
3)Function subtract: This function accepts two number as arguments and returns their
difference.
4) Function multiply: This function accepts two number as arguments and returns product.
5) Function divide: This function accepts two number as arguments and returns quotient.

Q.2 What is the output of following program?


a)float net = 5689.2356;
cout.precision(2);
cout.setf(ios::fixed | ios::showpoint);
cout << net << endl;
b) int x = 10, y;
y = x++;
cout << y;

c) int x = 10;
cout << ++x;
d) int x = 10, y;
y = x++;
cout << x;

Q.3 Write a program to check character entered is alphabet, digit or special character
using library functions.
Q.4 Write a program which input three numbers and display the largest number using
ternary operator.

Q.5 Write a program which accepts days as integer and display total number of years,
months and days in it. for example: If user input as 856 days the output should be 2 years
4 months 6 days.

You might also like