NPTEL Problem Solving Through Programming In C - Programming Assignment 1 2 3 4 and 5 August-2023 Swayam

 

Week 3 : Programming Assignment 1

Due on 2023-08-17, 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-08-08, 21:27 IST
Select the Language for this assignment. 
#include <stdio.h>
#define PI 3.14
void main()
{
    int radius;
    float area;
    /* Enter the radius of a circle */
    scanf("%d", &radius);
 
/*Here the first part and the last part of the program is already written. 
You have to write only the middle portion by carefully considering the
variables used. You can use more variables if required but no other input and output
statements can be used as the test input and corresponding output is already provided. 
There are two public test cases which you can see and check whether your program is correct. 
There is also one or two private test cases, the result of which you cannot
see and which are used for evaluation purpose*/ 
/*For example in this program the middle part can be written as:
area = PI * radius * radius;  
in the space provided */
area = PI * radius * radius;
printf("Area of a circle = %5.2f", 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
42
Area of a circle = 5538.96
Area of a circle = 5538.96
Passed





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



Week 3 : Programming Assignment 2

Due on 2023-08-17, 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 2023-08-08, 21:30 IST
Select the Language for this assignment. 
#include <stdio.h>
int main()
{
    double number;
    scanf("%lf", &number); 
 
    /* The number is entered automatically from the test cases and executed */
    /* Write the rest of the code in the box below
    As the output should exactly match with the output mentioned in the test cases
    so copy and paste the following printf statements wherever and whichever is applicable
      printf("The number is 0.");
      printf("Negative number.");
      printf("Positive number.");  
    Do not use any other scanf statements */
    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
-50
Negative number.
Negative number.
Passed




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



Week 3 : Programming Assignment 3

Due on 2023-08-17, 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 2023-08-08, 21:32 IST
Select the Language for this assignment. 
#include <stdio.h>
int main()
{
    int number;
    scanf("%d", &number); /*An integer number is taken from the test case */
 
/* Write the rest of the program in the box provided below. As the output
should exactly match with the output provided in the test cases so use exactly the 
following printf statement wherever and whichever is applicable. 
 
printf("%d is even.", number);
printf("%d is odd.", number);
 
*/
   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
24
24 is even.
24 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 3 : Programming Assignment 4

Due on 2023-08-17, 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 2023-08-08, 21:35 IST
Select the Language for this assignment. 
#include <stdio.h>
int main()
{
    int n1, n2, n3;
 
    scanf("%d %d %d", &n1, &n2, &n3); /*Three numbers are accepted from the test case */
 
/*  Complete the code in the box provided below. Use printf statement as provided below:
printf("%d is the largest number.", n1);
It may be n1, n2 or n3.
*/
    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
80 -5 3
80 is the largest number.
80 is the largest number.
Passed





Private Test cases used for EvaluationStatus
Test Case 1
Passed


No comments

JavaFX Scene Builder

  This is an article about the JavaFX Scene Builder. You will get a short introduction about the installation and usage of the software. The...