NPTEL Introduction to programming in C Assignment 1 Answers 2023? This article will help you with the answer to the National Programme on Technology Enhanced Learning (NPTEL) Course “ Introduction to programming in C Assignment 1 “
Below you can find the answers for Introduction to programming in C Assignment 1 Answers 2023
NPTEL Introduction to programming in C Assignment 1 Answers 2023:-
Q1. You have a certain number of 100 rupee notes, 10 rupee notes and 1 rupee notes with you.
There is an item you want to buy whose price is given to you.
Write a program to find if the item is affordable, that is the price of the item is less than or equal to the current money you have.
Input
—–
Four non negative integers.
The first input is an integer representing the number of 100 rupee notes.
The second input is an integer representing the number of 10 rupee notes.
The third input is an integer representing the number of 1 rupee notes.
The fourth input is an integer representing the price of the item.
Output
——
You have to output 1 if the item is affordable.
You have to output 0 if the item is not affordable.
Code:-
#include <stdio.h>
int main(){
int hundred , ten , one , price;
scanf("%d %d %d %d" , &hundred , &ten , &one , &price);
if(hundred <0 || ten<0 || one<0 || price<0){
printf("%d" ,0);
return 0;
}
if(price < (hundred*100 + ten*10 + one)){
printf("%d" , 1) ;
}
else{
printf("%d" , 0);
}
return 0;
}
Next Week Answers: Assignment 02
Q2. You are given two positive integers, say M and N.
Check whether M is an exact multiple of N, without using loops.
Input
—–
Two positive integers, say M and N.
Output
——
You have to output 0 if M is not a multiple of N.
You have to output 1 if M is a multiple of N.
Code:-
#include<stdio.h>
int main()
{
int M,N;
scanf("%d %d",&M,&N);
if(M%N==0)
printf("%d",(M/N)/2);
else
printf("0");
return 0;
}
Q3.Given three integers a b and c, find if they are strictly increasing/decreasing or not.
Input
——-
Triplet of three integers (a,b,c)
Output
———
You have to output 1 if they are either in strictly increasing (a>b>c) or decreasing (a<b<c) order.
Output 0, otherwise.
Code:-
Will be updated soon and notified on our telegram channel So Join
If there are any changes in answers will notify you on telegram so you can get 100% score, So Join
For other courses answers:- Visit
For Internship and job updates:- Visit
Disclaimer: We do not claim 100% surety of answers, these answers are based on our sole knowledge, and by posting these answers we are just trying to help students, so we urge do your assignment on your own.
if you have any suggestions then comment below or contact us at [email protected]
If you found this article Interesting and helpful, don’t forget to share it with your friends to get this information.