Wipro Coding Question Solve

Application ID

In an online exam the test paper set is categorized by the letters A-Z. The students enrolled in the exam have been assigned a numeric value called application ID.  To assign the test set to the student, firstly the sum of all the digits in the application ID is calculated. If the sum is within the numeric range 1-26 the corresponding alphabetic set code is assigned to the student, else the sum of digits is calculated again and so on until the sum falls within the range of 1-26.

Input 1: 6442

Output 1: P

 

Input 2: 558823

Output 2: D

Code in Python

# cook your dish here
s=input("")
W="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
r=27
while r>26:
    x=[]
    for i in s:
        x.append(int(i))
    #print(x)
    r=sum(x)
    s=str(r)
    #print("r=",r)
    
    if r==0:
        print("Z")
    else:
        print(W[r-1])

Code in C

int digsum(int x)
{
int dsum=0;
while(x!=0)
{
dsum+=x%10;
x= x/10;
}
if(dsum>=1&&dsum<=26)
return dsum;
else
digsum(dsum);
}
int main()
{
int n,dsum=0;
scanf("%d",&n);
dsum=digsum(n);
printf("%c",'A'+dsum-1);
return 0;
}

Advertisement program

#include"stdio.h"
int main(void) {
long long int n;
scanf("%d",&n);
int sum = 0;
int r = 0;
while(n>0){
r = n%10;
if(r%2==0){
sum+=r;
}
n/=10;
}
printf("%d\n",sum);
return 0;
}

K-th shortest execution time

#include"stdio.h"
int main()
{
int n,k,j,temp;
scanf("%d %d",&n,&k);
int a[n],i;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("%d",a[k-1]);
return 0;
}

Count of Unique Authors

int main()
{
int no;
scanf("%d",&no);
int max = 10;
int rem;
while(no){
rem = no%10;
if(rem<max){
max= rem;
}
no/=10;
}
printf("%d",max);
}

Algorithm of Toy Manufacture

#include"stdio.h"
void mergeSort(int A[],int lb,int up)
{
int mid;
if(lb<up){
mid = (lb+up)/2;
mergeSort(A,lb,mid);
mergeSort(A,mid+1,up);
merge(A,lb,mid,up);
}
}
void merge(int A[],int lb,int mid, int up)
{
int i,j,k,b[up];
i = lb;
j = mid+1;
k = lb;
while(i<=mid&&j<=up)
{
if(A[i]<=A[j])
{
b[k] = A[i];
i++;
k++;
}
else
{
b[k] = A[j];
j++;
k++;
}
}
if (i>mid)
{
while(j<=up)
{
b[k] = A[j];
j++;
k++;
}
}
else
{
while(i<=mid)
{
b[k] = A[i];
i++;
k++;
}
}
for(i= lb;i<=up;i++)
{
A[i]=b[i];
}
}
int main(){
int n,m;
scanf("%d %d",&n,&m);
int arr[n];
int i;
for(i = 0;i<n;i++){
scanf("%d",&arr[i]);
}
mergeSort(arr,0,n-1);

printf("%d",arr[m-1]);
}

Bank Transaction- Credit Card Debit Card

#include <bits/stdc++.h>
using namespace std;
bool isCredit(char c){
return (c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='u' || c=='U' ||c=='o' || c=='O');
}
int func(string str){
int n=str.length();
int count=0;
for(int i=1;i<n;i++){
if(!isCredit(str[i]) && isCredit(str[i-1]))
count++;
}
return count;
}
int main(){
string str;
cin>>str;
cout<<func(str);
}

E-Commerce Code

#include"stdio.h"
void main() {
int n;
scanf("%d", &n);
if (n >= 30 && n <= 50)
printf("D");
elseif(n >= 51 && n <= 60)
printf("C");
elseif(n >= 61 && n <= 80)
printf("B");
elsif(n >= 81 && n <= 100)
printf("A")
}
Recent Posts

Leave a Comment

Your email address will not be published. Required fields are marked *