Ticker

6/recent/ticker-posts

CPNM HOME WORK WITH ANSWERS

 


 CPNM- Home Work made by ece the wonders. Daily Home works will be Updated here . For more details contact to hemu😍the😍smart ***THANK YOU***   

HOME WORK DATE :- 04/07/2022

 Q1. Write a program to display percentage , average and grade by taking input as marks?

(A)   #include<stdio.h>

          void main ()

       {

float m1,m2,m3;

float per,avg;

float total;

printf(" enter the marks of MATHS ");

scanf("%f", &m1);

printf(" enter the marks of CPNM ");

scanf("%f", &m2);

printf("enter the marks of CHEMISTRY ");

scanf("%f", &m3);

total= m1+m2+m3;

printf("\n the total mark is %.2f ",total);

per = (total/300)*100;

avg = (total/3);

printf("\n the percentage mark is : %.2f ", per);

printf("\n the average mark  is: %.2f", avg);

if(per>=80) printf("\n Grade : A");

else if(per>=60) printf("\n Grade : B");

else if(per>=40) printf("\n Grade : C");

else if(per<40) printf("\n Fail ");

        }

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

Q2. Write a program to display the sequence from zero to 10 as 0 2 4 6...10 ?

(A)          #include <stdio.h>

int main() { int i; printf("Sequence of numbers between 0 to 10 :\n"); for (i = 0; i <= 10; i++) { if(i%2 == 0)                  { printf("%d ", i);                  } } return 0; }

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


HOME WORK DATE :- 01/07/2022

Q1 . Write a program to compute the roots of quadratic equation using if else statement ?

(A)   #include<stdio.h>

        #include<math.h>

          void main()

    {

  int a, b, c;

 float disc, root1, root2, real, imag;

printf("Enter the values of a, b and c\n");

 scanf("%d %d %d", &a, &b, &c);

 disc = ((b*b)-(4*a*c));

  if(disc > 0)

{

root1 = (-b + sqrt(disc))/(2*a);

root2 = (-b - sqrt(disc))/(2*a);

  printf("Roots are real and                complex\n");

printf("Root 1:\t%f\n", root1);

printf("Root 2:\t%f\n", root2);

}

else if(disc == 0)

{        root1 = root2 = -b/(2*a);

printf("Roots are equal\n");

printf("Root:\t%f\n", root1);   }

   else

    {

real = -b/(2*a);

imag = sqrt(-disc)/(2*a);

printf("Roots are imaginary\n");

printf("Root 1:\t%f + i%f\n", real, imag);

printf("Root 2:\t%f - i%f\n", real, imag); }

            }

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

Q2. Write a program to describe nested if else statement ?

(A)    #include<stdio.h>

           int main()

       {

int num;

     printf(" enter a integer to check  :");

        scanf("%d",&num);

if(num<10)

{

if(num==1)

{  

printf("The value is:%d\n",num);   }

else

{   

printf("The value is greater than 1");  }

   }

  else

 {    

printf("The value is greater than 10");            }

   return 0;

         }

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

Q3. Write a program to describe simple if statement ?

(A)   #include<stdio.h>

         int main()

        {

int num1=1;

int num2=2;

if(num1<num2)

{  

printf("num1 is smaller than num2");  

}

return 0;

         }

💖THANK YOU VISIT AGAIN💖

Post a Comment

1 Comments