Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

DAILY TEST | NEW PLATFORM | CODING | 29 AUG

 CODING

 

1.

 

CANDLES:

PYTHON CODE:

a =int(input())
if(a<=5):
    print("NUMBER OF CANDIES SOLD : ",a)
    print("NUMBER OF CANDIES AVAILABLE : ",10-a)

 

 

2.

Caesar Cipher Coding Question

C CODE:

#include <stdio.h>
int main()
{
    char str[100];
    int key, i=0, left;
    printf("Enter your plain text : ");
    scanf("%[^\n]s",str);
    printf("Enter the key : ");
    scanf("%d",&key);
    if(key==0)
    {
        printf("INVALID INPUT");
    }
    else
    {
        while(str[i]!='\0')
        {
            //printf("%d\n", str[i]);
            if(str[i]>=48 && str[i]<=57)
            {
                if(str[i]+key<=57)
                {
                    str[i] = str[i] + key;
                }
                else
                {
                    left = (str[i] + key) - 57;
                    str[i] = 47 + left;
                }   
            }
            else if(str[i]>=65 && str[i]<=90)
            {
                if(str[i]+key<=90)
                {
                    str[i] = str[i] + key;
                }
                else
                {
                    left = (str[i] + key) - 90;
                    str[i] = 64 + left;
                }  
            }
            else if(str[i]>=97 && str[i]<=122)
            {
                if(str[i]+key<=122)
                {
                    str[i] = str[i] + key;
                }
                else
                {
                    left = (str[i] + key) - 122;
                    str[i] = 96 + left;
                }
            }
            i++;
        }
        printf("The encrypted text is : %s",str);
   }
   return 0;
}

---------------------------------------------------------------------------------------------------------------------

 

 


    

Post a Comment

Previous Post Next Post