</>
Tutorials

Tag: Programming

  • Pattern Printing question asked in CGI Coding Round
    Write a program that receives a number as input and prints it in the following format as shown below. Examples :   Input : n = 3 Output : 1*2*3*10*11*12 --4*5*8*9 ----6*7 Input : n = 4 Output : 1*2*3*4*17*18*19*20 --5*6*7*14*15*16 ----8*9*12*13 ------10*11 Asked in CGI coding round Approach: The approach is to see the problem, not as a single task but three tasks which, on combining, complete the main task. The three tasks are printing the left-half of the pattern, printing dashes(-), and prin...
  • Coding Challenge for Beginners | Coding Practice Challenges
    Start your coding journey with our Coding Challenge for Beginners! Here???s a simple coding challenge suitable for beginners. This challenge involves writing a function in a programming language of your choice.These fun practice coding challenges will help you learn the basics of programming and improve your problem-solving skills, giving you confidence as you learn to code.Coding Challenge for Beginners: From Easy to HardBeginners looking to enhance their coding skills should explore the Geeksf...
  • Program to count the number of months between given two years
    Given a start year and end year. Write a program to count number of months between given two years (both inclusive). Examples: Input: startYear = 1991, endYear = 2023Output: 396Explanation: The number of years between 1991 and 2023 (both inclusive) are: 33. So, total number of months = 396. Input: startYear = 2010, endYear = 2023Output: 168Explanation: The number of years between 2010 and 2023 (both inclusive) are: 14. So total number of months are: 168. Approach: To solve the problem, follow t...
  • Program to print the number of days in a given year
    Write a program to print the number of days in a given year. Examples: Input: 2023Output: 365Explanation: The year 2023 is not a leap year, therefore the number of days are 365. Input: 2024Output: 366Explanation: The year 2024 is a leap year, therefore the number of days are 366. Approach: To solve the problem, follow the below idea: To determine the number of days in a given year, you need to consider whether the year is a leap year or not. A year is a leap year if the following conditions are...
  • Program to convert minutes to seconds
    Given an integer N, the task is to convert N minutes to seconds. Note: 1 minute = 60 seconds Examples: Input: N = 5Output: 300 secondsExplanation: 5 minutes is equivalent to 5 * 60 = 300 seconds Input: N = 10Explanation: 600 secondsOutput: 10 minutes is equivalent to 10 * 60 = 600 seconds Approach: To solve the problem, follow the below idea: We know that 1 minute is equal to 60 seconds, so to convert N minutes to seconds, we can simply multiply N with 60 to get the total number of seconds. Ste...
  • Program to check a number is divisible by 5 or not
    Given number N, the task is to check whether it is divisible by 5. Print "Yes" if N is divisible by 5; otherwise, print "No". Examples: Input: N = 155Output: YesExplanation: If we divide 155 by 5, we get the remainder as 0, therefore 155 is divisible by 5. Input: N = 17Output: NoExplanation: If we divide 17 by 5, we get the remainder by 2, therefore 17 is divisible by 5. Program to check a number is divisible by 5 or not using Divisibility of 5:If observed carefully, all the multiples of 5 have...
Page 2 / 5515