questions_for_smvec
questions_for_smvec
Janu is good at handleing collection of numbers. For example u give her 2 sets of number list
she gives u the sum of the numbers in a set format ie, addition of array. Her friends wants to
perform the operation regarding the numbers they give. Janu accepted it and does the
addition of the array.
Input Format:
1. Number of rows.
2. Number of columns.
3. Values of the array1.
4. Values of the array2.
5. all should be integers.
Output Format:
Output consists of integer values of Resultant array list.
Constraints:
0<rows,columns<10
0<elements<500
Sample Input:
1
2
14
35
Sample Output:
49
Solution :
#include <stdio.h>
int main() {
scanf("%d", &array1[i][j]);
scanf("%d", &array2[i][j]);
return 0;
Test cases:
case = t1
input=1
2
output=4 9
case = t2
input=2
output=7 13
13 10
case = t3
input=3
5
45
20
29
30
26
46
56
27
11
39
56
62
74
96
75
82
92
output=16 84 76
91 104 122
case = t4
input=3
101
16
34
46
74
102
18
17
96
34
44
24
102
17
24
44
86
96
76
56
17
28
48
output=203 33 58 90
160 198 94 73
103 51 72 72
case = t5
input=2
100
406
562
321
28
94
62
74
32
47
97
108
Question 2:
Ram is small boy. His father gives him a number and ask him to calculate the sum of the digits in that
number till the answer comes in singe digit. As ram is a small boy he doesn't knows how to calculate. So
help him to Find the sum of the digits untill it reaches to single digit.
Input Format:
Constraints:
0<number<10^15
Sample Input:
2567
Sample Output:
Solution:
#include<stdio.h>
int main()
int n ;
scanf("%d",&n);
int sum = 0;
if(n == 0)
n = sum;
sum = 0;
}
sum += n % 10;
n /= 10;
printf("%d",sum);
return 0;
Test Cases:
case = t1
input=25678
output=1
case=t2
input=389178
output=9
case=t3
input=589123489
output=4
case=t4
input=314
output=8
case=t5
input=459
output=9
Question 3:
Embark on a journey to the mystical Prime Pyramid Valley, where each row of the pyramid is
adorned with the sacred prime numbers. You, the chosen programmer, have been entrusted
with the task of unveiling the secrets hidden in the patterns of prime numbers.
The Oracle of Prime Pyramid Valley has given you a challenge: Write a C program to print
the prime numbers in a half pyramid pattern. As you ascend each row, reveal the prime
numbers that guard the ancient wisdom. The fate of the valley lies in your coding skills. Can
you craft a program that not only prints the prime numbers but also creates an enchanting
pattern, reflecting the sacred harmony of the Prime Pyramid Valley
Input Format:
Input consists of number of rows to rows to be print.
Output Format:
Output shows the prime prime numbers in half pyramid pattern.
Sample Input:
4
Sample Output:
2
35
7 11 13
17 19 23 29
solution:
#include <stdio.h>
int main() {
int rows;
scanf("%d", &rows);
int count = 0;
int is_prime = 1;
if (num % j == 0) {
is_prime = 0;
break;
if (is_prime) {
count++;
num++;
printf("\n");
return 0;
Test cases:
case=t1
input=4
output=2
35
7 11 13
17 19 23 29
case=t2
input=11
output=2
35
7 11 13
17 19 23 29
31 37 41 43 47
53 59 61 67 71 73
199 211 223 227 229 233 239 241 251 257
263 269 271 277 281 293 307 311 313 317
case=t3
input=5
output=2
35
7 11 13
17 19 23 29
31 37 41 43 47
case=t4
input=7
output=2
35
7 11 13
17 19 23 29
31 37 41 43 47
53 59 61 67 71 73
case=t5
input=9
output=2
35
7 11 13
17 19 23 29
31 37 41 43 47
53 59 61 67 71 73
Question 4:
Imagine you are an apprentice in the kingdom of Harmonica, where the mystical Harmonic
Numbers hold the key to unlocking the secrets of harmonic resonance. The Harmonic King
has set forth a quest for you to unveil the harmonic patterns that lie hidden in the square of
wisdom.
Your task is to write a C program that crafts a square pattern using the magical Harmonic
Numbers. As you traverse the rows and columns, reveal the harmonic fractions that
resonate with the energies of the kingdom. Can you, the chosen programmer, decipher the
harmonic square pattern and harness the harmonious frequencies encoded within, thereby
unlocking the ancient wisdom of Harmonica?
Input Format:
Input consists of size of the square (no.of rows and columns)
Output Format:
Output shows the harmonic number in square pattern.
Sample Input:
3
Sample Output:
1\1 1\2 1\3
1\4 1\5 1\6
1\7 1\8 1\9
Solution:
#include <stdio.h>
int main()
int n;
scanf("%d", &n);
int count = 1;
if (count <= n * n) {
printf("1/%d\t", count);
count++;
} else {
break;
printf("\n");
return 0;
Test cases:
case=t1
input=3
case=t2
input=5
input=7
case=t4
input=2
output=1\1 1\2
1\3 1\4
case=t5
input=9
Question 5:
Imagine a futuristic world where a secret society of health enthusiasts has discovered a
hidden formula for unlocking the mysteries of well-being. You, a brilliant programmer, have
been chosen to decipher the code that lies within the Body Mass Index (BMI) – the key to
understanding one's health.
In this quest, you find a mysterious ancient device that prompts users to input their weight
and height. As you decipher the BMI algorithm, you unveil a magical number that holds the
secret to an individual's physical condition. Your mission is to write a C program that
calculates the BMI, providing a glimpse into the user's well-being.
Input Format:
Input consists of weight and height of a person in floating point.
1. weight of a person in kilogram.
2. height of the person in Centimeter.
Output Format:
1st shows the BMI of the person(correct it to 2 decimal places)
2nd prints the fitness condition of the person whether he/she is Normal weight, under weight
or obese.
Sample Input:
99
151
Sample Output:
43.42
Obese
Solution:
#include <stdio.h>
int main() {
// Calculate BMI
printf("%.2f\n", bmi);
printf("Underweight\n");
printf("Normal weight\n");
} else {
printf("Obese\n");
return 0;
Test cases:
case=t1
input=99
151
output=43.42
Obese
case=t2
input=50.6
161
output=19.52
Normal weight
case=t3
input=43
172
output=14.53
Underweight
case=t4
input=66.6
121
output=45.49
Obese
case=t5
input=40
134.5
output=22.11
Normal weight
Question 6 :
Once upon a time, in a quaint village, there was a mystical array that held the key to the
prosperity of the entire community. Legends spoke of an ancient algorithm, known only to a
few, that could rearrange the elements of this magical array in a peculiar way.
The village was facing a dilemma, and the elders believed that if they could rearrange the
array by placing elements at odd indices to even indices and vice versa, the hidden powers
within the array would bring about abundance and good fortune to the villagers.
Your task is to write a Java program to unlock the magic of the array. The villagers have
handed you the array, and you must create a program that performs the mysterious swap,
turning the ordinary array into an extraordinary source of prosperity for the entire village.
Can you decipher the ancient algorithm and bring prosperity to the village by rearranging
the elements of the mystical array?
Input Format:
An integer that indicates the number of elements in the array.
elements of array in integer.
Output Format:
Shows the rearranged array.
Constraints:
The size of the array should be greater than 1.
Sample Input:
5
2
4
5
6
3
Sample Output:
42653
Solution:
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n <= 1) {
return 1;
int arr[n];
scanf("%d", &arr[i]);
arr[i - 1] = temp;
return 0;
Testcases:
case=t1
input=5
output=4 2 6 5 3
case=t2
input=0
case=t3
input=8
42
65
88
90
97
67
75
output=65 42 90 88 67 97 75 5
case=t4
input=1
case=t5
input=10
90
65
45
36
98
100
345
93
In a mystical land, there were five wizards, each possessing a magical ring. These rings were
said to have special powers when their GCD (Greatest Common Divisor) was found. The
wizards decided to embark on a quest to uncover the combined magic within their rings.
The ancient scrolls spoke of a legendary algorithm hidden within the enchanted forest that
could reveal the GCD of any set of magical numbers. As a skilled programmer, you were
chosen to write a program that would unlock this mystical power.
Your task is to create a C program that takes the magical numbers from the wizards, finds
their GCD, and unveils the true potential of their rings. Can you decipher the ancient
algorithm and unleash the magical energy stored within the rings?
Input Format:
1. Enter the size of the array in integer(it is positive integer)
2. enter the elements of array.
Output Format:
Output prints the GCD of the array.
Sample Input:
4
15
25
35
45
Sample Output:
5
Solution:
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n <= 0) {
return 1;
int arr[n];
scanf("%d", &arr[i]);
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
gcd = a;
}
// Print the GCD of the array
printf("%d\n", gcd);
return 0;
Testcases:
case=t1
input=4
15 25 35 45
output=5
case=t2
input=3
24 36 48
output=12
case=t3
input=5
10
30
50
80
60
output=10
case=t4
input=1
27
output=27
case=t5
input=0
Question 8:
In the mystical land of Numerica, there existed a legendary puzzle known as the "Neon
Enigma." It was said that only numbers possessing a unique glow, known as "neon
numbers," could unlock the secrets hidden within the enchanted realm.
You, as the chosen one, embarked on a journey to decipher the Neon Enigma. Guided by an
ancient prophecy, you must develop a magical program that reveals whether a given
number carries the radiant essence of a neon number.
The Oracle of Numerica provided you with a clue: "When the sum of the digits of a number,
squared, mirrors the number itself, the glow of a neon number is revealed."
Can you craft a C program to uncover the neon numbers and unveil the mysteries of the
Neon Enigma?
Input Format:
Enter a positive integer number.
Output Format:
Output prints "Neon Number" or "Not a Neon Number"
Sample Input:
16
Sample Output:
Not a Neon Number
solution:
#include <stdio.h>
int main() {
scanf("%d", &num);
if (num <= 0) {
return 1;
square /= 10;
printf("Neon Number\n");
} else {
return 0;
Testcases:
case=t1
input=16
case=t2
input=9
output=Neon Number
case=t3
input=25
output=Neon Number
case=t4
input=12
input=0
output=Neon Number
Question 9:
In the enchanting land of Linguatopia, a mystical figure known as the "Word Weaver"
possessed the extraordinary ability to manipulate words with magical precision. Legends
spoke of an ancient artifact called the "Numeralbane," capable of removing numbers from
any word it touched.
As the chosen apprentice, your quest is to craft a magical program to emulate the powers of
the Numeralbane. Armed with a keyboard and your coding incantations, you embark on this
journey.
The Elders of Linguatopia guide you: "Create a C program that removes the numbers from a
single word, unleashing the true essence of linguistic magic."
Can you harness the power of the Numeralbane and become the Word Weaver's true
successor?
Input Format:
Enter a word with numbers as input.
Output Format:
Output shows the word without the numbers.
Sample Input:
A1r5u8n
Sample Output:
Arun
Solution:
#include <stdio.h>
int main() {
int index = 0;
// Input the word with numbers
scanf("%s", word);
result[index++] = word[i];
result[index] = '\0';
printf("%s\n", result);
return 0;
Testcases:
case=t1
input=A1r5u8n
output=Arun
case=t2
input=hell122o3worl4d
output=helloworld
case=t3
input=1e2leph4an5t
output=elephant
case=t4
input=123wo4r4l5d5of4c
output=worldofc
case=t5
input=h2a3i4ho5w2a4r5e8y0o8u
output=haihowareyou
Question 10:
In the futuristic city of Codeopolis, a brilliant scientist named Dr. Quantum has developed a
groundbreaking invention called the "Time-Shift Array." This array has the astonishing ability
to rearrange itself and remove specific elements across time.
As a keen explorer of code and technology, you receive a mysterious message from Dr.
Quantum, challenging you to create a program that utilizes the Time-Shift Array. Your
mission is to reverse the array and eradicate any remnants of numbers divisible by 2(even
number).
Embrace the challenge, dear coder, and embark on a journey through the temporal currents
of Codeopolis. Will you successfully manipulate the Time-Shift Array and unveil the future of
numeric sequences?
Input Format:
1st line contains the size of the array
from second line type the elements of array
Output Format:
Output shows the resultant array after reversing and removing of all even numbers
Sample Input:
3
12
33
55
Sample Output:
55 33
Solution:
#include <stdio.h>
int main() {
int n;
scanf("%d", &arr[i]);
return 0;
Testcases:
case=t1
input=3
12
33
55
output=55 33
case=t2
input=5
output=5 3 1
case=t3
input=6
2
44
88
90
output=
case=t4
input=4
19
37
55
output=55 37 19
case=t5
input=7
23
32
44
57
567
445