💻
NPTEL • Introduction to Programming in C

Study Glance Blog

NPTEL - Introduction to Programming in C - Week 1:Assignment 1 Answers- 2025

C PROGRAMMING • WEEK 1

NPTEL - Introduction to Programming in C - Week 1:Assignment 1 Answers- 2025

NPTEL • Introduction to Programming in C

Week 1 : Assignments - NPTEL >> Introduction to Programming In C - 2025


Week 1 : Assignment 1 - Question 1

Given three distinct integers a b and c, write a C program to find the second largest number among them.

Solution :


#include<stdio.h>

int main()
{
  int a,b,c,val;
  scanf("%d %d %d",&a,&b,&c);
  if((a>=b && a<=c) || (a>=c && a<=b))
     val=a;
  else if((b>=a && b<=c) || (b>=c && b<=a))
    val=b;
   else
    val=c;
   printf("%d",val);
  return(0);
}


Week 1 : Assignment 1 - Question 2

Write a C program to convert a length given in centimeters into feet and inches.

Solution :


#include<stdio.h>

int main() {
    int cm;
    int feet;
    float inches;

    scanf("%d", &cm);

    
    // Add your code here
  	feet = cm/30.48;
  	inches = (cm-30.48*feet)/2.54;
    
    printf("%d %.2f", feet, inches);

    return 0;
}


Week 1 : Assignment 1 - Question 3

Write a C program to compute the area of a rectangle.
Use the formula: Area=Length×Breadth.

Solution :


#include<stdio.h>

int main()
{
  int l,b,a;
  scanf("%d %d",&l,&b);
  a=l*b;
  printf("%d",a);
  return (0);
}