Home
  • C
  • C++
  • Java
  • Python
  • All Courses
  • About us
  • Home
  • C
  • C++
  • Java
  • Python
  • All Courses
  • About us
  • Contact
  • Privacy Policy

Swayam Solver

Learn Programming & Prepare for NPTEL Exams... Swayam Solver is your one-stop destination for NPTEL exam preparation.

NPTEL Problem Solving Through Programming In C - Programming Assignment | Jan-2023 Swayam

Posted on February 07, 2023

 Problem Solving Through Programming In C


Subscribe to our YouTube Channel :  Swayam Solver

  Please scroll down for latest Programs. 👇 




Week-03: Programing Assignment-01

Due on 2023-02-16, 23:59 IST
Write a C Program to calculates the area (floating point number with two decimal places) of a Circle given it’s radius (integer value). The value of Pi is 3.14.
[Marks for Week 3 Programming assignments will not be evaluated finally. This is for users to get familiar with programming in google course builder platform]
Your last recorded submission was on 2023-02-07, 16:14 IST
Select the Language for this assignment. 
1
#include <stdio.h>
2
#define PI 3.14
3
void main()
4
{
5
    int radius;
6
    float area;
7
    /* Enter the radius of a circle */
8
    scanf("%d", &radius);
9
 
10
/*Here the first part and the last part of the program is already written. 
11
You have to write only the middle portion by carefully considering the
12
variables used. You can use more variables if required but no other input and output
13
statements can be used as the test input and corresponding output is already provided. 
14
There are two public test cases which you can see and check whether your program is correct. 
15
There is also one or two private test cases, the result of which you cannot
16
see and which are used for evaluation purpose*/ 
17
/*For example in this program the middle part can be written as:
18
area = PI * radius * radius;  
19
in the space provided */
20
 
21
area = PI * radius * radius;
printf("Area of a circle = %5.2f\n", area);
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
7
Area of a circle = 153.86\n
Area of a circle = 153.86\n
Passed
Test Case 2
50
Area of a circle = 7850.00\n
Area of a circle = 7850.00\n
Passed





Private Test cases used for EvaluationStatus
Test Case 1
Passed




Week-03: Program-02

Due on 2022-08-18, 23:59 IST
Write a C program to check if a given Number is zero or Positive or Negative Using if...else statement.

[Week 3 programming assignments will not be considered for final evaluation]
Your last recorded submission was on 2022-08-13, 08:43 IST
Select the Language for this assignment. 
1
#include <stdio.h>
2
int main()
3
{
4
    double number;
5
    scanf("%lf", &number); 
6
    /* The number is entered automatically from the test cases and executed */
7
    /* Write the rest of the code in the box below
8
    As the output should exactly match with the output mentioned in the test cases
9
    so copy and paste the following printf statements wherever and whichever is applicable
10
      printf("The number is 0.");
11
      printf("Negative number.");
12
      printf("Positive number.");  
13
    Do not use any other scanf statements */
14
 
15
if (number <= 0.0)
    {
        if (number == 0.0)
            printf("The number is 0.");
        else
            printf("Negative number.");
    }
    else
        printf("Positive number.");
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
14.05
Positive number.
Positive number.
Passed
Test Case 2
0.45
Positive number.
Positive number.
Passed
Test Case 3
-0.9
Negative number.
Negative number.
Passed



Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed




Week-03: Program-03

Due on 2022-08-18, 23:59 IST
Write a C program to check whether a given number (integer) is Even or Odd.
[This program does not carry any marks.]
Your last recorded submission was on 2022-08-13, 08:44 IST
Select the Language for this assignment. 
1
#include <stdio.h>
2
int main()
3
{
4
    int number;
5
    scanf("%d", &number); /*An integer number is taken from the test case */
6
 
7
/* Write the rest of the program in the box provided below. As the output
8
should exactly match with the output provided in the test cases so use exactly the 
9
following printf statement wherever and whichever is applicable. 
10
 
11
printf("%d is even.", number);
12
printf("%d is odd.", number);
13
 
14
*/
15
 
16
if(number % 2 == 0)
        printf("%d is even.", number);
    else
        printf("%d is odd.", number);
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
116
116 is even.
116 is even.
Passed
Test Case 2
51
51 is odd.
51 is odd.
Passed



Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed





Week-03 Program-04

Due on 2022-08-18, 23:59 IST
Write a C Program to find the Largest Number (integer) among Three Numbers (integers) using IF and Logical && operator.
[Week 3 programming assignments will not be considered for final evaluation]
Your last recorded submission was on 2022-08-13, 08:44 IST
Select the Language for this assignment. 
1
#include <stdio.h>
2
int main()
3
{
4
    int n1, n2, n3;
5
 
6
    scanf("%d %d %d", &n1, &n2, &n3); /*Three numbers are accepted from the test case */
7
 
8
/*  Complete the code in the box provided below. Use printf statement as provided below:
9
printf("%d is the largest number.", n1);
10
It may be n1, n2 or n3.
11
*/
12
 
13
if( n1>=n2 && n1>=n3 )
        printf("%d is the largest number.", n1);
    if( n2>=n1 && n2>=n3 )
        printf("%d is the largest number.", n2);
    if( n3>=n1 && n3>=n2 )
        printf("%d is the largest number.", n3);
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
45 34 67
67 is the largest number.
67 is the largest number.
Passed
Test Case 2
-9 -4 -20
-4 is the largest number.
-4 is the largest number.
Passed



Private Test cases used for EvaluationStatus
Test Case 1
Passed



------------------------------------------------------------------------------------------------------------





Week-04: Programing Assignment-01

Due on 2023-02-23, 23:59 IST

Write a C Program to Find the Smallest Number among Three Numbers (integer values) using Nested IF-Else statement.
Select the Language for this assignment. 
1
#include <stdio.h>
2
int main()
3
{
4
    int n1, n2, n3; 
5
    scanf("%d %d %d", &n1, &n2, &n3); /* where three number are read from the test cases and are stored in the variable n1, n2 and n3 */
6
 
7
/* Complete the program to get the desired output */
8
/* Only use the printf statement given below to exactly match your output 
9
with the output cases. Change the variable n1 as required.
10
 
11
printf("%d is the smallest number.", n1);    //Copy and paste this printf statement wherever required. 
12
 
13
*/
14
 
15
if (n1<n2)
    {
        if(n1<n3)
            printf("%d is the smallest number.", n1);
        else
            printf("%d is the smallest number.", n3);
    }
    else
    {
        if(n2<n3)
            printf("%d is the smallest number.", n2);
        else
            printf("%d is the smallest number.", n3);
    }
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
20 30 10
10 is the smallest number.
10 is the smallest number.
Passed
Test Case 2
77 44 99
44 is the smallest number.
44 is the smallest number.
Passed




Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed




Week-04: Programing Assignment-02

Due on 2023-02-23, 23:59 IST

Write a program to find the factorial of a given number using while loop.
Select the Language for this assignment. 
1
#include<stdio.h>
2
void main()
3
{
4
    int n;
5
    long int fact;  /* n is the number whose factorial we have to find and fact is the factorial */
6
    scanf("%d",&n);  /* The value of n is taken from test cases */
7
 
8
/* complete the program. Use the printf statements in the format mentioned below 
9
to match your output exactly with output test cases 
10
 
11
printf("The Factorial of %d is : %ld",n,fact);
12
 
13
You can declare any other variables if required */
14
 
15
fact = 1;
for(int i=n;i>0;i--)
  fact*=i;
printf("The Factorial of %d is : %ld",n,fact);
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
5
The Factorial of 5 is : 120
The Factorial of 5 is : 120
Passed
Test Case 2
7
The Factorial of 7 is : 5040
The Factorial of 7 is : 5040
Passed




Private Test cases used for EvaluationStatus
Test Case 1
Passed



Week-04: Programing Assignment-03

Due on 2023-02-23, 23:59 IST

Write a Program to find the sum of all even numbers from 1 to N where the value of N is taken as input. [For example when N is 10 then the sum is 2+4+6+8+10 = 30]
Select the Language for this assignment. 
1
#include <stdio.h>  
2
void main()
3
{
4
int N, sum=0; 
5
scanf("%d", &N); /* The value of N is taken from the test cases */
6
 
7
/* Complete the program. Please use the printf statement given below to 
8
exactly match your output with the test cases.
9
 
10
printf("Sum = %d", sum);
11
 
12
*/
13
 
14
for(int i=2; i <= N; i=i+2)
  sum+=i;
printf("Sum = %d", sum);
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
10
Sum = 30
Sum = 30
Passed
Test Case 2
25
Sum = 156
Sum = 156
Passed





Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed




Week-04: Programing Assignment-04

Due on 2023-02-23, 23:59 IST

Write a C program to calculate the Sum of First and the Last Digit of a given Number. For example if the number is 1234 the result is 1+4 = 5.
Select the Language for this assignment. 
1
#include <stdio.h>
2
int main()
3
{
4
 
5
int N, First_digit, Last_digit;
6
 
7
scanf("%d", &N); //The number is accepted from the test case
8
 
9
Last_digit = N%10;
First_digit = N;

while(First_digit >=10)
{
    First_digit = First_digit/10;
}
0
printf("Sum of First and Last digit = %d", First_digit + Last_digit);
1
 
2
return 0;
3
}
4
 
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
2908
Sum of First and Last digit = 10
Sum of First and Last digit = 10
Passed
Test Case 2
56986
Sum of First and Last digit = 11
Sum of First and Last digit = 11
Passed





Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed



































































No comments:

Post a Comment

Keep your comments reader friendly. Be civil and respectful. No self-promotion or spam. Stick to the topic. Questions welcome.

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Contact Form

Name

Email *

Message *

Total Page views

750,011

Quick Links

  • Home
  • About
  • Contact
  • Privacy Policy

Follow us on

YouTube WhatsApp Telegram

Designed by Swayam Solver © 2024