arrow
arrow

Making_Decisions

Check number is even or odd


                            
                                #include <iostream>
                                using namespace std;
                                int main()
                                {  int num = 0;
                                    cout << "Enter the number:" << endl;
                                    cin >> num;
                                    if (num % 2 == 0)
                                    {cout << "It is an even number:" << endl;}
                                    else{ cout << "It is an odd number:" << endl;}
                                    return 0;}
                            
                        

To learn about the DECISIONS and if/else_if


Get Slides in which all concepts cover thoroughly


--------------------------------------------------------

Download PDF here

Write a program to find maximum between three numbers.


                        
                            /*MAXIMUM BETWEEN three NUMBERS*/
                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                            
                                int num1;
                                int num2;
                                int num3;
                                cout << "Enter the number 1:" << endl;
                                cin >> num1;
                                cout << "Enter the number 2:" << endl;
                                cin >> num2;
                                cout << "Enter the number 3:" << endl;
                                cin >> num3;
                                if (num1 > num2 && num1 > num3)
                                {
                                    cout << num1 << " is greater than " << num2 << " and " << num3 << endl;
                                }
                                else if (num2 > num1 && num2 > num3)
                                {
                                    cout << num2 << " is greater than " << num1 << " and " << num3 << endl;
                                }
                                else
                                {
                                    cout << num3 << " is greater than " << num1 << " and " << num2 << endl;
                                }
                                return 0;
                            }
                        
                    

Write a program to check whether a number is negative, positive or zero


                        
                            // Check Number is positive or negative or zero
                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                            
                                int num;
                                cout << "Enter the number :" << endl;
                                cin >> num;
                                if (num > 0)
                                {
                                    cout << "It is a positive number:" << endl;
                                }
                                else if (num < 0)
                                {
                                    cout << "It is negative number:" << endl;
                                }
                                else
                                {
                                    cout << "It is a zero:" << endl;
                                }
                            
                                return 0;
                            }
                        
                    

Write a program to check whether a year is leap year or not


                        
                            // Check year is a leap year or not
                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                            
                                int year;
                                cout << "Enter the year:" << endl;
                                cin >> year;
                                if (year % 4 == 0)
                                {
                                    cout << "It is a leap year:" << endl;
                                }
                                else
                                {
                                    cout << "It is not a leap year:" << endl;
                                }
                            
                                return 0;
                            }
                        
                    

Write a program to check whether a character is alphabet or not


                        
                            // Character is alphabat or not
                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                            
                                char ch;
                                cout << "Enter the character:" << endl;
                                cin >> ch;
                                // Range of small letters ASCII==(97-122)
                                // Range of Capital letters ASCII==(65-90)
                                if ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122))
                                {
                                    cout << "It is a character. It is \"" << ch << "\"." << endl;
                                }
                                else
                                {
                                    cout << "It is not a character:" << endl;
                                }
                            
                                return 0;
                            }
                        
                    

Write a program to input any alphabet and check whether it is vowel or consonant.


                        
                            // Vowel or constant check
                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                            
                                char ch;
                                cout << "Enter the letter a to z:" << endl;
                                cin >> ch;
                                if ((ch == 'a' || ch == 'A') || (ch == 'e' || ch == 'E') || (ch == 'i' || ch == 'I') || (ch == 'o' || ch == 'O') || (ch == 'U' || ch == 'u'))
                                {
                                    cout << "It is vowel as \"" << ch << "\"." << endl;
                                }
                                else
                                {
                                    cout << "It is a consonanat:" << endl;
                                }
                            
                                return 0;
                            }
                        
                    

Write a program to input any character and check whether it is alphabet, digit or special character.


                        
                            // digit ,letter and special letter detecter
                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                                char ch;
                                cout << "Enter the any letter ,number and special character:" << endl;
                                cin >> ch;
                                // Range of small letters ASCII==(97-122)
                                // Range of Capital letters ASCII==(65-90)
                                // Range of NUmbers ASCII==(48-57)
                                // Other than these range are all special characters range
                                if ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122))
                                {
                                    cout << "It is an letter as \"" << ch << "\" with an ascii value of " << static_cast<int>(ch) << "." << endl;
                                }
                                else if (ch >= 48 && ch <= 57)
                                {
                                    cout << "It is an number as \"" << ch << "\" with an ascii value of " << static_cast<int>(ch) << "." << endl;
                                }
                                else
                                {
                                    cout << "It is an special character as \"" << ch << "\" with an ascii value of " << static_cast<int>(ch) << "." << endl;
                                }
                            
                                return 0;
                            }
                        
                    

Write a program to check whether a character is uppercase or lowercase alphabet


                        
                            // Uppercase or lower case check
                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                            
                                char ch;
                                cout << "Enter the letter :" << endl;
                                cin >> ch;
                                if (ch >= 65 and ch <= 90)
                                {
                                    cout << "It is an uppercase letter:" << endl;
                                }
                                else if (ch >= 97 and ch <= 122)
                                {
                                    cout << "It is an lowercase lettter:" << endl;
                                }
                            
                                return 0;
                            }
                        
                    

Write a program to input month number and print number of days in that month


                        
                            /*Days given by month*/
                            #include <iostream>
                            #include <string>
                            using namespace std;
                            int main()
                            {
                                string month;
                                int year;
                                cout << "Enter the name of month" << endl;
                                cin >> month;
                                if (month == "februray" || month == "Februray" || month == "FEBRURAY")
                                {
                                    cout << "Enter the year to check it is leap yaer or not:" << endl;
                                    cin >> year;
                                    if (year % 4 == 0)
                                    {
                                        cout << "It is a leap year and it conatines 29 days in Februray:" << endl;
                                    }
                                    else
                                    {
                                        cout << "It is not a leap year so it conatines 28 days in February" << endl;
                                    }
                                }
                                else
                                {
                                    if (month == "januray" || month == "Januray" || month == "JANURAY")
                                    {
                                        cout << "Januray conatines 31 days:" << endl;
                                    }
                                    if (month == "march" || month == "March" || month == "MARCH")
                                    {
                                        cout << "MARCH conatines 31 days:" << endl;
                                    }
                                    if (month == "April" || month == "april" || month == "APRIL")
                                    {
                                        cout << "April conatines 30 days:" << endl;
                                    }
                                    if (month == "May" || month == "may" || month == "MAY")
                                    {
                                        cout << "May conatines 31 days:" << endl;
                                    }
                                    if (month == "june" || month == "June" || month == "JUNE")
                                    {
                                        cout << "June conatines 30 days:" << endl;
                                    }
                                    if (month == "July" || month == "july" || month == "JULY")
                                    {
                                        cout << "July conatines 31 days:" << endl;
                                    }
                                    if (month == "August" || month == "august" || month == "AUGUST")
                                    {
                                        cout << "August conatines 30 days:" << endl;
                                    }
                                    if (month == "September" || month == "september" || month == "SEPTEMBER")
                                    {
                                        cout << "September conatines 30 days:" << endl;
                                    }
                                    if (month == "October" || month == "october" || month == "OCTOBER")
                                    {
                                        cout << "October conatines 31 days:" << endl;
                                    }
                                    if (month == "November" || month == "november" || month == "NOVEMBER")
                                    {
                                        cout << "November conatines 30 days:" << endl;
                                    }
                                    if (month == "December" || month == "december" || month == "DECEMBER")
                                    {
                                        cout << "December conatines 31 days:" << endl;
                                    }
                                }
                                return 0;
                            }
                        
                    

Write a program to input angles of a triangle and check whether triangle is valid or not


                        
                            // triangle is valid or not
                            #include <iostream>
                            #include <iomanip>
                            using namespace std;
                            int main()
                            {
                                float angle1;
                                float angle2;
                                float angle3;
                                float sum = 0;
                                cout << "Enter the angle 01 of the triangle:" << endl;
                                cin >> angle1;
                                cout << "Enter the angle 02 of the triangle:" << endl;
                                cin >> angle2;
                                cout << "Enter the angle 03 of the triangle:" << endl;
                                cin >> angle3;
                                cout << setprecision(2) << fixed;
                                sum = angle1 + angle2 + angle3;
                                if (sum == 180.00)
                                {
                                    cout << "This is a triangle:" << endl;
                                }
                                else
                                {
                                    cout << "This is not a triangle:" << endl;
                                }
                            
                                return 0;
                            }
                        
                    

Write a program to check whether the triangle is equilateral, isosceles or scalene triangle.


                        
                            //To check triangle is osscoles and equliteral andscalance
                            #include<iostream>
                            using namespace std;
                            int main()
                            {
                                
                                float side1;
                                float side2;
                                float side3;
                                bool flag=false;
                                cout<<"Enter the value of side1:"<<endl;
                                cin>>side1;
                                cout<<"Enter the value of side2:"<<endl;
                                cin>>side2;
                                cout<<"Enter the value of side3:"<<endl;
                                cin>>side3;
                                if(side1==side2 &&side2==side3)
                                {
                                    cout<<"It is an equiliteral triangle:"<<endl;
                                }
                                else if(side1==side2 ||side1==side3 ||side2==side3)
                                {
                                    cout<<"It is an isosolces triangle:"<<endl;
                                }
                                else 
                                {
                                    cout<<"It is an scalance triangle:"<<endl;
                                }
                                
                                return 0;
                            }
                        
                    

Write a program to input all sides of a triangle and check whether triangle is valid or not.


                        
                            //Check triangle is valid or not by input of its sides
                            #include<iostream>
                            #include<cmath>
                            using namespace std;
                            int main()
                            {
                                float side1;
                                float side2;
                                float side3;
                                bool flag=false;
                                cout<<"Enter the value of side1:"<<endl;
                                cin>>side1;
                                cout<<"Enter the value of side2:"<<endl;
                                cin>>side2;
                                cout<<"Enter the value of side3:"<<endl;
                                cin>>side3;
                                //a^2=b^2+c^2
                                if(side1==sqrt(pow(side2,2)+pow(side3,2)))
                                {
                                     flag=true;
                                }
                                else if(side2==sqrt(pow(side1,2)+pow(side3,2)))
                                {
                                    flag=true;
                                }
                                else if(side3==sqrt(pow(side2,2)+pow(side1,2)))
                                {
                                    flag=true;
                                }
                                if(flag==false)
                                {
                                    cout<<"It is not a triangle:"<<endl;
                                }
                                else if(flag==true)
                                {
                                    cout<<"It is a triangle:"<<endl;
                                }
                                    
                                return 0;
                                
                            }
                        
                    

Write a program to find all roots of a quadratic equation. And also find th nature of the roots as ,equal ,distant and imaginary


                        
                            //Roots of the qudratic equation
                            #include<iostream>
                            #include<cmath>
                            using namespace std;
                            int main()
                            {
                                
                                int a;
                                int b;
                                int c;
                                double disc;
                                double root1;
                                double root2;
                                cout<<"Quadratic equation is writtten as \"ax^2+bx+c\""<<endl;
                                cout<<"Enter the value of ax^2:"<<endl;
                                cin>>a;
                                cout<<"Enter the value of bx:"<<endl;
                                cin>>b;
                                cout<<"Enter the value of c:"<<endl;
                                cin>>c;
                                //calculations
                                disc=((pow(b,2))-4*(a*c));
                                root1=((-b+(sqrt(disc)))/2*a); 
                                root2=((-b-(sqrt(disc)))/2*a);
                                if(disc==0)
                                {
                                    cout<<"The roots of the quadratic equation "<<a<<"x^2"<<"+"<<b<<"x"<<"+"<<c<<"are given as:"<<endl;
                                    cout<<"\t( "<<root1<<" , "<<root2<<" )"<<endl;
                                    cout<<"The nature of the roots is \"equal\" and real:"<<endl;
                                }
                                else if(disc>0)
                                {
                                    cout<<"The roots of the quadratic equation "<<a<<"x^2"<<"+"<<b<<"x"<<"+"<<c<<"are given as:"<<endl;
                                    cout<<"\t( "<<root1<<" , "<<root2<<" )"<<endl;
                                    
                                    cout<<"The nature of the roots is \"distant\" and real:"<<endl;
                                }
                                else
                                {
                                    cout<<"The roots of the quadratic equation "<<a<<"x^2"<<"+"<<b<<"x"<<"+"<<c<<"are given as:"<<endl;
                                    cout<<"\t( "<<root1<<" , "<<root2<<" )"<<endl;
                                    cout<<"NAN means it is an complex imaginary number:"<<endl;
                                    cout<<"The nature of the roots is \"Imaginary roots\":"<<endl;	
                                }
                            
                                return 0;
                            }
                            
                        
                    

These are some quiz for you to try yourself .>


                        
                       *- Write a program to input basic salary of an employee and calculate its Gross salary according to
                            following:
                            Basic Salary <= 10000 : HRA = 20%, DA = 80%
                            Basic Salary <= 20000 : HRA = 25%, DA = 90%
                            Basic Salary > 20000 : HRA = 30%, DA = 95%
                        *. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and
                            Computer. Calculate percentage and grade according to following:
                            Percentage >= 90% : Grade A
                            Percentage >= 80% : Grade B
                            Percentage >= 70% : Grade C
                            Percentage >= 60% : Grade D
                            Percentage >= 40% : Grade E
                            Percentage < 40% : Grade F
                        
                    

I am going on the Ejtama Rivand💖 after that i am launching the some amazing project🙀 in the BLOG,tab tak ka ly Allah HAFIZ GYUZ😊

Whats make this website differents from others?

Amazing Feature That Increase your Productivity

If you don't find any problem,in this website and if you have a very difficult assignment question that is not present on internet ,then you dont bother yourself,we are here to solve every problem of your life you just click on the Problem asking button and write your problem we slove the code of your problem and sent you on your email addres that you put in the sin up form.