NPTEL(14 Sep- 06 Nov) | Week 0: Assignment 1 ( Question 1 ,Question 2 & Question 3)Introduction to Programming in C 2020.

NPTEL(14 Sep- 06 Nov) | Week 0: Assignment 1 ( Question 1 ,Question 2 & Question 3)Introduction to Programming in C  2020.





Assignment 1 ->Question1:


You will be given 3 integers as input. The inputs may or may not be
 different from each other. 

You have to output 1 if sum of first two inputs is greater than the third input, 
and 0 otherwise

Input
-------------------------------------
Three integers separated by space.

Output
----------------------------------
1 if sum of first two inputs is greater than third input
0 otherwise

PROGRAM:

#include<stdio.h>

int a,b,c;

int main() { scanf("%d",&a); scanf("%d",&b); scanf("%d",&c); if((a+b)>c) { printf("1"); } else { printf("0"); } return 0; }


Assignment 1 ->Question2:


You are given two integers, say M and N.
You have to output 1, if remainder is 1 when N divides M 
otherwise output 0

Input----------------------------
Two integers, say M and N.

Output---------------------------------------------------
You have to output 1 if remainder is 1 when M/N.
You have to output 0 , otherwise.


PROGRAM:

#include<stdio.h>



int main()
{
    int m,n,div;
  
  scanf("%d",&m); 
  scanf("%d",&n);


   div=m%n;

if(div==1)
{
printf("1");
}
else
{
 printf("0");
}
  return 0;
}

Assignment 1 ->Question3:


Input : Triplet of three numbers (a,b,c)
Output : 1 if they are either in strictly increasing (a>b>c) or decreasing (a<b<c) order
              0, otherwise.


PROGRAM:

#include<stdio.h>

int a,b,c;

int main()
{

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


if((a>b && b>c)||(a<b && b<c))
{
printf("1");
}
else
{
 printf("0");
}
  return 0;
}


  FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.

No comments:

Post a Comment

If you have any problems related to solutions or any concept please let me know.

Copyright (c) 2020 Custom Programs All Right Reserved

Pages