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
Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
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 |
Total Number of Questions:-6 ( 2 Coding Questions)
Total Time Limit:-55 Mins
Coding
MCQ’s
IBM Coding Test | Number of Questions |
---|---|
Code | 2 Questions |
Crack IBM use Coupon Code “CT10” and get flat 10% OFF on your PrepInsta Prime Subscription.
Here are some questions that are asked in IBM for –
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
(Use Coupon Code PREPINSTA and get flat 30% off and an extrta month subscription free.)
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
#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.
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" } }
Crack IBM use Coupon Code “CT10” and get flat 10% OFF on your PrepInsta Prime.
Q3. Write a C++ Program to Change Decimal Number to Binary?
#include<iostream>
namespace std;
int main ()
{
int a[10], 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
#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
include Using namespace std; int main() { int a=5,b=10,c=15; int*arr[]={&a,&b,&c}; cout<<arr[1]; return 0; }
Q 6. What is the Output of the program
include Using namespace std; int main() { Char arr[20]; int i; for(i=0;i<10;i++) *(arr+i)=65 +1; *(arr+i)=0; cout<<arr; return(o); }
Solution:-A
Q 7. What is the Output of the program
#include<iostream> Using namespace std; int main() { char*ptr; Char Str[]="abcdefg"; ptr=Str; ptr+=5; cout<<ptr; return 0; }
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.
public class Main { public static int[] findOriginalArray(int[] pref) { int n = pref.length; int[] arr = new int[n]; arr[0] = pref[0]; 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 } }
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
Answer: You Can use these langugaes to solve Coding Test of IBM
Answer: You can Visit our website for IBM Coding Test paper.You will get many questions to solve the paper.
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
Get Hiring Updates right in your inbox from PrepInsta
By reading the qn,I think the code for Q2 is wrong.
import java.util.*;
public class Main {
public static String properCompression(String s) {
StringBuilder compressedStr = new StringBuilder();
int freq[] = new int[26];
for(int i=0;i<s.length();i+=2){
freq[s.charAt(i)-'a']+=(s.charAt(i+1)-'0');
}
for (int i = 0; i < 26; i ++) {
char c = (char)(i+'a');
int count = freq[i];
if(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: "a5b5c2"
}
}
Please join our discord community for the technical support.
where are the previous year qns
Hey!
Kindly refer IBM PYQ’s. Also if you want to prepare for IBM, text us right away at 8448440710.
This is good experience for me
And this is good
Hey💖
We are so glad that you liked it.☺
this all program is sufficient for IBM coding round??