Problem Solving Through Programming In C Week 4 Solutions 2024

ABOUT THE COURSE :

Problem Solving Through Programming In C Week 4 Solutions

Disclaimer: The answers to these questions are provided for educational and informational purposes only. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.

This course is aimed at enabling the students to
    1. Formulate simple algorithms for arithmetic and logical problems 
    2. Translate the algorithms to programs (in C language) 
    3. Test and execute the programs and correct syntax and logical errors
    4. Implement conditional branching, iteration and recursion
    5. Decompose a problem into functions and synthesize a complete program using divide and conquer approach
    6. Use arrays, pointers and structures to formulate algorithms and programs
    7. Apply programming to solve matrix addition and multiplication problems and searching and sorting problems
    8. Apply programming to solve simple numerical method problems, namely rot finding of function, differentiation of function and simple integration

Summary
Course Type Elective
Duration 12 weeks
Category Computer Science and Engineering
Start Date 22 Jan 2024
End Date 12 Apr 2024
Exam Registration Ends 16 Feb 2024
Exam Date 21 Apr 2024 IST

Assignment Solutions :
Programming Assignment :

Week-04: 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);
    }
}

Week-04: 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");
}

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

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

CRITERIA TO GET A CERTIFICATE :
  1. Average assignment score = 25% of average of best 8 assignments out of the total 12 assignments given in the course.
  2. Exam score = 75% of the proctored certification exam score out of 100
  3. Final score = Average assignment score + Exam score
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met,you will not get the certificate even if the Final score >= 40/100.

Join With Us On :

Join Now


Previous Year Questions Now to Boost Your Exam Performance

LOADS OF LOGIC