C programming, exercises, solution: Write a C program to accept two integers and check whether they are equal or not. C# Sharp programming, exercises, solution: Write a C# Sharp program to accept two integers and check whether they are equal or not. 1. Take the two integers as input and store it in the variables m and n respectively. 2. Using if,else statements check if m is equal to n. 3. If they are equal, then print the output as “M and N are equal”. 4. Otherwise print it as “M and N are not equal”. write a program to input two unequal positive number and check whether they are perfect square or not. if the user in the negative numbers in the program display message 'square root of negative number cannot be determined'. In this, we’ll write a program that will test if the given number which is greater than 1 is prime or not. A prime number is a positive integer greater than 1 and which has only two factors 1 & the number itself for example number: 2, 3, 5, 7… etc are prime numbers as they have only two factors .i.e. 1 & the number itself. Write a C program to enter elements in two matrices and check whether both matrices are equal or not. C program to check whether elements of two matrices are equal or not. Logic to check if two matrices are equal or not in C programming. Take two inputs from user and check whether they are equal or not. print "Enter first number" first = input () print "Enter second number" second = input () print first == second 2. Input : num1 = 1233, num2 - 1233 Output : Same Input : num1 = 223, num2 = 233 Output : Not Same Recommended: Please try your approach on {IDE} first, before moving on to the solution. Method 1: The idea is to use XOR operator. You Might Like:Write a Python program to input two integers in a single line. Sample Solution-1: Python Code: Sample Output: The following tool visualize what the computer is doing step-by-step as it executes the said program: Sample Solution-2: Python Code: Sample Output: The following tool visualize what the computer is doing step-by-step as it executes the said program: Python Code Editor: Have another way to solve this solution? Contribute your code (and comments) through Disqus. Previous: Write a Python program to calculate the time runs (difference between start and current time)of a program.
What is the difficulty level of this exercise?
Split a String: >>> sentence = 'this is, a python, tutorial, about, idioms.' >>> sentence.split(', ') ['this is', 'a python', 'tutorial', 'about', 'idioms.'] >>> sentence.split(', ', 2) ['this is', 'a python', 'tutorial, about, idioms.'] >>> sentence.rsplit(', ') ['this is', 'a python', 'tutorial', 'about', 'idioms.'] >>> sentence.rsplit(', ', 2) ['this is, a python, tutorial', 'about', 'idioms.']
Write a C program to accept two integers and check whether they are equal or not. Pictorial Presentation: Sample Solution: C Code: Sample Output: Flowchart: C Programming Code Editor: Improve this sample solution and post your code through Disqus. Previous: C Conditional Statement Exercises Home
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
How to format strings using printf() to get equal length in the output? You can specify a width on string fields, e.g. printf("%-20s", "initialization...");And then whatever's printed with that field will be blank-padded to the width you indicate. The - left-justifies your text in that field. Ref : https://bit.ly/34DMOc3
View Discussion Improve Article Save Article Like Article The following are not allowed to use
Examples:
Method 1: The idea is to use the XOR operator. XOR of two numbers is 0 if the numbers are the same, otherwise non-zero.
Time Complexity: O(1) Method 2: We can subtract the numbers. The same numbers yield 0. If the answer is not 0, the numbers are not the same.
Time Complexity: O(1) Method 3: The bitwise AND of one number and the complement of the other number is zero if they are the same, and non-zero if they are not the same. Below is the implementation of the above approach:
Time Complexity: O(1) This article is contributed by Rohit Thapliyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above. |