Skip to content
- Tutorials
- Python Tutorial
- Taking Input in Python
- Python Operators
- Python Data Types
- Python Loops and Control Flow
- Python Functions
- Python OOPS Concept
- Python Data Structures
- Python Exception Handling
- Python File Handling
- Python Exercises
- Java
- Java Programming Language
- Java Collections
- Java 8 Tutorial
- Java Programs
- Java Interview Questions
- Java Exercises
- Java Quiz
- Java Projects
- Advance Java
- Programming Languages
- System Design
- Interview Corner
- Computer Science Subjects
- Operating System
- DBMS
-
- DSA Course
- DSA
- Practice Mathematical Algorithm
- Mathematical Algorithms
- Pythagorean Triplet
- Fibonacci Number
- Euclidean Algorithm
- LCM of Array
- GCD of Array
- Binomial Coefficient
- Catalan Numbers
- Sieve of Eratosthenes
- Euler Totient Function
- Modular Exponentiation
- Modular Multiplicative Inverse
- Stein's Algorithm
- Juggler Sequence
- Chinese Remainder Theorem
- Quiz on Fibonacci Numbers
Last Updated : 08 Aug, 2024
Summarize
Comments
Improve
Given four integers A, B, C and D which represents the four angles of a Quadrilateral in degrees. The task is to check whether the given quadrilateral is valid or not.
Examples:Input: A = 80, B = 70, C = 100, D=110
Output: ValidInput: A = 70, B = 80, C = 130, D=60
Output: InvalidApproach:
A Quadrilateral is valid if the sum of the four angles is equal to 360 degrees.Below is the implementation of the above approach:
C++ // C++ program to check if a given // quadrilateral is valid or not#include <bits/stdc++.h>using namespace std;// Function to check if a given // quadrilateral is valid or notbool Valid(int a, int b, int c, int d){ // Check condition if (a + b + c + d == 360) return true; return false;}// Driver codeint main(){ int a = 80, b = 70, c = 100, d = 110; if (Valid(a, b, c, d)) cout << "Valid quadrilateral"; else cout << "Invalid quadrilateral"; return 0;}
Java // Java program to check if a given // quadrilateral is valid or not class GFG{ // Function to check if a given // quadrilateral is valid or not public static int Valid(int a, int b, int c, int d) { // Check condition if (a + b + c + d == 360) return 1; return 0; } // Driver code public static void main (String[] args) { int a = 80, b = 70, c = 100, d = 110; if (Valid(a, b, c, d) == 1) System.out.println("Valid quadrilateral"); else System.out.println("Invalid quadrilateral"); } }// This code is contributed// by apurva_sharma244
Python3 # Python program to check if a given # quadrilateral is valid or not# Function to check if a given # quadrilateral is valid or notdef Valid(a, b, c, d): # Check condition if (a + b + c + d == 360): return True; return False;# Driver codea = 80; b = 70; c = 100; d = 110;if (Valid(a, b, c, d)): print("Valid quadrilateral");else: print("Invalid quadrilateral");# This code is contributed by Rajput-Ji
C# // C# program to check if a given // quadrilateral is valid or not class GFG {// Function to check if a given // quadrilateral is valid or not static bool Valid(int a, int b, int c, int d) { // Check condition if (a + b + c + d == 360) return true; return false; } // Driver code public static void Main(){ int a = 80, b = 70, c = 100, d = 110; if (Valid(a, b, c, d)) Console.WriteLine("Valid quadrilateral"); else Console.WriteLine("Invalid quadrilateral"); } }// This code is contributed by nidhiva
JavaScript <script>// Javascript program to check if a given // quadrilateral is valid or not // Function to check if a given // quadrilateral is valid or not function Valid(a, b, c, d) { // Check condition if (a + b + c + d == 360) return 1; return 0; } // Driver codevar a = 80, b = 70, c = 100, d = 110; if (Valid(a, b, c, d) == 1) document.write("Valid quadrilateral"); else document.write("Invalid quadrilateral"); // This code is contributed by Khushboogoyal499</script>
PHP <?php // PHP program to check if a given // quadrilateral is valid or not // Function to check if a given // quadrilateral is valid or not function Valid($a, $b, $c, $d){ // Check condition if ($a + $b + $c + $d == 360) return true; return false;}// Driver Code $a = 80;$b = 70;$c = 100;$d = 110;if (Valid($a, $b, $c, $d)) echo("Valid quadrilateral");else echo("Invalid quadrilateral");// This code is contributed by Naman_garg. ?>
Output
Valid quadrilateral
Time Complexity : O(1)
Auxiliary Space: O(1)
Please Login to comment...
Similar Reads
Check whether the triangle is valid or not if angles are given
Given three integers A, B and C which are the three angles of a possible triangle in degrees, the task is to check whether the triangle is valid or not.Examples: Input: A = 60, B = 40, C = 80 Output: ValidInput: A = 55, B = 45, C = 60 Output: Invalid Approach: A triangle is valid if the sum of the three angles is equal to 180 degrees. Below is the
3 min read
Find interior angles for each side of a given Cyclic Quadrilateral
Given four positive integers A, B, C, and D representing the sides of a Cyclic Quadrilateral, the task is to find all the interior angles of the cyclic quadrilateral. A cyclic quadrilateral is a quadrilateral whose vertices lie on a single circle. This circle is called the circumcircle or circ*mscribed circle, and the vertices are said to be concyc
9 min read
The sum of opposite angles of a cyclic quadrilateral is 180° | Class 9 Maths Theorem
In Euclidean geometry, a cyclic quadrilateral or inscribed quadrilateral is a quadrilateral whose vertices all lie on a single circle. This circle is called the circumcircle or circ*mscribed circle, and the vertices are said to be concyclic. The center of the circle and its radius are called the circumcenter and the circumradius respectively. Other
6 min read
Program to find the angles of a quadrilateral
Given that all the angles of a quadrilateral are in AP having common differences 'd', the task is to find all the angles. Examples: Input: d = 10Output: 75, 85, 95, 105Input: d = 20Output: 60, 80, 100, 120Approach: We know that the angles of the quadrilateral are in AP and having the common difference 'd'. So, if we assume the first angle to be 'a'
12 min read
Check whether triangle is valid or not if sides are given
Given three sides, check whether triangle is valid or not. Examples: Input : a = 7, b = 10, c = 5 Output : Valid Input : a = 1 b = 10 c = 12 Output : Invalid Approach: A triangle is valid if sum of its two sides is greater than the third side. If three sides are a, b and c, then three conditions should be met. 1.a + b > c 2.a + c > b 3.b + c
4 min read
Check whether triangle is valid or not if three points are given
Given coordinates of three points in a plane P1, P2 and P3, the task is to check if the three points form a triangle or notExamples: Input: P1 = (1, 5), P2 = (2, 5), P3 = (4, 6) Output: YesInput: P1 = (1, 1), P2 = (1, 4), P3 = (1, 5) Output: No Approach: The key observation in the problem is three points form a triangle only when they don't lie on
9 min read
Check whether right angled triangle is valid or not for large sides
Given three integers a, b and c as triplets. Check if it is possible to make right angled triangle or not. Print Yes if possible, else No. 10-18 <= a, b, c <= 1018 Examples: Input: 3 4 5 Output: Yes Explanation: Since 3*3 + 4*4 = 5*5 Hence print "Yes" Input: 8 5 13 Since 8 + 5 < 13 which violates the property of triangle. Hence print "No"
8 min read
Check whether the given string is a valid identifier
Given a string str, the task is to check if the string is a valid identifier or not. In order to qualify as a valid identifier, the string must satisfy the following conditions: It must start with an either underscore(_) or any of the characters from the ranges ['a', 'z'] and ['A', 'Z'].There must not be any white space in the string.And, all the s
6 min read
Find a valid parenthesis sequence of length K from a given valid parenthesis sequence
Given a string S of valid parentheses sequence of length N and an even integer K, the task is to find the valid parentheses sequence of length K which is also a subsequence of the given string. Note: There can be more than one valid sequence, print any of them. Examples: Input: S = "()()()", K = 4Output: ()()Explanation:The string "()()" is a subse
7 min read
Check if given Sudoku board configuration is valid or not
Given a Sudoku Board configuration, check whether it is valid or not. Examples: Input: [5 3 - - 7 - - - -] [6 - - 1 9 5 - - -] [- 9 8 - - - - 6 -] [8 - - - 6 - - - 3] [4 - - 8 - 3 - - 1] [7 - - - 2 - - - 6] [- 6 - - - - 2 8 -] [- - - 4 1 9 - - 5] [- - - - 8 - - 7 9] Output: True Input: [3 9 - 7 5 2 - - -] [5 - 4 - - - - 7 -] [- - 2 - 8 - - 9 -] [1
14 min read
Check if the given chessboard is valid or not
Given an NXN chessboard. The task is to check if the given chessboard is valid or not. A chess board is considered valid if every 2 adjacent cells are painted with different color. Two cells are considered adjacent if they share a boundary. First chessboard is valid whereas the second is invalid. Examples: Input : N = 2 C = { { 1, 0 }, { 0, 1 } } O
10 min read
Check if the given Prufer sequence is valid or not
Given a Prufer sequence of N integers, the task is to check if the given sequence is a valid Prufer sequence or not.Examples: Input: arr[] = {4, 1, 3, 4} Output: Valid The tree is: 2----4----3----1----5 | 6 Input: arr[] = {4, 1, 7, 4} Output: Invalid Approach: Since we know the Prufer sequence is of length N - 2 where N is the number of vertices. H
7 min read
Check if given email address is valid or not in C++
Given a string email that denotes an Email Address, the task is to check if the given string is a valid email id or not. If found to be true, then print "Valid". Otherwise, print "Invalid". A valid email address consists of an email prefix and an email domain, both in acceptable formats: The email address must start with a letter (no numbers or sym
4 min read
Check if a given string is a valid Hexadecimal Color Code or not
Given a string str, the task is to check whether the given string is an HTML Hex Color Code or not. Print Yes if it is, otherwise print No. Examples: Input: str = “#1AFFa1”Output: Yes Input: str = “#F00”Output: Yes Input: str = �”Output: No Approach: An HTML Hex Color Code follows the below-mentioned set of rules: It starts with the ‘#’ symbol.Then
7 min read
Check if the given RGB color code is valid or not
Given three numbers R, G and B as the color code for Red, Green and Blue respectively as in the form of RGB color code. The task is to know whether the given color code is valid or not. RGB Format: The RGB(Red, Green, Blue) format is used to define the color of an HTML element by specifying the R, G, B values range between 0 to 255. For example: RG
10 min read
Check if given Sudoku solution is valid or not
Given a 2D array, board[][] of size 9 × 9, which represents a solution to the Sudoku puzzle, the task is to check if the given representation of a solved Sudoku puzzle is valid or not. Examples: Input: board[][] = {{7, 9, 2, 1, 5, 4, 3, 8, 6}, {6, 4, 3, 8, 2, 7, 1, 5, 9}, {8, 5, 1, 3, 9, 6, 7, 2, 4}, {2, 6, 5, 9, 7, 3, 8, 4, 1}, {4, 8, 9, 5, 6, 1,
15+ min read
Check if the given string is valid English word or not
Given string str, the task is to check if this string str consists of valid English words or not. A string is known as a valid English word if it meets all the below criteria- The string can have an uppercase character as the first character only.The string can only have lowercase characters.The string can consist of only one hyphen('-') surrounded
15 min read
Javascript Program for Check whether all the rotations of a given number is greater than or equal to the given number or not
Given an integer x, the task is to find if every k-cycle shift on the element produces a number greater than or equal to the same element. A k-cyclic shift of an integer x is a function that removes the last k digits of x and inserts them in its beginning. For example, the k-cyclic shifts of 123 are 312 for k=1 and 231 for k=2. Print Yes if the giv
3 min read
Check whether all the rotations of a given number is greater than or equal to the given number or not
Given an integer x, the task is to find if every k-cycle shift on the element produces a number greater than or equal to the same element. A k-cyclic shift of an integer x is a function that removes the last k digits of x and inserts them in its beginning. For example, the k-cyclic shifts of 123 are 312 for k=1 and 231 for k=2. Print Yes if the giv
12 min read
C++ Program to Check whether all the rotations of a given number is greater than or equal to the given number or not
Given an integer x, the task is to find if every k-cycle shift on the element produces a number greater than or equal to the same element. A k-cyclic shift of an integer x is a function that removes the last k digits of x and inserts them in its beginning. For example, the k-cyclic shifts of 123 are 312 for k=1 and 231 for k=2. Print Yes if the giv
6 min read
Exterior angle of a cyclic quadrilateral when the opposite interior angle is given
Given cyclic quadrilateral inside a circle, the task is to find the exterior angle of the cyclic quadrilateral when the opposite interior angle is given.Examples: Input: 48 Output: 48 degrees Input: 83 Output: 83 degrees Approach: Let, the exterior angle, angle CDE = xand, it's opposite interior angle is angle ABCas, ADE is a straight lineso, angle
3 min read
Find the area of quadrilateral when diagonal and the perpendiculars to it from opposite vertices are given
Given three integers d, h1, h2 where d represents the length of the diagonal of a quadrilateral. h1 and h2 represents the lengths of the perpendiculars to the given diagonal from the opposite vertices. The task is to find the area of the Quadrilateral. Examples: Input : d= 6, h1 = 4, h2 = 3 Output : 21Input : d= 10, h1 = 8, h2 = 10 Output : 90 Appr
3 min read
Calculate area of a cyclic quadrilateral with given side lengths
Given four positive integers A, B, C, and D representing the length of sides of a Cyclic Quadrilateral, the task is to find the area of the Cyclic Quadrilateral. Examples: Input: A = 10, B = 15, C = 20, D = 25Output: 273.861 Input: A = 10, B = 30, C = 50, D = 20Output: 443.706 Approach: The given problem can be solved based on the following observa
5 min read
Maximize Perimeter of Quadrilateral formed by choosing sides from given Array
Given an array arr of size N where each element represents the length of a side, the task is to find the maximum perimeter quadrilateral that can be created using the sides in the given array. If no quadrilateral can be formed print -1. Examples: Input: arr[ ] = {3, 1, 2, 4, 2, 1}Output: 11Explanation: A quadrilateral of perimeter 4 + 3 + 2 + 2 = 1
9 min read
Check if an N-sided Polygon is possible from N given angles
Given an array arr[] of N elements, where each element represents an angle(in degrees) of a polygon, the task is to check whether it is possible to make an N-sided polygon with all the given angles or not. If it is possible then print Yes else print No. Examples: Input: N = 3, arr[] = {60, 60, 60}Output: YesExplanation: There exists a triangle(i.e.
4 min read
Check if a king can move a valid move or not when N nights are there in a modified chessboard
Given an infinite chessboard with the same rules as that of chess. Also given are N knights coordinates on the infinite chessboard(-10^9 <= x, y <= 10^9) and the king's coordinate, the task is to check if the King is checkmate or not. Examples: Input: a[] = { {1, 0}, {0, 2}, {2, 5}, {4, 4}, {5, 0}, {6, 2} } king -> {3, 2} Output: Yes The k
10 min read
Check if the game is valid or not
Three players P1, P2 and P3 are playing a game. But at a time only two players can play the game, so they decided, at a time two players will play the game and one will spectate. When one game ends, the one who lost the game becomes the spectator in the next game and the one who was spectating plays against the winner. There cannot be any draws in
6 min read
How to check Aadhaar number is valid or not using Regular Expression
Given string str, the task is to check whether the given string is a valid Aadhaar number or not by using Regular Expression. The valid Aadhaar number must satisfy the following conditions: It should have 12 digits.It should not start with 0 and 1.It should not contain any alphabet and special characters.It should have white space after every 4 dig
5 min read
Check if an URL is valid or not using Regular Expression
Given a URL as a character string str of size N.The task is to check if the given URL is valid or not.Examples : Input : str = "https://www.geeksforgeeks.org/" Output : Yes Explanation : The above URL is a valid URL.Input : str = "https:// www.geeksforgeeks.org/" Output : No Explanation : Note that there is a space after https://, hence the URL is
4 min read
Check if Rotated Concatenated Strings are valid or not
Given a string s formed by concatenating another string s1 to itself, followed by a rotation to the left any number of times, the task is to determine whether a given string s is valid, indicating whether it can be formed from the original string s1. Examples: Input: s = "abcabc"Output: 1Explanation: s1 = "abcabc" can be generated by s = "abc". s+s
5 min read
Article Tags :
Practice Tags :
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
- Python Tutorial
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, check: true }), success:function(result) { jQuery.ajax({ url: writeApiUrl + 'suggestions/auth/' + `${post_id}/`, type: "GET", dataType: 'json', xhrFields: { withCredentials: true }, success: function (result) { $('.spinner-loading-overlay:eq(0)').remove(); var commentArray = result; if(commentArray === null || commentArray.length === 0) { // when no reason is availaible then user will redirected directly make the improvment. // call to api create-improvement-post $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); return; } var improvement_reason_html = ""; for(var comment of commentArray) { // loop creating improvement reason list markup var comment_id = comment['id']; var comment_text = comment['suggestion']; improvement_reason_html += `
${comment_text}
`; } $('.improvement-reasons_wrapper').html(improvement_reason_html); $('.improvement-bottom-btn').html("Create Improvement"); $('.improve-modal--improvement').hide(); $('.improvement-reason-modal').show(); }, error: function(e){ $('.spinner-loading-overlay:eq(0)').remove(); // stop loader when ajax failed; }, }); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ $('.improvement-reason-modal').hide(); } $('.improve-modal--improvement').show(); }); function loadScript(src, callback) { var script = document.createElement('script'); script.src = src; script.onload = callback; document.head.appendChild(script); } function suggestionCall() { var suggest_val = $.trim($("#suggestion-section-textarea").val()); var array_String= suggest_val.split(" ") var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(suggest_val.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `
${suggest_val}
`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-section-textarea').val(""); jQuery('.suggest-bottom-btn').css("display","none"); // Update the modal content const modalSection = document.querySelector('.suggestion-modal-section'); modalSection.innerHTML = `
Thank You!
Your suggestions are valuable to us.
You can now also contribute to the GeeksforGeeks community by creating improvement and help your fellow geeks.
`; }, error:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 5 Words and Maximum Character limit is 2000."); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('#suggestion-section-textarea').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // load the captcha script and set the token loadScript('https://www.google.com/recaptcha/api.js?render=6LdMFNUZAAAAAIuRtzg0piOT-qXCbDF-iQiUi9KY',[], function() { setGoogleRecaptcha(); }); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.improvement-reason-modal').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); });