Loading repository data…
Loading repository data…
faizan-ahmad5 / repository
This repository contains 100+ C++ programs, ranging from basic to advanced topics. It covers fundamental concepts like loops, conditionals, and functions, progressing to more advanced topics such as arrays, pointers etc. Perfect for beginners to grasp C++ essentials and for advanced learners to explore more complex concepts.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
Welcome to the 100-plus-cpp-programs repository! This collection contains over 100 C++ programs, designed to cover a wide range of topics from basic concepts to more advanced techniques. Whether you're a beginner or an experienced programmer looking to enhance your skills, this repository offers valuable resources for learning and practice.
Display Information:
Write a C++ program that displays your name, department, and section on the console. Ensure that each detail appears on a new line using the escape sequence \n.
Favorite Personality Quote:
Write a C++ program that displays the name and quote of your favorite personality. Use the escape sequence \" to put the quote in double quotation marks. Example output:
Friedrich Nietzsche once said, "He who has a why to live can bear almost any how."
Print a Pattern:
Write a C++ program to print the following pattern using escape sequences:
************
**********
*****
**
Create a CV:
Make a CV that includes your Name, Father’s Name, CNIC, Qualification, Semester, CGPA, etc. Print each line separately using \n and endl. Use comments in your code.
Print a Diamond:
Print a diamond shape using escape sequences \n and \t in a single cout statement.
Square and Cube Table:
Write a program that displays the square and cube of a number in table form. Use escape sequences to format the output.
Arithmetic Operations:
Write a C++ program that takes two numbers and displays their addition, subtraction, division, multiplication, and squares on the console.
Average Age Calculation:
Calculate the average age of a class of five students. Prompt the user to enter the age of each student.
Circle Calculations:
Write a C++ program that takes the radius of a circle as input from the user and outputs the circumference and area. Ensure the output is clear and readable. Add proper comments to the code and set the value of π up to 3 decimal places.
Temperature Conversion:
Write a C++ program that takes temperature in Fahrenheit from the user and converts it to Celsius and Kelvin using the formulas:
Simple Interest Calculation:
Write a program to calculate simple interest for given values: ( P = 4000 ), ( T = 2 ), ( R = 5.5 ). Use the formula I = PTR / 100.
Size of Data Types:
Write a C++ program to find the size of various data types: int, short int, float, double, bool, and char. Use the sizeof operator.
Arithmetic Assignment Operations:
Take two integers as input from the user, apply arithmetic assignment operations on them, and print the results on the screen.
Polynomial Calculation:
Write a C++ program that takes values of a and b from the user and displays the result of the polynomial ( a^2 + 2ab + b^2 ).
Complex Number Addition:
Write a C++ program that takes two complex numbers from the user and adds them. Print the resultant complex number.
Forward and Reversed Order:
Write a C++ program to prompt the user to input 3 integer values and print these values in forward and reversed order.
Integer and Character Display:
Write a C++ program that takes an integer value and a character from the user and displays both on the console window.
Sphere Calculations:
Write a program that takes the radius of a sphere as input from the user and outputs:
Time Conversion:
Write a C++ program that takes seconds from the user and displays the time in hours, minutes, and seconds format. For example, if the user enters 3700, the output should be "1 hour 1 minute and 40 seconds."
Variable Swapping:
Write a C++ program to swap the values of two variables both with and without using a third variable.
String Copy:
Write a C++ program to enter a string s1 and copy it to another string s2.
Polynomial Evaluation:
Write a program that asks the user to enter a value for x and then displays the value of the polynomial (2x^5 + 3x^4 - x^3 - 2x^2 + 7x - 6). To calculate (x^5), use pow(x, 5). Include the math.h library for pow.
Quotient and Remainder:
Write a C++ program to find the quotient and remainder of two integers by taking input from the user.
Previous Character:
Write a C++ program that takes a character and displays its previous character using the decrement operator.
Complex Calculation:
Write a program that asks for a number input from the keyboard, adds 34 to it, divides it by 2, takes the modulus with 4, adds 4, and then multiplies the resultant value by 5. Display the result.
Expression Calculation:
Write a program in C++ to compute the expression (25 * 3.5 - 3 * 7.5) + 3 / (40.5 - 4.5) and print the output.
String Operations:
Write a C++ program that prompts the user to enter two strings, then displays the strings, their lengths, their concatenation, and specific characters from each string.
Fraction Operations:
Write a C++ program that prompts the user to enter two fractions (numerator and denominator for each), then calculates and displays their sum, difference, product, and division.
Distance Calculation:
Write a C++ program to calculate the distance between two points where (x1), (y1), (x2), and (y2) are all double values.
Age Check (if statements only):
Write a C++ program that checks the age of Fahad and Khurram and displays the appropriate message using if statements only.
Age Check (nested if statements only):
Write a C++ program that checks the age of Fahad and Khurram and displays the appropriate message using nested if statements only.
Number Comparison:
Write a C++ program that takes an integer value from the user and checks if it’s greater than 10 and less than or equal to 20. Print 1 if yes and print 0 if no.
String Comparison:
Write a C++ program that takes two strings as input from the user and checks if both strings are equal.
Even or Odd:
Using if-else, determine whether a value is even or odd.
Greatest of Three Numbers:
Write a C++ program that prompts the user to input three integer values and find the greatest value of the three (hint: use logical operators).
Vowel or Consonant:
Write a C++ program to check whether an alphabet entered by the user is a vowel (lower and upper case) or a consonant (lower and upper case) using if-else statements (hint: use logical operators).
Temperature State:
Write a C++ program that prompts the user to input temperature in centigrade and display a message according to the temperature state below:
Grade Calculation:
Write a C++ program that takes quiz marks, midterm marks, and final term marks from the user and determines the student’s grade based on the following rules:
Maximum Number (Ternary Operator):
Write a C++ program that prompts the user to input two numbers and then determines the largest number using the ternary operator.
String Equality Check (Ternary Operator):
Write a C++ program that takes two strings as input from the user and checks if both strings are equal or not using the ternary operator.
Repeated Number Entry:
Write a C++ program that prompts the user to enter a number repeatedly until a non-positive number is entered.
Simple Calculator:
Write a C++ program to make a simple calculator using a switch case to perform addition, subtraction, multiplication, or division.
Sum of Numbers (Using For Loop):
Write a C++ program to calculate the sum of up to 10 numbers using a for loop. If the user enters a negative number, the loop terminates.
Sum of Numbers (Using For Loop, Skip Negatives):
Write a C++ program to calculate the sum of up to 10 numbers using a for loop. If the user enters a negative number, it should not be added to the result.
Area of Circle Function:
Write a function that calculates and returns the area of a circle. The radius should be a parameter of your function. Use appropriate data types.
Maximum of Two Numbers Function:
Write a function that takes two parameters, x and y, and returns the maximum of the two numbers.
Even Numbers Between Two Points:
Write a C++ program that takes two integers, i (starting point) and n (ending point), from the user and prints all even numbers between i and n using a while loop. For example, if i = 5 and n = 20, the output should be: 6 8 10 12 14 16 18 20.
Sum of Odd Natural Numbers:
Write a C++ program to calculate the sum of odd natural numbers (1 + 3 + 5 + 7 + … + n) using a while loop. Take n as input from the user.
Pyramid Pattern of Asterisks:
Write a C++ program that prints a pyramid pattern of asterisks. The pattern should have 5 rows, with the number of asterisks in each row increasing by 2 for each subsequent row, starting with 1 asterisk in the first row:
*
***
*****
*******
*********
Reverse Whole Numbers:
Write a C++ program to print whole numbers in reverse from n to 0 using a while loop.
Write a C++ program to display the days of two weeks using a nested for loop. The outer loop should represent the weeks (2 weeks), and the inner loop should represent the days (4 days per week).
Write a C++ program that takes an integer input from the user and checks if the number is even. If it is even, print "The number is even".
Write a C++ program that takes a character input from the user and checks if it is an uppercase letter. If it is, print "The character is uppercase".
Write a C++ program that takes an integer input from the user and checks if the number is divisible by 5. If it is divisible, print "The number is divisible by 5".
Write a C++ program that takes a character input from the user and checks if it is a vowel or consonant. Print "Vowel" if it is a vowel; otherwise, print "Consonant".
Write a C++ program that takes the age of a person as input and categorizes them into the following categories:
Write a C++ program that takes three float numbers as input and prints which number is the largest, the second largest, and the smallest.
Write a C++ program that takes an integer input from the user and prints whether the number is positive, negative, or zero using nested if statements.
Write a C++ program that takes the scores of three subjects from the user and determines if