Problem Solving Through Programming In C Week4 Assignment 2024

Problem-Solving-Through-Programming-In-C-Week4-Assignment-2024

NPTEL Problem Solving Through Programming In C Week4 All Programming Assignment Solutions | Swayam Jan 2024. With the growth of Information and Communication Technology, there is a need to develop large and complex software.

ABOUT THE COURSE:

This course is aimed at enabling the students to:
  • Formulate simple algorithms for arithmetic and logical problems
  • Translate the algorithms to programs (in C language)
  • Test and execute the programs and  correct syntax and logical errors
  • Implement conditional branching, iteration and recursion
  • Decompose a problem into functions and synthesize a complete program using divide and conquer approach
  • Use arrays, pointers and structures to formulate algorithms and programs
  • Apply programming to solve matrix addition and multiplication problems and searching and sorting problems 
  • Apply programming to solve simple numerical method problems, namely rot finding of function, differentiation of function and simple integration
COURSE LAYOUT
    • Week 1 : Introduction to Problem Solving through programs, Flowcharts/Pseudo codes, the compilation process, Syntax and Semantic errors, Variables and Data Types
    • Week 2 : Arithmetic expressions, Relational Operations, Logical expressions; Introduction to Conditional Branching
    • Week 3 : Conditional Branching and Iterative Loops
    • Week 4 : Arranging things : Arrays
    • Week 5 : 2-D arrays, Character Arrays and Strings 
    • Week 6 : Basic Algorithms including Numerical Algorithms
    • Week 7 : Functions and Parameter Passing by Value
    • Week 8 : Passing Arrays to Functions, Call by Reference
    • Week 9 : Recursion
    • Week 10 : Structures and Pointers
    • Week 11 : Self-Referential Structures and Introduction to Lists
    • Week 12 : Advanced Topics

Once again, thanks for your interest in our online courses and certification. Happy learning!

Problem Solving through Programming In C Jan 2024

Practice Program – 1 : 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

				
					area = PI * radius * radius;
    /* Print the area with two decimal places */
    printf("Area of a circle = %.2f", area);
				
			

Problem Solving through Programming In C Jan 2024

Practice Program – 2 :  Write a C program to check if a given Number is zero or Positive or Negative Using if…else statement.

				
						if (number > 0) {
        printf("Positive number.");
    } else if (number < 0) {
        printf("Negative number.");
    } else {
        printf("Zero.");
    }
}
				
			

Problem Solving through Programming In C Jan 2024

Program-01 : Write a C Program to Find the Smallest Number among Three Numbers (integer values) using Nested IF-Else statement.

				
					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);
    }
}
				
			

Problem Solving through Programming In C Jan 2024

Program-02 : The length of three sides are taken as input. Write a C program to find whether a triangle can be formed or not. If not display “This Triangle is NOT possible.” If the triangle can be formed then check whether the triangle formed is equilateral, isosceles, scalene or a right-angled triangle. (If it is a right-angled triangle then only print Right-angle triangle do not print it as Scalene Triangle).

				
					if(a<(b+c)&&b<(a+c)&&c<(a+b))
    {
        if(a==b&&a==c&&b==c)
        printf("Equilateral Triangle");
          else if(a==b||a==c||b==c)
          printf("Isosceles Triangle");
          else   
    if((a*a)==(b*b)+(c*c)||(b*b)==(a*a)+(c*c)||(c*c)==(a*a)+(b*b))
        printf("Right-angle Triangle");
        else if(a!=b&&a!=c&&b!=c)
        printf("Scalene Triangle");
    }
    else
    printf("Triangle is not possible");
}
				
			

Problem Solving through Programming In C Jan 2024

Program-03 : Write a program to find the factorial of a given number using while loop

				
					int i=1;
fact = 1;
while(i<=n)
    {
        fact*=i;
        i++;
    }
    printf("The Factorial of %d is : %ld",n,fact);
}

				
			

Problem Solving through Programming In C Jan 2024

Program-04 : 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]

				
					 for(int i = 2; i <= N; i += 2)
{
    sum += i;
}
  printf("Sum = %d",sum);
}