Wednesday, 1 Dec 2021
Category: School Programming

Given a positive integer N, the task is to check whether all the digits of the given integer N are the same or not. If found to be true, then print Yes. Otherwise, print No.Examples:Input: N = 222Output: YesInput: N = 232Output: NoNaive Approach: The simplest approach to solve the given problem is to iterate […]

Program to calculate Kinetic Energy and Potential EnergyGiven three integers M, H, and V representing the mass, velocity, and height of an object respectively the task is to calculate its Kinetic Energy as well as its Potential Energy,Note: The value of acceleration due to gravity (g) is 9.8 and ignore units.   Examples:Input: M = 25, […]

#include using namespace std;  void crossProduct(int vect_A[],                  int vect_B[],                  int cross_P[]){        cross_P[0]        = vect_A[1] * vect_B[2]          – vect_A[2] * vect_B[1];          cross_P[1]        = vect_A[2] * vect_B[0]          – vect_A[0] * vect_B[2];          cross_P[2]        = vect_A[0] * vect_B[1]          – vect_A[1] * vect_B[0];}  void checkCollinearity(int x1, int y1,                       int z1, int x2,                       int y2, int z2){        int A[3] = { x1, y1, z1 };    int B[3] = { x2, y2, z2 };          int cross_P[3];          crossProduct(A, B, cross_P);              if (cross_P[0] == […]

Program to find the Magnitude of a VectorGiven three integers representing the X, Y, and Z coordinates of a 3-D vector, the task is to find the magnitude of that vector.Example:Input: X = 1, Y = 2, Z = 2Output: 3Explanation: Magnitude of the vector is equal to √9 =3Input: X = 0, Y = […]