# IBM Coding Questions and Answers 2024 | PrepInsta

## IBM Coding Questions 2024

Here You can get all the IBM Coding Questions and Answers of IBM Coding Round.

Find All the latest 2024 IBM Coding Questions and Test Modules for Coding Round in IBM below.

 IBM Coding Questions 2 Questions Total Time 55 mins Types of Test Non Adaptive Negative Marking No ## IBM Coding Test Questions and Answers 2024

Total Number of Questions:-6 ( 2 Coding Questions)

Total Time Limit:-55 Mins

Coding

• C
• C++
• JAVA
• Python

MCQ’s

• DBMS
• Data structure
• Computer Networks
IBM Coding TestNumber of Questions
Code2 Questions
• Use Coupon Code “CT15” and get flat 15% OFF on your Prime Subscription plus:
• 1 month extra subscription on 3 & 6 months plans
• 2 months extra subscription on 12 & 24 months plans
• 3 months extra subscription on 36 & 48 months plan

## IBM PROGRAMMING PREVIOUS YEAR  QUESTIONS AND ANSWERS

Here are some questions that are asked in IBM for –

1. IBM C Programming Questions for On Campus
2. IBM Java Programming Questions for On Campus
3. IBM C++ Programming Questions for On Campus

## IBM Coding Questions and Answers

1. Write a program to find HCF of two numbers by without using recursion.

Input format:

The first line contains any 2 positive numbers separated by space.

Output format:

Print the HCF of given two numbers.

Sample Input:

70 15

Sample Output:

5

Run
```#include<iostream>
int gcd(int,int);
int main()
{
int m,n,ans;
scanf("%d",&m);
scanf("%d",&n);
while(m!=n)
{
if(m>n)
{
m=m-n;
}
else
{
n=n-m;
}
}
printf("%d",m);
return 0;
}```

Q2. Consider a string, S, that is a series of characters, each followed by its frequency as an integer. The string is not compressed correctly, so there may be multiple occurrences of the same character. A properly compressed string will consist of one instance of each character in alphabetical order followed by the total count of that character within the string.

Run
```import java.util.*;

public class Main {
public static String properCompression(String s) {
StringBuilder compressedStr = new StringBuilder();

for (int i = 0; i < s.length(); i += 2) { char c = s.charAt(i); int count = Character.getNumericValue(s.charAt(i + 1)); while (count > 0) {
compressedStr.append(c);
count--;
}
}

return compressedStr.toString();
}

public static void main(String[] args) {
String inputStr = "a3b5c2a2";
String compressedResult = properCompression(inputStr);
System.out.println(compressedResult);  // Output: "aaabbbbbcc"
}
}
```

Use Coupon Code “CT15” and get flat 15% OFF on your Prime Subscription plus:

• 1 month extra subscription on 3 & 6 months plans
• 2 months extra subscription on 12 & 24 months plans
• 3 months extra subscription on 36 & 48 months plan

Q3. Write a  C++ Program to Change Decimal Number to Binary?

Run
```#include<iostream>
namespace std;
int main ()
{
int a, n, i;
cout << "Enter the number to convert: ";
cin >> n;
for (i = 0; n > 0; i++)
{
a[i] = n % 2;
n = n / 2;
}
cout << "Binary of the given number= ";
for (i = i - 1; i >= 0; i--)
{
cout << a[i];
}
}
```

Q 4.C++ Program to generate Fibonacci Triangle

Run
```#include<iostream>
using namespace std;
int main()
{
int a=0,b=1,i,c,n,j;
cout<<"Enter the limit: ";
cin>>n;
for(i=1; i<=n; i++)
{
a=0;
b=1;
cout<<b<<"\t";
for(j=1; j<i; j++)
{
c=a+b;
cout<<c<<"\t";
a=b;
b=c;
}
cout<<"\n";
}
return 0;
}  ```

Q 5. What is the Output of the program

Run

```include
Using namespace std;
int main()
{
int a=5,b=10,c=15;
int*arr[]={&a,&b,&c};
cout<<arr;
return 0;
}```
• 5
• 10
• 15
• It will print their address of variable b.

Q 6. What is the Output of the program

Run

```include
Using namespace std;
int main()
{
Char arr;
int i;
for(i=0;i<10;i++)
*(arr+i)=65 +1;
*(arr+i)=0;
cout<<arr;
return(o);
}```
• ABCDEFGHIJ
• AAAAAAAAAA
• JJJJJJJJ
• None of the above
`Solution:-A`

Q 7. What is the Output of the program

Run

```#include<iostream>
Using namespace std;
int main()
{
char*ptr;
Char Str[]="abcdefg";
ptr=Str;
ptr+=5;
cout<<ptr;
return 0;
}```
• fg
• cdef
• defg
• abcd

Q8. For each element of an array of non-negative integers, arrin], is calculated as:
prefli] = arr[1JIJ⊕ arrl2JIJO . . . ⊕arrli]
Here x ⊕ y is the bitwise XOR of x and y. The array pref[n] contains the prefix XOR of all elements in arr[n]where 1 s is n.
1
2
Given the array pref, find the original array arr.
Note: There is always a unique arr for a given pref.

Run
```public class Main {
public static int[] findOriginalArray(int[] pref) {
int n = pref.length;
int[] arr = new int[n];

arr = pref;
for (int i = 1; i < n; i++) {
arr[i] = pref[i] ^ pref[i - 1];
}

return arr;
}

public static void main(String[] args) {
int[] pref = {3, 5, 2, 10};
int[] originalArray = findOriginalArray(pref);

System.out.print("Original Array: ");
for (int num : originalArray) {
System.out.print(num + " ");
}
// Output: Original Array: 3 8 10 2
}
}
```

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

(Use Coupon Code CT15 and get 15% off plus extra month subscription)

## FAQ

#### Question : What is the Difficulty Level of the Coding Paper of IBM?

Answer: The Coding paper difficulty is Medium to High is IBM Coding Test. If you want to prepare you can Prepare from our website Prepinsta.com

#### Question : In Which Languages You can solve the IBM Coding Test Paper?

Answer: You Can use these langugaes to solve Coding Test of IBM

• C
• C++
• JAVA
• Python

#### Question : How to Prepare for IBM Coding Test Paper?

Answer: You can Visit our website for IBM Coding Test paper.You will get many questions to solve the paper.

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

## Checkout list of all the video courses in PrepInsta Prime Subscription

### 5 comments on “IBM Coding Questions and Answers 2024 | PrepInsta”

• SAI KUMAR

where are the previous year qns 0
• PrepInsta Support

Hey!
Kindly refer IBM PYQ’s. Also if you want to prepare for IBM, text us right away at 8448440710. 1
• nithish kumar

This is good experience for me
And this is good 0
• PrepInsta Support

Hey💖
We are so glad that you liked it.☺ 0
• sheetal Bhagat

this all program is sufficient for IBM coding round?? 0