Question: Write a Program that prompts user to input three Numbers. The program should then output the Entered numbers are Ascending Order, Descending Order or Random Order.
Sample Output:
Enter 1st Number: 5
Enter 2nd Number: 4
Enter 3rd Number: 0
Entered Numbers are in Descending Order...
Continue... (y/n): n
***** PROGRAM TERMINATE *****
Question: Write a program that prompts the user to input an integer between 0 and 25. If user enters 0 then Display A, if user enters 1 then Display B, if user enter 2 then Display C and so On... Don’t use more than 5 if else statements otherwise you will get 0 makrs.
Sample Output:
Enter a Number: 5
5 = F
Continue... (y/n): y
Enter a Number: 60
Invalid Number! Please try again
Enter a Number: 25
25 = Z
Continue... (y/n): n
***** PROGRAM TERMINATE *****
Question: Write a program that will take the input values of three side of triangle and display either this triangle is Right Triangle or not.
Sample Output:
Enter the 1st side value: 23
Enter the 2nd side value: 80
Enter the 3rd side value: 77
Not a Right Triangle
Question: The Cost of International call from Pakistan to Saudi-Arabia is 25.75 Rs. (per min) for first 2 minutes, 15.40 Rs. (per min) for next 3 minutes, 10.99 Rs. (per min) for next for each edition minutes. Write a program that prompts user to input the call time in seconds and display the total charges. (Format your output with two decimal places).
Sample Output:
Enter the call time in Seconds: 26
Total Charges = 5.57
Question:: Write a program that will input the value of a, b and c then it will display the result of Quadratic Equation.
Sample Output:
Enter the value of a: 2
Enter the value of b: 4
Enter the value of c: 2
Answer = -2
Question : Write a program that prompts the user to input the x-y coordinate of a point in a Cartesian plane, the program should then output a message indicating whether the point is origin, is located on the x (or () axis or appears in a particular quadrant.
Sample Output:
Enter value on x: 0
Enter value on y: 0
Result = (0,0) is the origin
Continue... (y/n): y
Enter value on x: 4
Enter value on y: 0
Result = (0,0) in on the x-axis
Continue... (y/n): y
Enter value on x: 0
Enter value on y: -3
Result = (0,0) is on the y-axis
Continue... (y/n): y
Enter value on x: -2
Enter value on y: 3
Result = (0,0) is in the second quadrant
Continue... (y/n): n
***** PROGRAM TERMINATE *****
Question : Write a program that mimics a Calculator. The program should take as input two decimal values and operator to be performed. It should then output the numbers, the operator, and result.
Your Program should Support the following Operators
+ Addition 2+3 = 5
- Subtraction 2-3 = -1
x Multiplication 2x3 = 6
/ Division 2/3 = 0.66
^ Power 2^3 = 23 = 8
Sample Output:
Enter a [Decimal Number] [Operator] [Decimal Number]: 5.2 + 6.1
Solution
5.2 + 6.1 = 11.3
Continue... (y/n): n
***** PROGRAM TERMINATE *****
Question : Write a program that prompts the user to input a decimal number and output the number rounded to the nearest integers
Sample Output:
Enter a Decimal Number: 2.3
Rounded to : 2
Enter a Decimal Number: 7.9
Rounded to : 8
Question : A palindrome is a number or a text phrase that reads the same backwards as forwards, For Example, each of the following five digit number is a palindrome 12321, 55555, 45554, 11611. Write a program that reads in a five digit integer and determines whether it is a palindrome or not? (Hint: Use Modulus and Division operator to separate the numbers)
Sample Output:
Enter a Five Digit Number 22521
This Number is not a Palindrome
Enter a Five Digit Number 56465
This Number is Palindrome
Question : Write a Program that will take Input a String and Then Display each Character on Separate Line.
Sample Output:
Enter a String: Hello World
H
e
l
l
........ And So on
Question: Write a Program that will get the a Single Character and Tell either it is Vowel or Not using SWITCH Statement (Your Program should Support the upper and Lower Case)
Sample Output:
Enter a Character: e
It’s a Vowel
Continue... (y/n): y
Enter a Character: E
It’s a Vowel
Continue... (y/n): n
***** PROGRAM TERMINATE *****
Question : Write a temperature-conversion program that gives the user the option of converting Fahrenheit to Celsius or Celsius to Fahrenheit. Output should be in Decimal .Using SWITCH Statement.
Sample Output:
Press 1 for Convert Fahrenheit to Celsius
Press 2 for Convert Celsius to Fahrenheit
Press 3 for Exit Program
Enter your Choice: 1
Enter Temperature in Fahrenheit: 70
70 Fahrenheit in Celsius = 21.111111
Question : Create the equivalent of a four-function calculator. The program should request the user to enter a number, an operator, and another number. (Use floating point.) It should then carry out the specified arithmetical operation: adding, subtracting, multiplying, or dividing the two numbers. Use a switch statement to select the operation. Finally, display the result.
When it finishes the calculation, the program should ask if the user wants to do another calculation. The response can be ‘y’ or ‘n’. Using SWITCH Statement.
Sample Output:
Enter first number, operator, second number: 10/3
Answer = 3.333333
Do another (y/n)? y
Enter first number, operator, second number: 12+100
Answer = 112
Do another (y/n)? n
*****PROGRAM TERMINATE*****
Question: Write a Program using that prompts the user to input your Name and Display it 10 times.
Sample Output:
Enter your Name: Abc Xyz
Abc Xyz
Abc Xyz
....... And So on
Question : Write a program that will get first name and last name of the user and print the first name and last name character by character and after each character the user must enter any key for the next character.
Sample Output:
Enter your First Name: Abc
Enter your Last Name: Xyz
A
b
....... And So on
Question : Write a program that will get a number from the user and prints its factorial (Using for Loop).
Sample Output:
Enter a Number: 5
5x4x3x2x1=120
Question : Write a program that will get any value from the user and print the table of that value from 1 – 10 (using for Loop).
Sample Output:
Enter a Number for table Display: 5
5 x 1 = 5
5 x 2 = 10
....... And So on
Question : Write a program that will get a base number 'x' from user and its power and then calculate the power of the base. (Using for loop).
Sample Output:
Enter the Base Number: 5
Enter the Power: 3
Answer = 125
Question : Write a program that will get a number from the user and print the multiples of the given number formatting it into 10 columns and 10 rows.
Sample Output:
Enter a Number: 5
5555555555
5555555555
....... And So on
Question : Use for loops to construct a program that displays a pyramid of Xs on the screen. Except that it should be 20 lines high, instead of the 5 lines shown here. One way to do this is to nest two inner loops, one to print spaces and one to print Xs, inside an outer loop that steps down the screen from line to line.
Sample Output:
X
XXX
XXXXX
XXXXXXX
XXXXXXXXX
....... And So on
Question : Write Fibonacci sequence program. Take input from user then print the Fibonacci sequence to 10 Steps.
Sample Output:
Enter a Number for Print the Fibonacci Series: 2
2, 2, 4, 6, 10, 16, 26, 42, 68, 110
Question : Write Prime Number sequence program. Your Program should Display the first 10 Prime Number.
Sample Output:
1, 3, 5, 7, 11, 13, 17....... And So on
Question: Write a program that will get a number from the user and then print the factorial if the user entered number is even then divide factorial by 2, if odd then divide factorial by 3, and if factorial is out of the range of integer (2 bytes) then show message that "OUT OF RANGE."?
Note: Write this program 3 times. Using For Loop, While Loop and Do-While Loop.
Sample Output:
Enter a Number: 8
Factorial 8x7x6x5x4x3x2x1 = 40320
The Entered Number is Even, Due to this your Answer Divided by 2 = 20160
Question : Write Fibonacci sequence program. Take start and end of series from user. After Displaying series ask user do u want to generate another series, if yes then generate another series. Perform this task till user says no.
Note: Write this program 3 times. Using For Loop, While Loop and Do-While Loop.
Sample Output:
Enter start of series : 5
Enter end of series : 15
Series is:
5, 5, 10, 15
Do u want to generate another series (y/n): y
Enter start of series : 1
Enter end of series : 5
Series is:
1, 1, 2, 3, 5
Do u want to generate another series: n
*****PROGRAM TERMINATES*****
Question : Write Prime Number Series program. Take start and end of series from user. After Displaying series ask user do u want to generate another series, if yes then generate another series. Perform this task till user says no.
Note: Write this program 3 times. Using For Loop, While Loop and Do-While Loop.
Sample Output:
Enter start of series: 1
Enter end of series : 10
Series is:
1, 3, 5, 7
Do u want to generate another series (y/n): y
Enter start of series : 5
Enter end of series : 20
Series is:
5, 7, 11, 13, 17
Do u want to generate another series: n
*****PROGRAM TERMINATES*****
Question : Write a program that accepts numbers from the user and computes their sum. The numbers should be entered one at a time and the output of all the numbers entered thus far should then be displayed. The program should halt when the user enters the number 0.
Note: Write this program 1 time. Using any one Loop according to your choice.
Sample Output:
Enter a number: 10
Cumulative Sum = 10
Enter a number: 12
Cumulative Sum = 22
Enter a number: 5
Cumulative Sum = 27
Enter a number: 3
Cumulative Sum = 30
Enter a number: 0
Cumulative Sum = 30
Thank you for using this program.
***** PROGRAM TERMINATE *****
Question: Write the following function and implement these functions in a sample program. (Don’t use any built-in Library)
int add(int, int)
// this function will get two numbers as parameters and return their result as sum
int sub(int, int)
// this function will get two numbers as parameters and return their result as subtraction
int mul(int, int)
// this function will get two numbers as parameters and return their result as multiplication
int div(int, int)
// this function will get two numbers as parameters and return their result as division
int pow(int, int)
// this function will get two numbers base and power as parameters
int max(int, int)
// this function will get three numbers as parameters and return the maximum number
int min(int, int)
// this function will get three numbers as parameters and return the minimum number
void fibonacci(int, int)
// function take two number start and end of series as a parameter and display the Fibonacci series between these Numbers.
void prime(int, int)
// function take two number start and end of series as a parameter and display the all prime number between them.
int isEqual(int, int)
// function take two number and check either both numbers are equal or not. If both numbers are equal then return 1 otherwise return 0;
Question : Write the following function and implement these functions in a sample program. (Don’t use built-in Library)
float FahrenheitToCentigrade(float)
// function that Convert the Temperature Fahrenheit to Centigrade
// and return the result
float CentigradeToFahrenheit(float)
// function that Convert the Temperature Centigrade to Fahrenheit
// and return the result
Question : Write the following function and implement these functions in a sample program. (Don’t use built-in Library)
char grade(int)
// function will get the total marks and return the grade
int isVowel(char)
// function will get the character and return 1 if that character is
// a vowel otherwise return 0
Question: Write the following function and implement these functions in a sample program. (Don’t use built-in Library).
void std(char* name, int id, char* major)
// this function will get student name, student id and student major
// and print the all data on console
Question : Write the following function and implement these functions in a sample program. (Don’t use built-in Library)
int* sort(int*, int)
// function will take an integer array and its size,
// then it will sort this array and return it
int math(int num1, char op, int num2)
// this function will take two number and one operator as parameter
// and then return the result
char* sort(char*)
// function get a character array then sort this array and return it
Question : Write the following function and implement these functions in a sample program. (Don’t use built-in Library)
char*number(int)
// function that will take number as parameter and print its pronunciation (1 - 100). The number 85 is pronounced "eighty-five," not "eight five." For example, 13 would be "thirteen" and 100 would be "one hundred."(Do with Minimum Number of statements to get Extra Credit, if control statements are more than 50 then zero marks will be given)
Question: Write the following function and implement these functions in a sample program. (Don’t use built-in Library)
Void Strcpy(char*str1, char*str2)
// this function will copy the “str1” to” str2”
Char*Strcat(char*str1,char*str2)
// this function will concatenate “str1” and” str2” and return the new string
Int Strcmp(char*str1, char*str2)
// this function will compare both string (IGNORE CASE). If both are equal then return 1 otherwise 0
Int Strcmpi(char*str1, char*str2)
// this function will compare both string (DON’T IGNORE CASE). If both are equal then return 1 otherwise 0
Char*Strstr(char*str, int start, int end)
// function will return the “str” part from “start” index to “end” index
Char*Strrev(char *str)
// function will make reverse the “str” String and return it
Char*Strtok(char*str,char ch)
// function will split the “str” string from “ch” character and convert it into char* Array and return it
Int Strlen(Char*str)
// function will return the length of “str” String
Int StrStart(char*str,char*start)
// function check if the “str” string will start with “start” string then it will return 1 otherwise return 0
Int StrEnd(char*str,char*end)
// function check if the “str” End will start with “end” string then it will return 1 otherwise return 0
Int StrFind(char*str,char*f)
// function find the String “f” in String “str”. If string is found then it will return 1 otherwise 0
Int CharFind(char*str,char f)
// function find the character “f” in string “str”, If character is found then return 1 otherwise 0
Question: Write a program that will input two arrays of 10-10 integers and show the Sum, subtraction and product of numbers and also divide and get remainder of only two largest numbers.
Sample Output:
Enter 1st Number for Array A: 6
Enter 2nd Number for Array A: 9
....... And So on
Enter 1st Number for Array B: 4
Enter 2nd Number for Array B: 12
....... And So on
Addition of 1st Number from Array A & B = 10
Addition of 2nd Number from Array A & B = 21
....... And So on
Question : Write a program which will get a character array from user and search any character from that array.
Sample Output:
Enter a Character Array: islamabad
Enter the Character that you want to search: s
Character “s” found at 2 index
Question : Write a program that will get a character array from user and sort the array according to the alphabetic order. (Remember that 'a' is greater than 'A’)
Sample Output:
Enter a Character Array: Pakistan
Array in Sorting Order: aaiknstP
Question : Write a program that will get a character array from user and then swap only the values of array of first and last index.
Sample Output:
Enter a Character Array: Hello
After first and Last index Swap: oellH
Question : Write a program that will get an integer type array from user and show the number of even and odd numbers entered in array.
Sample Output:
Enter 1st Number:6
Enter 2nd Number:3
Enter 3rd Number:4
....... And So on
Total Even Number in Array = 6
Total Odd Number in Array = 4
Question : Write a program that will get a character type array and copy the array into another array and show the second array.
Sample Output:
Enter an Array: Hello
Your Entered Array: Hello
Question : Write a program that will take a string from user and change case of the string (Do Not Use Built In Function).
Sample Output:
Enter string: AbCacsA135fhG
Result: aBcACSa135FHg
Do u want to continue (y/n): n
*****PROGRAM TERMINATE*****
Question : Write a Program that will input an integer Array and sort that integers array in ascending and descending order using for loop, do while and while Loop Separately.
Sample Output:
Enter 1st Element in Integer Array: 5
Enter 2nd Element in Integer Array: 2
Enter 3rd Element in Integer Array: 15
Using For Loop
2
5
15
....... And So on
Question : Write a Program that prompts the user to input a Decimal Number and Print its Reverse.
Sample Output:
Enter a Decimal Number: 456.221
Reverse of 456.221 is = 122.654
Question: Write Program that will Declare dynamically 2D Array and Copy that Array Element to Another 2D Array (Both Array should be Declared dynamically and Array Size and Array Element will be input from user).
Sample Output:
Enter the 2D Size of Array [Rows][Space][Column]: 6 4
Enter 1st Element in 2D Array At index[0][0] : 5
Enter 2nd Element in 2D Array At index[0][1] : 2
Enter 3rd Element in 2D Array At index[0][2] : 15
All Elements in Array:
0 1 2 3
0 5 2 15 8
1 6 4 2 1
2 9 8 9 4
....... And So on
Question : Write Program that will Declare dynamically 3D Array and Copy that Array Element to Another 3D Array (Both Array should be Declared dynamically and Array Size and Array Element will be input from user).
Sample Output:
Enter the 2D Size of Array [X][Space][y][Space][Z]: 2 2 3
Enter 1st Element in 3D Array At index[0][0][0] : 7
Enter 2nd Element in 3D Array At index[0][0][1] : 3
Enter 3rd Element in 3D Array At index[0][0][2] : 1
All Elements in Array:
Value at [0][0][0] index = 7
Value at [0][0][1] index = 3
....... And So on
Question : Write a Program that will declare two Matrices dynamically and (Metrics Size and Value Input from user) Display the Menu for following Operation.
Addition of both Matrices
Subtraction of Both Matrices
Multiplication of Both Matrices
Note: if the Number of Rows in 1st Matrices is not Equal to the Number of Column 2nd Matrices then It should Display the Error … Multiplication is not possible. And If the Number of Row and Column of Both Matrics are not Equal then It should be display the error … Addition and Subtraction is not Possible
Your Program should be handle all error
Sample Output:
Enter the Rows and Column of 1st Matrices: 2 3
Enter the Rows and Column of 2nd Matrices: 4 6
***** MENU *****
Press 1 for Addition of both Matrices
Press 2 for Subtraction of both Matrices
Press 3 for Multiplication of both Matrices
Enter your choice: 3
Multiplication is not Possible
Reason: the Number of Rows in 1st Matrix is not Equal to the Number of Column in 2nd Matrix
Continue... (y/n): n
***** PROGRAM TERMINATE *****
Question: Use following functions Built-in function of string.h in your programs and briefly describe each function in your own words.
Strcpy()
Strcat()
Strcmp()
Strcmpi()
Strlwr()
Strncpy()
Strncmp()
Strncmpi()
Strncat()
Strstr()
Strbrk()
Strrev()
Strtok()
Question : Write a function strend(s,t) with pointers which returns 1 if the string t occurs at the end of string s otherwise a zero (Don’t use any build-in function).
Question : Initialize an array of pointers pointing towards character with {Lahore , Karachi, Islamabad} Now take input from the user and show how many time these words appeared in the input string.
Question: Write a program that will input the student information (first name, last name, email, age... etc) and write it on file “student.txt"
Question : Write a program that will read your name from file “read.txt” and write it on “write.txt”
Question : Write a program that will read a sample source program from “code.cpp” file and display how many key words are used in this program. Display result on Console.
Question : Write a program that will read the series of number (numbers will be separated by Single Comma “,” Example: 5,3,65,21,3) from a file and add numbers and display the result on Console.
Question : Write a program that will read a sample C++ source program from file “withComments.cpp” and remove all (ONLY MULTIPLE LINE /**/) comments in this code and then save it with the name “withoutComments.cpp”.
BEST OF LUCK
Regards: HASEEB MUGHAL
{[['
']]}

0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.