MAKE THE SUSBCRIBERS 1000 and..
Don't Panic Everyone! Just Calm Down.. You have 6 Hours to complete those 6 Questions
Every Code will be uploaded.. But you have to share this Channel
SHARE THIS CHANNEL
Don't Panic Everyone! Just Calm Down.. You have 6 Hours to complete those 6 Questions
Every Code will be uploaded.. But you have to share this Channel
SHARE THIS CHANNEL
#include <stdio.h>
void swap(int *xp, int *yp) {
int temp = *xp;
*xp = *yp;
*yp = temp;
}
void bubbleSort(int arr[], int n, int arr2[]) {
int i,j;
for (i = 0; i < n-1; i++) {
for (j = 0; j < n-i-1; j++) {
if (arr[j] > arr[j+1]) {
swap(&arr[j], &arr[j+1]);
swap(&arr2[j], &arr2[j+1]);
}
}
}
}
int main() {
int n,i,j;
printf("Enter size of arrays: ");
scanf("%d", &n);
int a1[n], a2[n];
printf("\nEnter first array: ");
for ( i = 0; i < n; i++) {
scanf("%d", &a1[i]);
}
printf("\nEnter second array: ");
for ( i = 0; i < n; i++) {
scanf("%d", &a2[i]);
}
bubbleSort(a1, n, a2);
for ( i = 0; i < n; i++) {
printf("%d ", a2[i]);
}
return 0;
}
Bubble Sort C++ Working Code
TCS Codevita
Pls share
https://t.me/TCS_Codevita_Exam_Help
void swap(int *xp, int *yp) {
int temp = *xp;
*xp = *yp;
*yp = temp;
}
void bubbleSort(int arr[], int n, int arr2[]) {
int i,j;
for (i = 0; i < n-1; i++) {
for (j = 0; j < n-i-1; j++) {
if (arr[j] > arr[j+1]) {
swap(&arr[j], &arr[j+1]);
swap(&arr2[j], &arr2[j+1]);
}
}
}
}
int main() {
int n,i,j;
printf("Enter size of arrays: ");
scanf("%d", &n);
int a1[n], a2[n];
printf("\nEnter first array: ");
for ( i = 0; i < n; i++) {
scanf("%d", &a1[i]);
}
printf("\nEnter second array: ");
for ( i = 0; i < n; i++) {
scanf("%d", &a2[i]);
}
bubbleSort(a1, n, a2);
for ( i = 0; i < n; i++) {
printf("%d ", a2[i]);
}
return 0;
}
Bubble Sort C++ Working Code
TCS Codevita
Pls share
https://t.me/TCS_Codevita_Exam_Help
IBM Coding Exam Answers
Bubble Sort Solution https://www.youtube.com/shorts/xcmj7hifWro
EVERYONE SUBSCRIBE THIS CHANNEL 🔥
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
typedef struct {
int x, y;
} Point;
typedef struct {
char name[20];
Point location;
} Passenger;
typedef struct {
char number[20];
Point location;
} Vehicle;
int manhattanDistance(Point p1, Point p2) {
return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}
Vehicle* findNearestVehicle(Passenger passenger, Vehicle* vehicles, int m, int* assigned) {
int i;
int minDistance = INT_MAX;
Vehicle* nearestVehicle = NULL;
for (i = 0; i < m; i++) {
if (!assigned[i]) {
int distance = manhattanDistance(passenger.location, vehicles[i].location);
if (distance < minDistance || (distance == minDistance && strcmp(vehicles[i].number, nearestVehicle->number) < 0)) {
minDistance = distance;
nearestVehicle = &vehicles[i];
}
}
}
assigned[nearestVehicle - vehicles] = 1;
return nearestVehicle;
}
int main() {
int n, m,i;
scanf("%d %d", &n, &m);
Passenger passengers[n];
for ( i = 0; i < n; i++) {
scanf("%s %d %d", passengers[i].name, &passengers[i].location.x, &passengers[i].location.y);
}
Vehicle vehicles[m];
for ( i = 0; i < m; i++) {
scanf("%s %d %d", vehicles[i].number, &vehicles[i].location.x, &vehicles[i].location.y);
}
int assigned[m];
memset(assigned, 0, sizeof(assigned));
int totalDistance = 0;
for ( i = 0; i < n; i++) {
Vehicle* assignedVehicle = findNearestVehicle(passengers[i], vehicles, m, assigned);
totalDistance += manhattanDistance(passengers[i].location, assignedVehicle->location);
}
printf("%d\n", totalDistance);
return 0;
}
Solo Rider C++ Working Code
TCS Codevita
Pls share
https://t.me/TCS_Codevita_Exam_Help
#include <stdlib.h>
#include <string.h>
#include <limits.h>
typedef struct {
int x, y;
} Point;
typedef struct {
char name[20];
Point location;
} Passenger;
typedef struct {
char number[20];
Point location;
} Vehicle;
int manhattanDistance(Point p1, Point p2) {
return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}
Vehicle* findNearestVehicle(Passenger passenger, Vehicle* vehicles, int m, int* assigned) {
int i;
int minDistance = INT_MAX;
Vehicle* nearestVehicle = NULL;
for (i = 0; i < m; i++) {
if (!assigned[i]) {
int distance = manhattanDistance(passenger.location, vehicles[i].location);
if (distance < minDistance || (distance == minDistance && strcmp(vehicles[i].number, nearestVehicle->number) < 0)) {
minDistance = distance;
nearestVehicle = &vehicles[i];
}
}
}
assigned[nearestVehicle - vehicles] = 1;
return nearestVehicle;
}
int main() {
int n, m,i;
scanf("%d %d", &n, &m);
Passenger passengers[n];
for ( i = 0; i < n; i++) {
scanf("%s %d %d", passengers[i].name, &passengers[i].location.x, &passengers[i].location.y);
}
Vehicle vehicles[m];
for ( i = 0; i < m; i++) {
scanf("%s %d %d", vehicles[i].number, &vehicles[i].location.x, &vehicles[i].location.y);
}
int assigned[m];
memset(assigned, 0, sizeof(assigned));
int totalDistance = 0;
for ( i = 0; i < n; i++) {
Vehicle* assignedVehicle = findNearestVehicle(passengers[i], vehicles, m, assigned);
totalDistance += manhattanDistance(passengers[i].location, assignedVehicle->location);
}
printf("%d\n", totalDistance);
return 0;
}
Solo Rider C++ Working Code
TCS Codevita
Pls share
https://t.me/TCS_Codevita_Exam_Help
def generate_password(number, name):
# Check if the number is valid
if number <= 0:
return "Invalid input"
# Convert the number to scientific notation
scientific_notation = "{:.1e}".format(number)
# Simplify the digits after the decimal point to a single digit
decimal_digit = int(number * 10) % 10
# Simplify the exponent to a single digit
exponent_digit = int(abs(math.log10(number))) % 10
# Create S1 by concatenating the first three letters of each digit when expressed as words
s1 = ""
digits_as_words = get_digits_as_words(scientific_notation)
for i in range(0, len(digits_as_words), 3):
if i + 2 < len(digits_as_words):
s1 += digits_as_words[i:i+3]
else:
s1 += digits_as_words[i:]
# Create S2 by concatenating all the letters at odd positions in the given name
s2 = ""
for i in range(len(name)):
if (i + 1) % 2 != 0:
s2 += name[i]
# Check if the exponent digit is odd
if exponent_digit % 2 != 0:
return s1 + "@" + s2
else:
return s1
def get_digits_as_words(scientific_notation):
digits = ""
for char in scientific_notation:
if char.isdigit():
digits += get_word_for_digit(int(char))
else:
digits += char
return digits
def get_word_for_digit(digit):
words = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]
return words[digit]
# Test case
number = 3
name = "A"
password = generate_password(number, name)
print(password)
Password Generator Working Code
TCS Codevita
Pls share
https://t.me/TCS_Codevita_Exam_Help