IGNOU MCS-011 Problem Solving and Programming Solved Assignment 2021-22 Q1 | C Program using switch statement to provide the following functions

 IGNOU MCS-011 Problem Solving and Programming Solved Assignment 2021-22 | C Program using switch statement to provide the following functions

 

Course Code : MCS-011

Course Title : Problem Solving and Programming

Assignment Number : BCA(2)/011/Assignment/2021-22

Maximum Marks : 100

Weightage : 25%

Last Dates for Submission : 31st October, 2021 (For July Session)

15th April, 2022 (For January Session)


Q1: Write the following functions that: (2 ½ X 4 =10 Marks)
a) Request the user for two integers and outputs them and their sum.
b) Request the user for two integers and outputs their remainder after division.
c) Request the user for two floats and outputs their product.
d) Request the user for a word and prints it twice on the same row.
Write a C (main) program to provide the above functions as options to the user using switch statement and performs the functions accordingly.
Solution:

 #include<stdio.h>
#include<conio.h>

void sum(int x, int y)
 {
     printf("Sum of %d and %d is %d\n",x,y,(x+y) );
 }
 void rem(int x, int y)
 {
    printf("Remainder after division of  %d by %d is %d\n",x,y,x%y);
 }

 void prod(float x, float y)
 {
    printf("Product of %f and %f is %f\n",x,y,(x*y) );
 }

 void word(char s[])
 {
    printf("Print input word twice is %s %s\n",s,s );
 }

 void main()
  {
    int x,y,choice;
    float a,b;
    char str[15];
    clrscr();
    printf("Enter your choice\n");
    printf("Press 1 for Sum of two integers\n");
    printf("Press 2 for Remainder after division of two integers\n");
    printf("Press 3 for Product of two floats\n");
    printf("Press 4 for Print input word twice\n");
    scanf("%d",&choice);
    switch(choice)
    {
    case 1: printf("Enter the value of x and y\n");
        scanf("%d%d",&x,&y);
        sum(x,y);
        break;
    case 2: printf("Enter the value of x and y\n");
        scanf("%d%d",&x,&y);
        rem(x,y);
        break;
    case 3: printf("Enter the value of a and b\n");
                scanf("%f%f",&a,&b);
                prod(a,b);
                break;
        case 4: printf("Enter a word\n");
                scanf("%s",str);
                word(str);
                break;
        default: printf("Wrong choice\n");
     }
     getch();
  }

Note: You can understand for watching the video on YouTube Channel named as Gaurav Pali

and the link for this video

https://youtu.be/eGP8fDrJszw

 


Popular posts from this blog

IGNOU Solved Assignment 2023-24 | BCS-012 Basic Mathematics BCA(I)012/Assignment/2023-24

MCS-051 : ADVANCED INTERNET TECHNOLOGIES | 1. (a) Write a web application using JSP and JDBC that takes a bank account number as input and displays the account balance.

MCS054 TEE June 2021 Q1(b) | Bisection Method