The program must accept a string value S and an integer N as the input. The program must remove the characters which are present at the positions of multiples of N and then print the modified string as the output.
Boundary Condition(s):
1 <= Length of S <= 100
2 <= N <= Length of S
Input Format:
The first line contains the string S and the integer N.
Output Format:
The first line contains the modified string.
Example Input/Output 1:
Input:
SQUIRRELED 3
Output:
SQIRELD
Explanation:
In the string SQUIRRELED, the characters which are present at the positions of multiples of 3 are U, R and E.
So remove the characters U, R and E in the string SQUIRRELED.
Hence the output is SQIRELD
Example Input/Output 2:
Input:
Banglore 2
Output:
Bnlr
#include <stdio.h>
#include <string.h>
int main() {
char s[100];
int a;
scanf("%s %d", s, &a);
for(int i = 0; s[i] != ' '; i++) {
if((i + 1) % a != 0) {
printf("%c", s[i]);
}
}
return 0;
}
s = input().strip()
a = int(input())
for i in range(len(s)):
if (i + 1) % a != 0:
print(s[i], end="")
import java.util.Scanner;
public class SkipCharacters {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String s = scanner.next();
int a = scanner.nextInt();
for(int i = 0; i < s.length(); i++) {
if((i + 1) % a != 0) {
System.out.print(s.charAt(i));
}
}
}
}
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
int a;
cin >> s >> a;
for(int i = 0; i < s.length(); i++) {
if((i + 1) % a != 0) {
cout << s[i];
}
}
return 0;
}