Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please use C Code 1. String shuffle. Two strings a1 ···an and b1 ···bn with the

ID: 3668323 • Letter: P

Question

please use C Code

1. String shuffle. Two strings a1 ···an and b1 ···bn with the same length can be shuffled as a1b1 · · · anbn. Your program is to read two strings (with the same length) from the keyboard and print the shuffle out.

2. Transposition. A string with length k · m can be transposed as follows. First, we cut the string into k blocks, each of which is of length m. Then, we pick the first character from each block, pick the second character from each block, etc. The characters picked in this order form a string, called a (k, m)-transposition. For instance, let k = 3 and m = 2. For a given string abcdef, its transposition is acebdf. Your program is to read, from keyboard, k, m, and a string of length k · m, and then print its transposition out.

3. Two digit adder. Your program is going to read a string from keyboard, where the string is in the following format:

XX+YY=
where the XX and the YY are two-digit numbers. Your program is going to print out the sum (for instance, when the string is 13+31=, the output should be 44.). However, when the sum is bigger than 99, pls print out overflow instead.

Explanation / Answer

Program 1:

#include <stdio.h>

int main()
{
int size;
printf("Enter size :");
scanf("%d",&size);
  
char str1[size];
char str2[size];
printf("Enter string 1: ");
scanf("%s",&str1);
printf("Enter string 2: ");
scanf("%s",&str2);
int i=0;
for(;i<size;i++){
printf("%c%c",str1[i],str2[i]);
}
return 0;
}

Program 2:

#include <stdio.h>

int main()
{
int k,m;
printf("Enter k :");
scanf("%d",&k);
printf("Enter m :");
scanf("%d",&m);
int totalsize=k*m;
char str[totalsize];
char blocks[k][m];
printf("Enter string of size %d:",totalsize);
scanf("%s",str);
int i=0,j=0,l=0;
for(i=0;i<k;i++){
for(j=0;j<m;j++){
blocks[i][j]=str[l];
++l;
}
}
  
for(j=0;j<m;j++){
for(i=0;i<k;i++){
printf("%c",blocks[i][j]);
}
}
return 0;
  
}