Skip to main content

MINI TEST, MANIT Bhopal Dec 2022

 


Question 1:

Write a program that prints the word addition as "MANIT" using the ASCII value of individual characters.

Code

#include <stdio.h>

int main() {

    char a='M', b='A', c='N',d='I',e='T';

    int sum;

    sum = a+b+c+d+e;

    printf("Sum of %c+%c+%c+%c+%c is %d"

    ,a,b,c,d,e,sum);

     return 0;

}

Output:

Sum of M+A+N+I+T is 377


 

Question 2:
Write a program to find MIN and MAX without using IF-ELSE and take three values from the user.

 

Code

#include <stdio.h>

main()

{

    int a, b, c, Max, Min ;

 

    printf("Enter three numbers : ") ;

 

    scanf("%d %d %d", &a, &b, &c) ;

 

    Max = a > b ? (a > c ? a : c) : (b > c ? b : c) ;

    Min = a < b ? (a < c ? a : c) : (b < c ? b : c) ;

 

    printf("\nThe Biggest number is : %d \nThe Smallest number is : %d", Max, Min) ;

}

Output:

Enter three numbers : 45

87

12

The Biggest number is : 87

The Smallest number is : 12

 


Question 3:
Write a program to calculate profit or loss; where take input cost price and selling price.

Code

#include <stdio.h>

int main()

{

    int cp,sp, amt;

    printf("Enter cost price: ");

    scanf("%d", &cp);

    printf("Enter selling price: ");

    scanf("%d", &sp);

    if(sp > cp)

    {

        amt = sp - cp;

        printf("Profit = %d", amt);

    }

    else if(cp > sp)

    {

        amt = cp - sp;

        printf("Loss = %d", amt);

    }

    else

    {

        printf("No Profit No Loss.");

    }

    return 0;

}

Output:

Enter cost price: 1589

Enter selling price: 1200

Loss = 389

 



Question 4:
Write a programme to left shift by two bits of any number and also check the number dividing by 4 or not.

Code

#include <stdio.h>

 main()

{

    long number,  after_number;

 

    printf("Enter an integer \n");

    scanf("%d", &number);

    after_number = number << 2;

   

    printf("before Shift : %d \nAfter Shift : %d", number, after_number);

 

    if(after_number%4==0)

                printf("\nYes, Its Divisible by 4");

    else

                 printf("\nNo, Its notDivisible by 4");

   

}

Output:

Enter an integer

123

before Shift : 123

After Shift : 492

Yes, Its Divisible by 4

 


 Question 5:
Convert the following conversions:
B2O and B2H: 111100
D2B, D2O, and D2H: 819

Solution:

  



D2B: 819

Answer: 1100110011

D2O: 819

Answer: 1463

D2H: 819

Answer: 333

 



Comments

Popular posts from this blog

Flow Charts - What Is a Flow Chart? When to Use a Flowchart? Flowchart Symbols & Components

  Flow Charts     Flow charts are a useful tool in many situations, as we make a process easy to understand at a glance. Using just a few words and some simple symbols, they show clearly what happens at each stage and how this affects other decisions and actions.   What Is a Flow Chart?     In 1921, the Frank and Lillian presented what was only a "graphic-based method" in a presentation titled: “ Process Charts: First Steps in Finding the One Best Way to do Work ”, to members of the American Society of Mechanical Engineers (ASME). When to Use a Flowchart?     Flowchart is a very simple yet powerful tool to improve productivity in both our personal and work life. Here are some ways flowchart can be helpful:   ·      Document a process ·      Present solution to a problem ·      Brainstorm ideas in a meeting ·      Design an operation system ·    ...

Most Asked Pattern Programs in C

  Pattern Programs in C  

Generations-of-Computers

  What is a computer?            Computer is an advanced electronic device that takes raw data as an input from the user and processes it under the control of a set of instructions (called program), produces a result (output), and saves it for future use. This tutorial explains the foundational concepts of computer hardware, software, operating systems, peripherals, etc. along with how to get the most value and impact from computer technology. Functionalities of a Computer  There are three basic functionalities of a Computer System and they are  1. Input  2. Process  3. Output  But if we look at it in a very broad sense, any digital computer carries out the following five functions: Step 1 - Takes data as input.  Step 2 - Stores the data/instructions in its memory and uses them as required. Step 3 - Processes the data and converts it into useful information.  Step 4 - Generates the output.  Step 5 - Controls...