{"id":26118,"date":"2024-12-16T14:59:05","date_gmt":"2024-12-16T09:29:05","guid":{"rendered":"https:\/\/internshala.com\/blog\/?p=26118"},"modified":"2026-04-07T18:15:44","modified_gmt":"2026-04-07T12:45:44","slug":"infosys-coding-interview-questions-and-answers","status":"publish","type":"post","link":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/","title":{"rendered":"Top 30 Infosys Coding Interview Questions and Answer (2026)"},"content":{"rendered":"\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>You know?<\/strong> According to Infosys (IFRS-INR press release), the company added 5,043 employees in Q3 FY2026, taking its total workforce to 337,034.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Infosys is one of the leading IT services companies globally and is renowned for its rigorous recruitment process, especially in coding and technical rounds. With over 300,000 employees across 50+ countries, Infosys emphasizes problem-solving skills and programming expertise when selecting candidates. The coding questions in their hiring process test logical reasoning, data structures, algorithms, and real-world problem-solving abilities. In this blog, we will discuss some of the commonly asked Infosys coding interview questions and answers and provide insightful answers to help you ace your interview.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#Infosys_Coding_Interview_Questions_and_Answers_For_Freshers\" >Infosys Coding Interview Questions and Answers For Freshers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#Infosys_Coding_Interview_Questions_and_Answers_For_Mid-level_Candidates\" >Infosys Coding Interview Questions and Answers For Mid-level Candidates<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#Infosys_Coding_Interview_Questions_And_Answers_For_Experienced_Candidates\" >Infosys Coding Interview Questions And Answers For Experienced Candidates<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#FAQs\" >FAQs<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Infosys_Coding_Interview_Questions_and_Answers_For_Freshers\"><\/span>Infosys Coding Interview Questions and Answers For Freshers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When preparing for an entry-level job position at Infosys, one of the key components of the interview process involves coding assessments. These assessments are designed to evaluate your problem-solving skills, understanding of algorithms, and coding proficiency. Below are Infosys coding interview questions and answers for freshers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q1. What will be the output of the Pseudo Code provided below?<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main()\n{\n    float i;\n    i = 1;\n    printf(\"%f\", i);\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Sample Answer:<\/strong> The given C code involves printing a floating-point value. The output of the provided C pseudo code will be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1.000000<\/code><\/pre>\n\n\n\n<p><strong>Explanation:<\/strong><\/p>\n\n\n\n<ol>\n<li>The variable i is declared as a float and initialized with the value 1.<\/li>\n\n\n\n<li>The printf function is used to print the value of i. The format specifier %f is used, which is for printing floating-point numbers in C.<\/li>\n\n\n\n<li>In C, when a float is printed using %f, it prints the number with six digits after the decimal point by default.<\/li>\n<\/ol>\n\n\n\n<p>So, when the value 1 is printed as a floating-point number, it is displayed as 1.000000 (with six decimal places). If you want to modify the precision of the printed number, you could adjust the format specifier (e.g., %.2f for two decimal places).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large desktop-image\"><a href=\"https:\/\/internshala.com\/jobs\/?utm_source=is_blog&amp;utm_medium=infosys-coding-interview-questions-and-answers&amp;utm_campaign=candidate-web-banner\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"203\" src=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1024x203.jpg\" alt=\"Find and Apply Banner\" class=\"wp-image-21795\" srcset=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1024x203.jpg 1024w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-672x133.jpg 672w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1536x305.jpg 1536w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-2048x406.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full mobile-image\"><a href=\"https:\/\/internshala.com\/jobs\/?utm_source=is_blog&amp;utm_medium=infosys-coding-interview-questions-and-answers&amp;utm_campaign=candidate-mobile-banner\"><img loading=\"lazy\" decoding=\"async\" width=\"356\" height=\"256\" src=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Job-Banner-for-candidates.jpg\" alt=\"Job Banner for candidates\" class=\"wp-image-21794\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Q2. Write a C program to arrange the given number to form the biggest number.<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> In this task, we need to write a C program that arranges a given set of numbers to form the largest possible number when concatenated. To achieve this, we treat the numbers as strings, allowing us to compare their concatenated versions in different orders. We will sort the numbers based on this comparison, ensuring that the resulting concatenation produces the largest number. The program will then print the largest number formed by the sorted input. Here&#8217;s a C program to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;string.h&gt;\n\n\/\/ Comparison function to compare two strings based on concatenation\nint compare(const void *a, const void *b) {\n    \/\/ Convert the pointers to strings\n    char *str1 = *(char **)a;\n    char *str2 = *(char **)b;\n\n    \/\/ Compare concatenated strings in both orders\n    if (strcmp(str1, str2) &gt; 0) return -1;\n    if (strcmp(str1, str2) &lt; 0) return 1;\n    return 0;\n}\n\nint main() {\n    int n;\n\n    \/\/ Read the number of elements\n    printf(\"Enter the number of elements: \");\n    scanf(\"%d\", &amp;n);\n\n    \/\/ Create an array of strings to store the numbers\n    char *arr&#91;n];\n\n    \/\/ Read the input numbers as strings\n    printf(\"Enter the numbers: \\n\");\n    for (int i = 0; i &lt; n; i++) {\n        arr&#91;i] = (char *)malloc(20 * sizeof(char)); \/\/ Allocate memory for each string\n        scanf(\"%s\", arr&#91;i]);\n    }\n\n    \/\/ Sort the array using qsort and the custom comparison function\n    qsort(arr, n, sizeof(char *), compare);\n\n    \/\/ Print the largest number formed\n    printf(\"The largest number formed is: \");\n    for (int i = 0; i &lt; n; i++) {\n        printf(\"%s\", arr&#91;i]);\n    }\n\n    \/\/ Free allocated memory\n    for (int i = 0; i &lt; n; i++) {\n        free(arr&#91;i]);\n    }\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p>Explanation:<\/p>\n\n\n\n<ul>\n<li><strong>Input:<\/strong> The program first takes the number of elements (n) and then takes n numbers as strings. This is necessary because numbers could have different lengths, and we want to treat them as strings for concatenation.<\/li>\n\n\n\n<li><strong>Sorting:<\/strong> The program sorts the strings based on how they compare when concatenated in both possible orders. For example, for two numbers &#8220;34&#8221; and &#8220;3&#8221;, it compares &#8220;343&#8221; and &#8220;334&#8221;. It chooses the order that forms the larger concatenated string.<\/li>\n\n\n\n<li><strong>Output:<\/strong> After sorting the strings, the program concatenates and prints them to form the largest possible number.<\/li>\n\n\n\n<li><strong>Memory Management:<\/strong> Memory is dynamically allocated for the strings and freed at the end.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Q3. How do you rotate a matrix by 90 degrees? Write a C program for this.<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> To rotate a matrix by 90 degrees clockwise, you can follow these steps:<\/p>\n\n\n\n<ul>\n<li><strong>Transpose the matrix:<\/strong> Swap the rows and columns of the matrix.<\/li>\n\n\n\n<li><strong>Reverse the rows:<\/strong> After transposing, reverse each row to get the final rotated matrix.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\n#define N 3 \/\/ Define the size of the matrix (NxN)\n\n\/\/ Function to print the matrix\nvoid printMatrix(int matrix&#91;N]&#91;N]) {\n    for (int i = 0; i &lt; N; i++) {\n        for (int j = 0; j &lt; N; j++) {\n            printf(\"%d \", matrix&#91;i]&#91;j]);\n        }\n        printf(\"\\n\");\n    }\n}\n\n\/\/ Function to rotate the matrix by 90 degrees clockwise\nvoid rotateMatrix(int matrix&#91;N]&#91;N]) {\n    \/\/ Step 1: Transpose the matrix\n    for (int i = 0; i &lt; N; i++) {\n        for (int j = i; j &lt; N; j++) {\n            \/\/ Swap matrix&#91;i]&#91;j] with matrix&#91;j]&#91;i]\n            int temp = matrix&#91;i]&#91;j];\n            matrix&#91;i]&#91;j] = matrix&#91;j]&#91;i];\n            matrix&#91;j]&#91;i] = temp;\n        }\n    }\n\n    \/\/ Step 2: Reverse each row\n    for (int i = 0; i &lt; N; i++) {\n        int start = 0, end = N - 1;\n        while (start &lt; end) {\n            \/\/ Swap elements in the row\n            int temp = matrix&#91;i]&#91;start];\n            matrix&#91;i]&#91;start] = matrix&#91;i]&#91;end];\n            matrix&#91;i]&#91;end] = temp;\n            start++;\n            end--;\n        }\n    }\n}\n\nint main() {\n    \/\/ Initialize a matrix\n    int matrix&#91;N]&#91;N] = {\n        {1, 2, 3},\n        {4, 5, 6},\n        {7, 8, 9}\n    };\n\n    printf(\"Original Matrix:\\n\");\n    printMatrix(matrix);\n\n    \/\/ Rotate the matrix by 90 degrees\n    rotateMatrix(matrix);\n\n    printf(\"\\nMatrix after rotating 90 degrees clockwise:\\n\");\n    printMatrix(matrix);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p><strong>Also Read:<\/strong> <a href=\"https:\/\/internshala.com\/blog\/infosys-interview-questions\/\" target=\"_blank\" rel=\"noreferrer noopener\">Infosys Interview Questions<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q4. How do you find the missing characters to make a string pangram using a C program?<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> To answer the coding questions asked in Infosys interview, you need to check if each letter of the alphabet (from &#8216;a&#8217; to &#8216;z&#8217;) is present in the string. If any letter is missing, you can add it to a list of missing characters. Here is the code to implement this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;string.h&gt;\n#include &lt;ctype.h&gt;\n\n#define ALPHABET_SIZE 26\n\n\/\/ Function to find missing characters for a pangram\nvoid findMissingCharacters(char str&#91;]) {\n    \/\/ Create an array to keep track of letters present in the string\n    int present&#91;ALPHABET_SIZE] = {0};\n\n    \/\/ Iterate over each character in the string\n    for (int i = 0; str&#91;i] != '\\0'; i++) {\n        \/\/ Convert the character to lowercase\n        char ch = tolower(str&#91;i]);\n\n        \/\/ If the character is a letter, mark it as present\n        if (ch &gt;= 'a' &amp;&amp; ch &lt;= 'z') {\n            present&#91;ch - 'a'] = 1;\n        }\n    }\n\n    \/\/ Print the missing characters\n    printf(\"Missing characters to make the string a pangram: \");\n    int foundMissing = 0;\n    for (int i = 0; i &lt; ALPHABET_SIZE; i++) {\n        if (present&#91;i] == 0) {\n            printf(\"%c \", 'a' + i);\n            foundMissing = 1;\n        }\n    }\n\n    \/\/ If no missing characters, the string is already a pangram\n    if (!foundMissing) {\n        printf(\"None. The string is already a pangram.\");\n    }\n    printf(\"\\n\");\n}\n\nint main() {\n    char str&#91;1000];\n\n    \/\/ Read input string\n    printf(\"Enter a string: \");\n    fgets(str, sizeof(str), stdin);\n\n    \/\/ Find missing characters to make the string a pangram\n    findMissingCharacters(str);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q5. How do you find the number of unique numbers in a given string? Write a C program for this.<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> To find the number of unique numbers in a given string, you need to extract all the numbers from the string and track which ones have already appeared. This can be done by using a data structure like a set (or an array, but a set is more efficient. This is the code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;string.h&gt;\n#include &lt;ctype.h&gt;\n\n#define MAX_NUMBERS 1000 \/\/ Define a maximum size for the set of unique numbers\n\n\/\/ Function to extract and count unique numbers in the string\nint countUniqueNumbers(char str&#91;]) {\n    int uniqueNumbers&#91;MAX_NUMBERS];\n    int uniqueCount = 0;\n\n    \/\/ Initialize all entries in uniqueNumbers to -1 (indicating no number is stored)\n    for (int i = 0; i &lt; MAX_NUMBERS; i++) {\n        uniqueNumbers&#91;i] = -1;\n    }\n\n    char currentNum&#91;20];  \/\/ Buffer to store current number (string format)\n    int currentIndex = 0;\n\n    \/\/ Iterate over the string\n    for (int i = 0; i &lt;= strlen(str); i++) {\n        if (isdigit(str&#91;i])) {\n            \/\/ Build the number string\n            currentNum&#91;currentIndex++] = str&#91;i];\n        } else {\n            \/\/ If currentNum is not empty and we've reached a non-digit\n            if (currentIndex &gt; 0) {\n                currentNum&#91;currentIndex] = '\\0';  \/\/ Null-terminate the current number\n                int num = atoi(currentNum);  \/\/ Convert the string to an integer\n\n                \/\/ Check if the number is already in the uniqueNumbers array\n                int isUnique = 1;\n                for (int j = 0; j &lt; uniqueCount; j++) {\n                    if (uniqueNumbers&#91;j] == num) {\n                        isUnique = 0;  \/\/ Number is already seen\n                        break;\n                    }\n                }\n\n                \/\/ If the number is unique, add it to the uniqueNumbers array\n                if (isUnique) {\n                    uniqueNumbers&#91;uniqueCount++] = num;\n                }\n\n                \/\/ Reset currentNum to start building the next number\n                currentIndex = 0;\n            }\n        }\n    }\n\n    return uniqueCount;  \/\/ Return the count of unique numbers\n}\n\nint main() {\n    char str&#91;1000];\n\n    \/\/ Read the input string\n    printf(\"Enter a string: \");\n    fgets(str, sizeof(str), stdin);\n\n    \/\/ Count the unique numbers in the string\n    int result = countUniqueNumbers(str);\n\n    \/\/ Output the result\n    printf(\"Number of unique numbers: %d\\n\", result);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q6. Write a program for the Subtraction of two Matrices.<\/h3>\n\n\n\n<p><span id=\"docs-internal-guid-6d5da2b7-7fff-9514-44e2-3485e08a4dc0\"><span style=\"font-size: 11pt; font-family: Arial, sans-serif; background-color: transparent; font-weight: 700; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline;\">Sample Answer:<\/span><span style=\"font-size: 11pt; font-family: Arial, sans-serif; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline;\"> To perform the subtraction of two matrices, you need to subtract the corresponding elements of the two matrices. If both matrices are of the same size, matrix subtraction is straightforward.<\/span><\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\n#define MAX_ROWS 10\n#define MAX_COLS 10\n\n\/\/ Function to subtract two matrices\nvoid subtractMatrices(int matrix1&#91;MAX_ROWS]&#91;MAX_COLS], int matrix2&#91;MAX_ROWS]&#91;MAX_COLS], int result&#91;MAX_ROWS]&#91;MAX_COLS], int rows, int cols) {\n    \/\/ Iterate over each element and subtract corresponding elements\n    for (int i = 0; i &lt; rows; i++) {\n        for (int j = 0; j &lt; cols; j++) {\n            result&#91;i]&#91;j] = matrix1&#91;i]&#91;j] - matrix2&#91;i]&#91;j];\n        }\n    }\n}\n\n\/\/ Function to print a matrix\nvoid printMatrix(int matrix&#91;MAX_ROWS]&#91;MAX_COLS], int rows, int cols) {\n    for (int i = 0; i &lt; rows; i++) {\n        for (int j = 0; j &lt; cols; j++) {\n            printf(\"%d \", matrix&#91;i]&#91;j]);\n        }\n        printf(\"\\n\");\n    }\n}\n\nint main() {\n    int matrix1&#91;MAX_ROWS]&#91;MAX_COLS], matrix2&#91;MAX_ROWS]&#91;MAX_COLS], result&#91;MAX_ROWS]&#91;MAX_COLS];\n    int rows, cols;\n\n    \/\/ Input the dimensions of the matrices\n    printf(\"Enter the number of rows and columns: \");\n    scanf(\"%d %d\", &amp;rows, &amp;cols);\n\n    \/\/ Input the first matrix\n    printf(\"Enter the elements of the first matrix:\\n\");\n    for (int i = 0; i &lt; rows; i++) {\n        for (int j = 0; j &lt; cols; j++) {\n            scanf(\"%d\", &amp;matrix1&#91;i]&#91;j]);\n        }\n    }\n\n    \/\/ Input the second matrix\n    printf(\"Enter the elements of the second matrix:\\n\");\n    for (int i = 0; i &lt; rows; i++) {\n        for (int j = 0; j &lt; cols; j++) {\n            scanf(\"%d\", &amp;matrix2&#91;i]&#91;j]);\n        }\n    }\n\n    \/\/ Perform matrix subtraction\n    subtractMatrices(matrix1, matrix2, result, rows, cols);\n\n    \/\/ Output the result\n    printf(\"\\nResult of matrix subtraction:\\n\");\n    printMatrix(result, rows, cols);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q7. How do you multiply two matrices and show results through another matrix? Write a C program.<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> Matrix multiplication involves multiplying rows of the first matrix with columns of the second matrix, and summing up the products of the corresponding elements. The result of the multiplication will be a new matrix. Here is the code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\n#define MAX_ROWS 10\n#define MAX_COLS 10\n\n\/\/ Function to multiply two matrices\nvoid multiplyMatrices(int matrix1&#91;MAX_ROWS]&#91;MAX_COLS], int matrix2&#91;MAX_ROWS]&#91;MAX_COLS], int result&#91;MAX_ROWS]&#91;MAX_COLS], int rows1, int cols1, int rows2, int cols2) {\n    \/\/ Initialize the result matrix to 0\n    for (int i = 0; i &lt; rows1; i++) {\n        for (int j = 0; j &lt; cols2; j++) {\n            result&#91;i]&#91;j] = 0;\n        }\n    }\n\n    \/\/ Perform matrix multiplication\n    for (int i = 0; i &lt; rows1; i++) {\n        for (int j = 0; j &lt; cols2; j++) {\n            for (int k = 0; k &lt; cols1; k++) {\n                result&#91;i]&#91;j] += matrix1&#91;i]&#91;k] * matrix2&#91;k]&#91;j];\n            }\n        }\n    }\n}\n\n\/\/ Function to print a matrix\nvoid printMatrix(int matrix&#91;MAX_ROWS]&#91;MAX_COLS], int rows, int cols) {\n    for (int i = 0; i &lt; rows; i++) {\n        for (int j = 0; j &lt; cols; j++) {\n            printf(\"%d \", matrix&#91;i]&#91;j]);\n        }\n        printf(\"\\n\");\n    }\n}\n\nint main() {\n    int matrix1&#91;MAX_ROWS]&#91;MAX_COLS], matrix2&#91;MAX_ROWS]&#91;MAX_COLS], result&#91;MAX_ROWS]&#91;MAX_COLS];\n    int rows1, cols1, rows2, cols2;\n\n    \/\/ Input dimensions and elements of the first matrix\n    printf(\"Enter the number of rows and columns for the first matrix: \");\n    scanf(\"%d %d\", &amp;rows1, &amp;cols1);\n    printf(\"Enter the elements of the first matrix:\\n\");\n    for (int i = 0; i &lt; rows1; i++) {\n        for (int j = 0; j &lt; cols1; j++) {\n            scanf(\"%d\", &amp;matrix1&#91;i]&#91;j]);\n        }\n    }\n\n    \/\/ Input dimensions and elements of the second matrix\n    printf(\"Enter the number of rows and columns for the second matrix: \");\n    scanf(\"%d %d\", &amp;rows2, &amp;cols2);\n    \n    \/\/ Check if multiplication is possible (cols1 of matrix1 must equal rows2 of matrix2)\n    if (cols1 != rows2) {\n        printf(\"Matrix multiplication not possible. The number of columns in the first matrix must be equal to the number of rows in the second matrix.\\n\");\n        return 1;  \/\/ Exit the program\n    }\n\n    printf(\"Enter the elements of the second matrix:\\n\");\n    for (int i = 0; i &lt; rows2; i++) {\n        for (int j = 0; j &lt; cols2; j++) {\n            scanf(\"%d\", &amp;matrix2&#91;i]&#91;j]);\n        }\n    }\n\n    \/\/ Perform matrix multiplication\n    multiplyMatrices(matrix1, matrix2, result, rows1, cols1, rows2, cols2);\n\n    \/\/ Output the result\n    printf(\"\\nResult of matrix multiplication:\\n\");\n    printMatrix(result, rows1, cols2);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q8. How do you convert decimal numbers to binary numbers? Write a C Program.<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> To convert a decimal number to binary, you can repeatedly divide the number by 2 and record the remainder for each division. This method generates the binary digits (bits) in reverse order, so you&#8217;ll need to reverse the remainder at the end to get the correct binary representation. Here is the code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\nvoid decimalToBinary(int n) {\n    \/\/ Array to store binary number\n    int binary&#91;32];\n    \n    \/\/ Index for binary array\n    int i = 0;\n\n    \/\/ If n is 0, the binary representation is 0\n    if (n == 0) {\n        printf(\"0\");\n        return;\n    }\n\n    \/\/ Generate binary number\n    while (n &gt; 0) {\n        binary&#91;i] = n % 2; \/\/ Store remainder in the binary array\n        n = n \/ 2; \/\/ Divide number by 2\n        i++;\n    }\n\n    \/\/ Print binary number in reverse order\n    printf(\"Binary: \");\n    for (int j = i - 1; j &gt;= 0; j--) {\n        printf(\"%d\", binary&#91;j]);\n    }\n    printf(\"\\n\");\n}\n\nint main() {\n    int num;\n\n    \/\/ Input the decimal number\n    printf(\"Enter a decimal number: \");\n    scanf(\"%d\", &amp;num);\n\n    \/\/ Convert and display the binary equivalent\n    decimalToBinary(num);\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q9. Write a program in C++ to swap two arrays quickly.<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> To swap two arrays in C++, you can use a temporary array to store one array&#8217;s values while copying the other array&#8217;s values to the first one. However, to do it quickly without needing extra space (except for a constant amount), you can swap the elements of the arrays in place using a simple loop. Here\u2019s a program that demonstrates how to swap two arrays in C++:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\n\/\/ Function to swap two arrays\nvoid swapArrays(int arr1&#91;], int arr2&#91;], int size) {\n    for (int i = 0; i &lt; size; i++) {\n        \/\/ Swap elements of arr1 and arr2\n        int temp = arr1&#91;i];\n        arr1&#91;i] = arr2&#91;i];\n        arr2&#91;i] = temp;\n    }\n}\n\n\/\/ Function to print an array\nvoid printArray(int arr&#91;], int size) {\n    for (int i = 0; i &lt; size; i++) {\n        cout &lt;&lt; arr&#91;i] &lt;&lt; \" \";\n    }\n    cout &lt;&lt; endl;\n}\n\nint main() {\n    int size;\n\n    \/\/ Input the size of the arrays\n    cout &lt;&lt; \"Enter the size of the arrays: \";\n    cin &gt;&gt; size;\n\n    int arr1&#91;size], arr2&#91;size];\n\n    \/\/ Input elements for the first array\n    cout &lt;&lt; \"Enter elements for the first array: \";\n    for (int i = 0; i &lt; size; i++) {\n        cin &gt;&gt; arr1&#91;i];\n    }\n\n    \/\/ Input elements for the second array\n    cout &lt;&lt; \"Enter elements for the second array: \";\n    for (int i = 0; i &lt; size; i++) {\n        cin &gt;&gt; arr2&#91;i];\n    }\n\n    \/\/ Display the original arrays\n    cout &lt;&lt; \"\\nOriginal arrays:\" &lt;&lt; endl;\n    cout &lt;&lt; \"Array 1: \";\n    printArray(arr1, size);\n    cout &lt;&lt; \"Array 2: \";\n    printArray(arr2, size);\n\n    \/\/ Swap the arrays\n    swapArrays(arr1, arr2, size);\n\n    \/\/ Display the arrays after swapping\n    cout &lt;&lt; \"\\nArrays after swapping:\" &lt;&lt; endl;\n    cout &lt;&lt; \"Array 1: \";\n    printArray(arr1, size);\n    cout &lt;&lt; \"Array 2: \";\n    printArray(arr2, size);\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q10. Write a C++ program to find the area of the incircle of a right-angle triangle.<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> To find the area of the incircle of a right-angled triangle, we first need to understand the formula for the radius of the incircle.<\/p>\n\n\n\n<p><strong>Formula to find the radius of the incircle of a right-angled triangle:<\/strong><\/p>\n\n\n\n<p>For a right-angled triangle with sides aaa, bbb, and hypotenuse ccc, the radius rrr of the incircle can be calculated using the formula:<\/p>\n\n\n\n<p>r=a+b\u2212c2r = \\frac{a + b &#8211; c}{2}r=2a+b\u2212c\u200b<\/p>\n\n\n\n<p><strong>Once we have the radius rrr, the area of the incircle can be found using the formula for the area of a circle:<\/strong><\/p>\n\n\n\n<p>Area of Incircle=\u03c0r2\\text{Area of Incircle} = \\pi r^2Area of Incircle=\u03c0r2<\/p>\n\n\n\n<p>Here is a C++ program to calculate the area of the encircle:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;cmath&gt; \/\/ For using sqrt and M_PI\nusing namespace std;\n\n\/\/ Function to calculate the area of the incircle of a right-angled triangle\ndouble calculateIncircleArea(double a, double b, double c) {\n    \/\/ Calculate the radius of the incircle\n    double r = (a + b - c) \/ 2.0;\n\n    \/\/ Calculate and return the area of the incircle\n    return M_PI * r * r; \/\/ M_PI is a constant for Pi\n}\n\nint main() {\n    double a, b, c;\n\n    \/\/ Input sides of the right-angled triangle\n    cout &lt;&lt; \"Enter the lengths of the two perpendicular sides (a and b): \";\n    cin &gt;&gt; a &gt;&gt; b;\n\n    \/\/ Calculate the length of the hypotenuse using the Pythagorean theorem\n    c = sqrt(a * a + b * b);\n\n    \/\/ Calculate and display the area of the incircle\n    double area = calculateIncircleArea(a, b, c);\n    cout &lt;&lt; \"The area of the incircle is: \" &lt;&lt; area &lt;&lt; endl;\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Pro Tip:<\/strong> Check out our recommended <a href=\"https:\/\/trainings.internshala.com\/how-to-ace-coding-interviews-course\/\" target=\"_blank\" rel=\"noreferrer noopener\">course on how to ace coding interviews<\/a> to further enhance your skills and prepare like a pro.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Infosys_Coding_Interview_Questions_and_Answers_For_Mid-level_Candidates\"><\/span>Infosys Coding Interview Questions and Answers For Mid-level Candidates<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Preparing for a coding interview at Infosys requires a solid understanding of problem-solving skills and technical expertise. Mid-level candidates are often tested on their ability to handle complex coding scenarios, optimize solutions, and apply industry-standard practices. Below are Infosys coding interview questions and answers for mid-level candidates.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q11. Write a C++ program that converts the given temperature of Fahrenheit into Celsius.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong> In this task, we will write a C++ program that converts a given temperature from Fahrenheit to Celsius. The program will prompt the user to input the temperature in Fahrenheit, and then it will apply the formula for conversion. <strong>Celsius = (5\/9) * (Fahrenheit &#8211; 32)<\/strong>. The result will be displayed in Celsius after the conversion. Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\n\/\/ Function to convert Fahrenheit to Celsius\ndouble fahrenheitToCelsius(double fahrenheit) {\n    return (5.0 \/ 9.0) * (fahrenheit - 32);\n}\n\nint main() {\n    double fahrenheit;\n\n    \/\/ Input the temperature in Fahrenheit\n    cout &lt;&lt; \"Enter temperature in Fahrenheit: \";\n    cin &gt;&gt; fahrenheit;\n\n    \/\/ Convert Fahrenheit to Celsius\n    double celsius = fahrenheitToCelsius(fahrenheit);\n\n    \/\/ Output the temperature in Celsius\n    cout &lt;&lt; fahrenheit &lt;&lt; \" Fahrenheit is equal to \" &lt;&lt; celsius &lt;&lt; \" Celsius.\" &lt;&lt; endl;\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Also Read:<\/strong> <a href=\"https:\/\/internshala.com\/blog\/infosys-interview-questions-for-java-developer\/\" target=\"_blank\" rel=\"noreferrer noopener\">Infosys Java Developer Interview Questions<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q12. Write a Python program to find the sum of all the prime numbers between 1 and N.<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we will write a Python program that calculates the sum of all prime numbers between 1 and a given number N. The program will first define a function to check whether a number is prime, then iterate through all numbers from 2 to N, summing those that are prime. Finally, the program will output the total sum of the prime numbers in the specified range. Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Function to check if a number is prime\ndef is_prime(num):\n    if num &lt;= 1:\n        return False\n    for i in range(2, int(num ** 0.5) + 1):\n        if num % i == 0:\n            return False\n    return True\n\n# Function to calculate the sum of all prime numbers between 1 and N\ndef sum_of_primes(N):\n    total = 0\n    for num in range(2, N + 1):\n        if is_prime(num):\n            total += num\n    return total\n\n# Main function\nif __name__ == \"__main__\":\n    N = int(input(\"Enter the value of N: \"))\n    result = sum_of_primes(N)\n    print(f\"The sum of all prime numbers between 1 and {N} is: {result}\")\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q13. Write a Python program to make the largest number from the digits of the array.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we will write a Python program that creates the largest number possible from the digits of an array. The program will first convert the elements of the array into strings. Then, it will sort the array in descending order, using a custom sorting technique to ensure that the concatenation of the numbers produces the largest possible number. Finally, the program will join the sorted digits and print the largest number formed.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Function to make the largest number from the digits of the array\ndef make_largest_number(arr):\n    # Convert all elements of the array to strings\n    arr = &#91;str(num) for num in arr]\n    \n    # Sort the array in descending order based on the string comparison of concatenated numbers\n    arr.sort(reverse=True, key=lambda x: x*10)  # Repeat each string to ensure correct comparison\n    \n    # Join the sorted array into a single string\n    largest_number = ''.join(arr)\n    \n    # Return the result\n    return largest_number\n\n# Main program\nif __name__ == \"__main__\":\n    arr = list(map(int, input(\"Enter the digits separated by space: \").split()))\n    result = make_largest_number(arr)\n    print(f\"The largest number formed is: {result}\")\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q14. Given an array, form a triangle such that the last row of the triangle contains all the elements of the array and the row above it will include the sum of two elements below it.<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we will write a Python program to form a triangle from an array of numbers. The last row of the triangle will contain all the elements of the array, and each subsequent row above it will consist of the sum of two adjacent elements from the row directly below. The program will generate each upper row iteratively until only one element remains at the top, forming the complete triangle.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def form_triangle(arr):\n    # Start with the last row being the input array\n    triangle = &#91;arr]\n    \n    # Generate each upper row by summing adjacent elements from the row below\n    while len(arr) &gt; 1:\n        arr = &#91;arr&#91;i] + arr&#91;i+1] for i in range(len(arr) - 1)]\n        triangle.insert(0, arr)  # Insert the new row at the beginning\n    \n    return triangle\n\n# Example usage:\narr = &#91;1, 2, 3, 4, 5]\ntriangle = form_triangle(arr)\nfor row in triangle:\n    print(row)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q15. Given the coordinates of the endpoints of two rectangles, find whether they overlap each other or not.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we will write a Python program to determine whether two rectangles, given by the coordinates of their bottom-left and top-right corners, overlap each other. The program will check the conditions for non-overlapping rectangles: if one rectangle is to the left or right of the other, or if one rectangle is above or below the other. If none of these conditions are met, the rectangles overlap.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def do_rectangles_overlap(rect1, rect2):\n    # rect1 and rect2 are tuples (x1, y1, x2, y2) representing bottom-left and top-right corners\n    x1_1, y1_1, x2_1, y2_1 = rect1\n    x1_2, y1_2, x2_2, y2_2 = rect2\n    \n    # Check if one rectangle is to the left or right of the other\n    if x2_1 &lt;= x1_2 or x2_2 &lt;= x1_1:\n        return False\n    \n    # Check if one rectangle is above or below the other\n    if y2_1 &lt;= y1_2 or y2_2 &lt;= y1_1:\n        return False\n    \n    return True\n\n# Example usage:\nrect1 = (1, 1, 4, 4)  # Bottom-left (1,1), Top-right (4,4)\nrect2 = (2, 2, 5, 5)  # Bottom-left (2,2), Top-right (5,5)\nrect3 = (5, 5, 7, 7)  # Bottom-left (5,5), Top-right (7,7)\n\nprint(do_rectangles_overlap(rect1, rect2))  # Should return True\nprint(do_rectangles_overlap(rect1, rect3))  # Should return False\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q16. You are given two strings to find whether we can convert one string to another by rotating in two places.<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we are given two strings and need to check whether one string can be transformed into another by rotating it in two places. To do this, we will rotate the first string by two places in both directions (left and right) and then check if either of the rotated versions matches the second string. If either of the rotated strings matches, the answer is True, otherwise, it is False.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def can_rotate_in_two_places(s1, s2):\n    # Check if lengths are equal\n    if len(s1) != len(s2):\n        return False\n\n    # Concatenate s1 with itself to cover all possible rotations\n    doubled_s1 = s1 + s1\n\n    # Check if s2 is a substring of the doubled string\n    for i in range(1, len(s1)):  \n# start from index 1 to ensure we check rotations in two places\n        if doubled_s1&#91;i:i + len(s2)] == s2:\n            return True\n\n    return False\n\n# Example Usage\ns1 = \"abcde\"\ns2 = \"deabc\"\nprint(can_rotate_in_two_places(s1, s2))  # Output: True\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q17.&nbsp; Given a list of integers, find the longest subsequence where the difference between every pair of consecutive elements is the same.<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we need to find the longest subsequence in a list of integers where the difference between every pair of consecutive elements is the same. We will iterate through the list, keeping track of the longest subsequence where the difference remains constant. If the difference changes, we will reset the subsequence and start a new one. The program will then return the longest subsequence found.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def longest_arithmetic_subsequence(arr):\n    if len(arr) &lt;= 1:\n        return arr\n    \n    # Variables to keep track of the current subsequence and the longest subsequence\n    max_length = 1\n    current_subsequence = &#91;arr&#91;0]]\n    longest_subsequence = &#91;arr&#91;0]]\n    diff = None\n\n    for i in range(1, len(arr)):\n        # If the difference is the same as the previous one, continue the subsequence\n        if diff is None or arr&#91;i] - arr&#91;i-1] == diff:\n            current_subsequence.append(arr&#91;i])\n        else:\n            # Otherwise, reset the subsequence\n            if len(current_subsequence) &gt; max_length:\n                max_length = len(current_subsequence)\n                longest_subsequence = current_subsequence\n            current_subsequence = &#91;arr&#91;i-1], arr&#91;i]]\n        \n        # Update the difference\n        diff = arr&#91;i] - arr&#91;i-1]\n    \n    # Check the last subsequence\n    if len(current_subsequence) &gt; max_length:\n        longest_subsequence = current_subsequence\n\n    return longest_subsequence\n\n# Example usage\narr = &#91;1, 7, 10, 13, 14, 19, 20]\nresult = longest_arithmetic_subsequence(arr)\nprint(f\"The longest arithmetic subsequence is: {result}\")\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q18. Write a C++ program to swap two numbers.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>This task requires us to write a program that swaps two numbers. The program will prompt the user to input two numbers and then swap them using a temporary variable. The result will be displayed before and after the swap.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    \/\/ Declare two variables to store the numbers\n    int a, b;\n    \n    \/\/ Input the values of the numbers\n    cout &lt;&lt; \"Enter the first number: \";\n    cin &gt;&gt; a;\n    cout &lt;&lt; \"Enter the second number: \";\n    cin &gt;&gt; b;\n\n    \/\/ Display the values before swapping\n    cout &lt;&lt; \"Before swapping:\" &lt;&lt; endl;\n    cout &lt;&lt; \"a = \" &lt;&lt; a &lt;&lt; \", b = \" &lt;&lt; b &lt;&lt; endl;\n\n    \/\/ Swap the values of a and b using a temporary variable\n    int temp = a;\n    a = b;\n    b = temp;\n\n    \/\/ Display the values after swapping\n    cout &lt;&lt; \"After swapping:\" &lt;&lt; endl;\n    cout &lt;&lt; \"a = \" &lt;&lt; a &lt;&lt; \", b = \" &lt;&lt; b &lt;&lt; endl;\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q19. Write a program to convert the decimal number to the octal number. (C++)&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we will write a program to convert a decimal number to its octal equivalent. The program will repeatedly divide the decimal number by 8 and store the remainders to form the octal number. After the conversion, the program will display the octal result.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    int decimalNumber, remainder;\n    string octalNumber = \"\";\n\n    \/\/ Input decimal number\n    cout &lt;&lt; \"Enter a decimal number: \";\n    cin &gt;&gt; decimalNumber;\n\n    \/\/ Convert decimal to octal\n    while (decimalNumber != 0) {\n        remainder = decimalNumber % 8;  \/\/ Get remainder when divided by 8\n        octalNumber = to_string(remainder) + octalNumber;  \/\/ Prepend the remainder\n        decimalNumber \/= 8;  \/\/ Update decimal number by dividing by 8\n    }\n\n    \/\/ Output the octal number\n    cout &lt;&lt; \"The octal equivalent is: \" &lt;&lt; octalNumber &lt;&lt; endl;\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q20. Write a Python program to convert a decimal number to a hexadecimal number.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>This task involves converting a decimal number to its hexadecimal equivalent. We will use Python\u2019s built-in hex() function to perform the conversion. The program will input a decimal number from the user and output the corresponding hexadecimal number after stripping the 0x prefix.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def decimal_to_hexadecimal(decimal_number):\n    # Using built-in hex function to convert decimal to hexadecimal\n    hexadecimal_number = hex(decimal_number)\n    return hexadecimal_number&#91;2:]  # Removing the '0x' prefix\n\n# Input from user\ndecimal_number = int(input(\"Enter a decimal number: \"))\n\n# Convert to hexadecimal\nhexadecimal_number = decimal_to_hexadecimal(decimal_number)\n\n# Output the result\nprint(f\"The hexadecimal equivalent of {decimal_number} is: {hexadecimal_number}\")\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Infosys_Coding_Interview_Questions_And_Answers_For_Experienced_Candidates\"><\/span>Infosys Coding Interview Questions And Answers For Experienced Candidates<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Preparing for a coding interview with Infosys as an experienced professional requires a strategic approach to problem-solving and technical expertise. Below are Infosys coding interview questions and answers for experienced candidates.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q21. Write a Python program to swap two numbers without using a third variable.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we need to write a Python program to swap two numbers without using a third variable. The program will take two numbers as input, display their values before swapping, and then swap them using arithmetic operations. The swapped values will be displayed at the end.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Take input from the user\nx = float(input(\"Enter the first number: \"))\ny = float(input(\"Enter the second number: \"))\n\n# Display the original values\nprint(f\"Before swapping: x = {x}, y = {y}\")\n\n# Swapping the values using arithmetic operations\nx = x + y\ny = x - y\nx = x - y\n\n# Display the swapped values\nprint(f\"After swapping: x = {x}, y = {y}\")\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q22. Write a Python program to convert an octal number to a binary number.<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>This task requires converting an octal number to its binary equivalent. The program will first convert the octal number to decimal and then convert the decimal number to binary. The result will be displayed as the binary equivalent of the given octal number.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def octal_to_binary(octal):\n    # Convert octal to decimal\n    decimal = int(octal, 8)\n    \n    # Convert decimal to binary\n    binary = bin(decimal).replace(\"0b\", \"\")\n    \n    return binary\n\n# Input octal number from the user\noctal_number = input(\"Enter an octal number: \")\n\n# Call the function and display the result\nbinary_number = octal_to_binary(octal_number)\nprint(f\"The binary equivalent of octal {octal_number} is {binary_number}\")\n<\/code><\/pre>\n\n\n\n<p><strong>Also Read:<\/strong> <a href=\"https:\/\/internshala.com\/blog\/infosys-bpm-interview-questions-and-answer\/\" target=\"_blank\" rel=\"noreferrer noopener\">Infosys BPM Interview Questions<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q23. Write a Java program to convert an octal number to a decimal number.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we are given an octal number, and we need to write a Java program to convert it into its decimal equivalent. The program will use Java&#8217;s Integer.parseInt() method to convert the octal string to a decimal integer and then output the result.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Scanner;\n\npublic class OctalToDecimal {\n    public static void main(String&#91;] args) {\n        \/\/ Create a scanner object to read input\n        Scanner scanner = new Scanner(System.in);\n        \n        \/\/ Ask the user for an octal number\n        System.out.print(\"Enter an octal number: \");\n        String octal = scanner.nextLine();\n        \n        \/\/ Convert the octal string to a decimal integer using parseInt method\n        try {\n            int decimal = Integer.parseInt(octal, 8);  \/\/ The second parameter (8) denotes the base (octal)\n            System.out.println(\"The decimal equivalent is: \" + decimal);\n        } catch (NumberFormatException e) {\n            System.out.println(\"Invalid octal number entered.\");\n        }\n\n        \/\/ Close the scanner\n        scanner.close();\n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q24. Write a Java program to find the spiral traversal of a matrix.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>The task is to traverse a matrix in a spiral order, starting from the top-left corner and moving right, down, left, and up repeatedly until all elements are traversed. The Java program will implement this traversal and print the elements in the correct spiral order.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.*;\n\npublic class SpiralTraversal {\n\n    \/\/ Function to print the spiral traversal of a matrix\n    public static void spiralTraversal(int&#91;]&#91;] matrix) {\n        if (matrix == null || matrix.length == 0) {\n            return;\n        }\n\n        \/\/ Define boundaries\n        int top = 0, bottom = matrix.length - 1;\n        int left = 0, right = matrix&#91;0].length - 1;\n\n        \/\/ List to store the spiral order\n        List&lt;Integer&gt; result = new ArrayList&lt;&gt;();\n\n        \/\/ Traverse the matrix in a spiral order\n        while (top &lt;= bottom &amp;&amp; left &lt;= right) {\n            \/\/ Traverse from left to right along the top row\n            for (int i = left; i &lt;= right; i++) {\n                result.add(matrix&#91;top]&#91;i]);\n            }\n            top++; \/\/ Move the top boundary down\n\n            \/\/ Traverse from top to bottom along the right column\n            for (int i = top; i &lt;= bottom; i++) {\n                result.add(matrix&#91;i]&#91;right]);\n            }\n            right--; \/\/ Move the right boundary left\n\n            if (top &lt;= bottom) {\n                \/\/ Traverse from right to left along the bottom row\n                for (int i = right; i &gt;= left; i--) {\n                    result.add(matrix&#91;bottom]&#91;i]);\n                }\n                bottom--; \/\/ Move the bottom boundary up\n            }\n\n            if (left &lt;= right) {\n                \/\/ Traverse from bottom to top along the left column\n                for (int i = bottom; i &gt;= top; i--) {\n                    result.add(matrix&#91;i]&#91;left]);\n                }\n                left++; \/\/ Move the left boundary right\n            }\n        }\n\n        \/\/ Print the result\n        for (int num : result) {\n            System.out.print(num + \" \");\n        }\n    }\n\n    \/\/ Main method to test the spiral traversal\n    public static void main(String&#91;] args) {\n        \/\/ Sample matrix for testing\n        int&#91;]&#91;] matrix = {\n            {1, 2, 3},\n            {4, 5, 6},\n            {7, 8, 9}\n        };\n\n        \/\/ Call the function to print spiral traversal\n        spiralTraversal(matrix);\n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q25. Write a Java code to print the first N Fibonacci numbers.<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>In this task, we need to write a Java program to print the first N Fibonacci numbers. The program will take an input N and print the Fibonacci sequence up to that N-th number by using a loop and updating two variables to generate the sequence.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Scanner;\n\npublic class Fibonacci {\n\n    public static void main(String&#91;] args) {\n        \/\/ Create a Scanner object to read input\n        Scanner scanner = new Scanner(System.in);\n        \n        \/\/ Prompt the user to input N\n        System.out.print(\"Enter the number of Fibonacci numbers to print: \");\n        int N = scanner.nextInt();\n        \n        \/\/ First two Fibonacci numbers\n        int first = 0, second = 1;\n\n        System.out.println(\"The first \" + N + \" Fibonacci numbers are:\");\n\n        \/\/ Print the first N Fibonacci numbers\n        for (int i = 0; i &lt; N; i++) {\n            if (i == 0) {\n                System.out.print(first + \" \");\n                continue;\n            }\n            if (i == 1) {\n                System.out.print(second + \" \");\n                continue;\n            }\n            \/\/ Calculate the next Fibonacci number\n            int next = first + second;\n            System.out.print(next + \" \");\n            \n            \/\/ Update the values of first and second\n            first = second;\n            second = next;\n        }\n\n        scanner.close();\n    }\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Also Read:<\/strong> <a href=\"https:\/\/internshala.com\/blog\/how-to-get-a-job-in-infosys\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to get Job at Infosys?<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q26. Write a Java code to find the first non-repeating character from a stream of characters.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>This task asks us to find the first non-repeating character from a stream of characters in a Java program. The program will use a map to track the frequency of each character and then identify the first character with a count of 1 as the first non-repeating character.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.*;\n\npublic class FirstNonRepeatingCharacter {\n    \n    public static void main(String&#91;] args) {\n        \/\/ Test the function with an example\n        String stream = \"aabccdbd\";\n        System.out.println(\"First non-repeating character: \" + firstNonRepeating(stream));\n    }\n    \n    public static char firstNonRepeating(String stream) {\n        \/\/ Map to store frequency of each character\n        Map&lt;Character, Integer&gt; charCount = new LinkedHashMap&lt;&gt;();\n        \n        \/\/ Iterate over the stream\n        for (char ch : stream.toCharArray()) {\n            \/\/ Update the frequency count for each character\n            charCount.put(ch, charCount.getOrDefault(ch, 0) + 1);\n        }\n        \n        \/\/ Iterate over the map to find the first non-repeating character\n        for (Map.Entry&lt;Character, Integer&gt; entry : charCount.entrySet()) {\n            if (entry.getValue() == 1) {\n                return entry.getKey();\n            }\n        }\n        \n        \/\/ If no non-repeating character exists\n        return '\\0';  \/\/ Return null character if no unique character is found\n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q27. Write a Java code to remove duplicates from a sorted array.&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>The task requires writing a Java program to remove duplicates from a sorted array. The program will traverse through the sorted array, comparing consecutive elements, and shift unique elements to the front of the array. It will then return the new length of the array after removing duplicates.<\/p>\n\n\n\n<p>Here is the code to implement this solution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class RemoveDuplicates {\n    public static int removeDuplicates(int&#91;] nums) {\n        \/\/ Check if the array is empty or contains only one element\n        if (nums == null || nums.length == 0) {\n            return 0;\n        }\n        \n        int uniqueIndex = 1; \/\/ Start from the second element\n        \n        \/\/ Traverse through the sorted array\n        for (int i = 1; i &lt; nums.length; i++) {\n            \/\/ If current element is not equal to previous element, add it to the unique position\n            if (nums&#91;i] != nums&#91;i - 1]) {\n                nums&#91;uniqueIndex] = nums&#91;i];\n                uniqueIndex++;\n            }\n        }\n        \n        \/\/ Return the new length of the array without duplicates\n        return uniqueIndex;\n    }\n\n    public static void main(String&#91;] args) {\n        int&#91;] nums = {1, 1, 2, 2, 3, 3, 4}; \/\/ Example sorted array\n        int length = removeDuplicates(nums);\n\n        \/\/ Print the array after removing duplicates\n        System.out.println(\"Array after removing duplicates:\");\n        for (int i = 0; i &lt; length; i++) {\n            System.out.print(nums&#91;i] + \" \");\n        }\n        System.out.println();\n        System.out.println(\"New length: \" + length);\n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q28. What is the difference between C++ and Java?&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong>C++ and <a href=\"https:\/\/internshala.com\/blog\/getting-started-with-java-basics-of-java\/\" target=\"_blank\" rel=\"noreferrer noopener\">Java<\/a> are both powerful programming languages, but they have different design and use cases. Here is a table illustrating the key differences between C++ and Java:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Features<\/strong><\/td><td><strong>C++<\/strong><\/td><td><strong>Java<\/strong><\/td><\/tr><tr><td>Primary Use<\/td><td>Originally designed for systems and application programming<\/td><td>Developed primarily for use in printing systems and supports network computing<\/td><\/tr><tr><td>Platform Dependency<\/td><td>C++ is platform-dependent, tailored for specific operating systems or hardware configurations<\/td><td>Java is platform-independent, runs on any device or OS with a compatible Java Virtual Machine (JVM)<\/td><\/tr><tr><td>Target Applications<\/td><td>Provides powerful tools for managing hardware resources and creating efficient applications<\/td><td>Ideal for developing distributed applications<\/td><\/tr><tr><td>Accessibility<\/td><td>More complex due to platform-specific considerations<\/td><td>More accessible for beginners, abstracts away platform-specific complexities<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Q29. Define class and object in C++.<\/h3>\n\n\n\n<p><strong>Sample Answer:<\/strong>&nbsp;In C++, a <strong>class<\/strong> is a user-defined data type that serves as a blueprint for creating objects. It combines both data and the functions that operate on that data. The variables that store the data within the class are referred to as data members, while the functions that operate on or manipulate these data members are known as member functions.<\/p>\n\n\n\n<p>An <strong>object <\/strong>is an instance of a class. Each object represents a specific realization or instantiation of the class, and it can be viewed as a unique example of the class.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q30. Explain some important differences between C and C++&nbsp;<\/h3>\n\n\n\n<p><strong>Sample Answer: <\/strong><a href=\"https:\/\/trainings.internshala.com\/blog\/difference-between-c-and-cpp\/\" target=\"_blank\" rel=\"noreferrer noopener\">C and C++<\/a> are both powerful programming languages, but they differ significantly in terms of features, design philosophy, and usage.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Aspect<\/strong><\/td><td><strong>C<\/strong><\/td><td><strong>C++<\/strong><\/td><\/tr><tr><td><strong>Paradigm<\/strong><\/td><td>C is a procedural language, focused on functions and structured programming. It emphasizes the use of procedures (functions) to operate on data, with a strong focus on step-by-step execution.<\/td><td>C++, on the other hand, is a multi-paradigm language that supports both procedural and object-oriented programming (OOP). It allows for the creation of classes, objects, and methods, making it more suited for complex systems.<\/td><\/tr><tr><td><strong>Object-Oriented Features:<\/strong><\/td><td>C lacks native support for classes, objects, inheritance, polymorphism, and encapsulation, which are central concepts in object-oriented programming.<\/td><td>C++ incorporates these features, enabling more modular and reusable code. The ability to use classes and objects enhances code organization and maintenance.<\/td><\/tr><tr><td><strong>Memory Management:<\/strong><\/td><td>C provides manual memory management using functions like malloc() and free().<\/td><td>C++ introduces the concept of constructors and destructors for automatic memory management and the new and delete operators to allocate and deallocate memory dynamically.<\/td><\/tr><tr><td><strong>Standard Libraries:<\/strong><\/td><td>C has a smaller standard library, primarily focusing on basic functionalities like input\/output, memory management, and string manipulation.<\/td><td>C++ offers a richer standard library, including the Standard Template Library (STL), which provides data structures like vectors, lists, and algorithms for efficient programming.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large desktop-image\"><a href=\"https:\/\/internshala.com\/jobs\/?utm_source=is_blog&amp;utm_medium=infosys-coding-interview-questions-and-answers&amp;utm_campaign=candidate-web-banner\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"203\" src=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1024x203.jpg\" alt=\"Find and Apply Banner\" class=\"wp-image-21795\" srcset=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1024x203.jpg 1024w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-672x133.jpg 672w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1536x305.jpg 1536w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-2048x406.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full mobile-image\"><a href=\"https:\/\/internshala.com\/jobs\/?utm_source=is_blog&amp;utm_medium=infosys-coding-interview-questions-and-answers&amp;utm_campaign=candidate-mobile-banner\"><img loading=\"lazy\" decoding=\"async\" width=\"356\" height=\"256\" src=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Job-Banner-for-candidates.jpg\" alt=\"Job Banner for candidates\" class=\"wp-image-21794\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Preparing for Infosys coding questions requires a blend of strong problem-solving skills, an understanding of algorithms, and consistent practice. By focusing on key concepts such as data structures, time complexity, and coding patterns, candidates can enhance their chances of success. Regularly practising on coding platforms and developing a systematic approach will ensure you&#8217;re well-prepared to confidently tackle Infosys&#8217;s coding interviews. If you are interested in C++ coding jobs, check our blog on the <a href=\"https:\/\/internshala.com\/blog\/cpp-coding-interview-questions\/\" target=\"_blank\" rel=\"noreferrer noopener\">C++ coding interview questions <\/a>to ace your interview.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1734333185565\"><strong class=\"schema-faq-question\">Q1.<strong> Does Infosys ask the same coding questions repeatedly?<\/strong><\/strong> <p class=\"schema-faq-answer\"><strong>Answer:<\/strong> Infosys rarely repeats coding questions from previous years. However, the concepts and difficulty level of the questions tend to be similar in subsequent exams.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1734333204622\"><strong class=\"schema-faq-question\">Q2.<strong> Is Python utilized at Infosys?<\/strong><\/strong> <p class=\"schema-faq-answer\"><strong>Answer:<\/strong> Yes, Python is employed at Infosys, particularly in roles related to software development, automation, and data analysis. It is a widely used language for various projects within the organization.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1734333232817\"><strong class=\"schema-faq-question\">Q<strong>3. Does Infosys focus on DSA (Data Structures and Algorithms) in their interviews?<\/strong><\/strong> <p class=\"schema-faq-answer\"><strong>Answer:<\/strong> Yes, Infosys places a strong emphasis on DSA during its interview process. Candidates are frequently evaluated on their knowledge of data structures, algorithms, and problem-solving skills.<\/p> <\/div> <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Sources<\/h3>\n\n\n\n<ul>\n<li>https:\/\/www.infosys.com\/investors\/reports-filings\/quarterly-results\/2025-2026\/q3\/documents\/ifrs-inr-press-release.pdf<\/li>\n<\/ul>\n<aside class=\"mashsb-container mashsb-main \"><div class=\"mashsb-box\"><div class=\"mashsb-count mash-medium\" style=\"float:left\"><div class=\"counts mashsbcount\">0<\/div><span class=\"mashsb-sharetext\">SHARES<\/span><\/div><div class=\"mashsb-buttons\"><a class=\"mashicon-facebook mash-medium mashsb-noshadow\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Finternshala.com%2Fblog%2Finfosys-coding-interview-questions-and-answers%2F\" target=\"_top\" rel=\"nofollow\"><span class=\"icon\"><\/span><span class=\"text\">Share&nbsp;on&nbsp;Facebook<\/span><\/a><a class=\"mashicon-subscribe mash-medium mashsb-noshadow\" href=\"#\" target=\"_top\" rel=\"nofollow\"><span class=\"icon\"><\/span><span class=\"text\">Get&nbsp;Your&nbsp;Dream&nbsp;Internship<\/span><\/a><div class=\"onoffswitch2 mash-medium mashsb-noshadow\" style=\"display:none\"><\/div><\/div>\n            <\/div>\n                <div style=\"clear:both\"><\/div><\/aside>\n            <!-- Share buttons by mashshare.net - Version: 4.0.42-->","protected":false},"excerpt":{"rendered":"<p>You know? According to Infosys (IFRS-INR press release), the company added 5,043 employees in Q3 FY2026, taking its total workforce to 337,034. Infosys is one of the leading IT services<\/p>\n","protected":false},"author":6498,"featured_media":26129,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4316],"tags":[9240,9241],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Top 30 Infosys Coding Interview Questions and Answer (2026)<\/title>\n<meta name=\"description\" content=\"Find these top Infosys coding interview questions and answers that are mostly asked in the interview. Practise these questions to get your dream job.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Top 30 Infosys Coding Interview Questions and Answer (2026)\" \/>\n<meta property=\"og:description\" content=\"Find these top Infosys coding interview questions and answers that are mostly asked in the interview. Practise these questions to get your dream job.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/\" \/>\n<meta property=\"og:site_name\" content=\"Internshala blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-16T09:29:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-07T12:45:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/12\/infosys-coding-questions.png\" \/>\n\t<meta property=\"og:image:width\" content=\"390\" \/>\n\t<meta property=\"og:image:height\" content=\"255\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Shailja Kaushik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shailja Kaushik\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/\"},\"author\":{\"name\":\"Shailja Kaushik\",\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/person\/e9d693573cfd7df9145f7f1a0f6e523b\"},\"headline\":\"Top 30 Infosys Coding Interview Questions and Answer (2026)\",\"datePublished\":\"2024-12-16T09:29:05+00:00\",\"dateModified\":\"2026-04-07T12:45:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/\"},\"wordCount\":3278,\"publisher\":{\"@id\":\"https:\/\/internshala.com\/blog\/#organization\"},\"keywords\":[\"Infosys Coding Questions\",\"Infosys Coding Questions and Answers\"],\"articleSection\":[\"Interview Guide\"],\"inLanguage\":\"en-US\"},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/\",\"url\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/\",\"name\":\"Top 30 Infosys Coding Interview Questions and Answer (2026)\",\"isPartOf\":{\"@id\":\"https:\/\/internshala.com\/blog\/#website\"},\"datePublished\":\"2024-12-16T09:29:05+00:00\",\"dateModified\":\"2026-04-07T12:45:44+00:00\",\"description\":\"Find these top Infosys coding interview questions and answers that are mostly asked in the interview. Practise these questions to get your dream job.\",\"breadcrumb\":{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333185565\"},{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333204622\"},{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333232817\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/internshala.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Job Tips\",\"item\":\"https:\/\/internshala.com\/blog\/job-tips\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Interview Guide\",\"item\":\"https:\/\/internshala.com\/blog\/job-tips\/interview-guide\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Infosys Coding Interview Questions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/internshala.com\/blog\/#website\",\"url\":\"https:\/\/internshala.com\/blog\/\",\"name\":\"Internshala blog\",\"description\":\"Your favourite senior outside college\",\"publisher\":{\"@id\":\"https:\/\/internshala.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/internshala.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/internshala.com\/blog\/#organization\",\"name\":\"Internshala blog\",\"url\":\"https:\/\/internshala.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/08\/LOGO-1.png\",\"contentUrl\":\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/08\/LOGO-1.png\",\"width\":112,\"height\":31,\"caption\":\"Internshala blog\"},\"image\":{\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/person\/e9d693573cfd7df9145f7f1a0f6e523b\",\"name\":\"Shailja Kaushik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/09\/Shailja-Kaushik-96x96.jpg\",\"contentUrl\":\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/09\/Shailja-Kaushik-96x96.jpg\",\"caption\":\"Shailja Kaushik\"},\"description\":\"Shailja Kaushik has been an Editor with Internshala since March 2023. She loves creative writing and experimenting with different forms of writing. She has explored different genres by working with journals and radio stations. She has also published her poems and nano tales in various anthologies. She graduated at the top of her class with Bachelor's in English and recently completed her Master's in English from the University of Delhi. Her experiments with writing continue on her literary blog.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/shailja-kaushik\/\"],\"url\":\"https:\/\/internshala.com\/blog\/author\/shailja\/\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333185565\",\"position\":1,\"url\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333185565\",\"name\":\"Q1. Does Infosys ask the same coding questions repeatedly?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"<strong>Answer:<\/strong> Infosys rarely repeats coding questions from previous years. However, the concepts and difficulty level of the questions tend to be similar in subsequent exams.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333204622\",\"position\":2,\"url\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333204622\",\"name\":\"Q2. Is Python utilized at Infosys?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"<strong>Answer:<\/strong> Yes, Python is employed at Infosys, particularly in roles related to software development, automation, and data analysis. It is a widely used language for various projects within the organization.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333232817\",\"position\":3,\"url\":\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333232817\",\"name\":\"Q3. Does Infosys focus on DSA (Data Structures and Algorithms) in their interviews?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"<strong>Answer:<\/strong> Yes, Infosys places a strong emphasis on DSA during its interview process. Candidates are frequently evaluated on their knowledge of data structures, algorithms, and problem-solving skills.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Top 30 Infosys Coding Interview Questions and Answer (2026)","description":"Find these top Infosys coding interview questions and answers that are mostly asked in the interview. Practise these questions to get your dream job.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/","og_locale":"en_US","og_type":"article","og_title":"Top 30 Infosys Coding Interview Questions and Answer (2026)","og_description":"Find these top Infosys coding interview questions and answers that are mostly asked in the interview. Practise these questions to get your dream job.","og_url":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/","og_site_name":"Internshala blog","article_published_time":"2024-12-16T09:29:05+00:00","article_modified_time":"2026-04-07T12:45:44+00:00","og_image":[{"width":390,"height":255,"url":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/12\/infosys-coding-questions.png","type":"image\/png"}],"author":"Shailja Kaushik","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Shailja Kaushik","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#article","isPartOf":{"@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/"},"author":{"name":"Shailja Kaushik","@id":"https:\/\/internshala.com\/blog\/#\/schema\/person\/e9d693573cfd7df9145f7f1a0f6e523b"},"headline":"Top 30 Infosys Coding Interview Questions and Answer (2026)","datePublished":"2024-12-16T09:29:05+00:00","dateModified":"2026-04-07T12:45:44+00:00","mainEntityOfPage":{"@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/"},"wordCount":3278,"publisher":{"@id":"https:\/\/internshala.com\/blog\/#organization"},"keywords":["Infosys Coding Questions","Infosys Coding Questions and Answers"],"articleSection":["Interview Guide"],"inLanguage":"en-US"},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/","url":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/","name":"Top 30 Infosys Coding Interview Questions and Answer (2026)","isPartOf":{"@id":"https:\/\/internshala.com\/blog\/#website"},"datePublished":"2024-12-16T09:29:05+00:00","dateModified":"2026-04-07T12:45:44+00:00","description":"Find these top Infosys coding interview questions and answers that are mostly asked in the interview. Practise these questions to get your dream job.","breadcrumb":{"@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333185565"},{"@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333204622"},{"@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333232817"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/internshala.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Job Tips","item":"https:\/\/internshala.com\/blog\/job-tips\/"},{"@type":"ListItem","position":3,"name":"Interview Guide","item":"https:\/\/internshala.com\/blog\/job-tips\/interview-guide\/"},{"@type":"ListItem","position":4,"name":"Infosys Coding Interview Questions"}]},{"@type":"WebSite","@id":"https:\/\/internshala.com\/blog\/#website","url":"https:\/\/internshala.com\/blog\/","name":"Internshala blog","description":"Your favourite senior outside college","publisher":{"@id":"https:\/\/internshala.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/internshala.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/internshala.com\/blog\/#organization","name":"Internshala blog","url":"https:\/\/internshala.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/internshala.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/08\/LOGO-1.png","contentUrl":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/08\/LOGO-1.png","width":112,"height":31,"caption":"Internshala blog"},"image":{"@id":"https:\/\/internshala.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/internshala.com\/blog\/#\/schema\/person\/e9d693573cfd7df9145f7f1a0f6e523b","name":"Shailja Kaushik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/internshala.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/09\/Shailja-Kaushik-96x96.jpg","contentUrl":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/09\/Shailja-Kaushik-96x96.jpg","caption":"Shailja Kaushik"},"description":"Shailja Kaushik has been an Editor with Internshala since March 2023. She loves creative writing and experimenting with different forms of writing. She has explored different genres by working with journals and radio stations. She has also published her poems and nano tales in various anthologies. She graduated at the top of her class with Bachelor's in English and recently completed her Master's in English from the University of Delhi. Her experiments with writing continue on her literary blog.","sameAs":["https:\/\/www.linkedin.com\/in\/shailja-kaushik\/"],"url":"https:\/\/internshala.com\/blog\/author\/shailja\/"},{"@type":"Question","@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333185565","position":1,"url":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333185565","name":"Q1. Does Infosys ask the same coding questions repeatedly?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"<strong>Answer:<\/strong> Infosys rarely repeats coding questions from previous years. However, the concepts and difficulty level of the questions tend to be similar in subsequent exams.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333204622","position":2,"url":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333204622","name":"Q2. Is Python utilized at Infosys?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"<strong>Answer:<\/strong> Yes, Python is employed at Infosys, particularly in roles related to software development, automation, and data analysis. It is a widely used language for various projects within the organization.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333232817","position":3,"url":"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/#faq-question-1734333232817","name":"Q3. Does Infosys focus on DSA (Data Structures and Algorithms) in their interviews?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"<strong>Answer:<\/strong> Yes, Infosys places a strong emphasis on DSA during its interview process. Candidates are frequently evaluated on their knowledge of data structures, algorithms, and problem-solving skills.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/posts\/26118"}],"collection":[{"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/users\/6498"}],"replies":[{"embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/comments?post=26118"}],"version-history":[{"count":0,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/posts\/26118\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/media\/26129"}],"wp:attachment":[{"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/media?parent=26118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/categories?post=26118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/tags?post=26118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}