Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Saturday, March 2, 2024

SEE C programming conditional program solution for grade 10

SEE C programming conditional program solution for grade 10


SEE C programming conditional program solution for grade 10


(It carries 4 Marks)

1. (Specification Grid 2077)

To check whether input number is odd or even.

#include<stdio.h>

int main()

{

          int n;

          printf("Enter any number=");

          scanf("%d",&n);

          if(n%2==0)

          printf("The entered number is even");

          else

          printf("The entered number is odd");

          return 0;

}

 

2.  (SEE 2078)  (Npabson pre-board exam 2080)

To check whether input number is positive, negative or neutral.

#include<stdio.h>

int main()

{

int n;

printf("Enter any number\n");

scanf("%d",&n);

if(n>0)

printf("\Positive no");

if(n<0)

printf("\n Negative no");

if(n==0)

printf("\n Netural no");

return 0;

}

 

3. To display the greatest number among the input three numbers.

#include<stdio.h>

    main()

    {

      int num1,num2,num3;

      printf("Enter three numbers\n");

      scanf("%d%d%d",&num1,&num2,&num3);

      if(num1>num2&&num1>num3)

          printf("%d is Grestest",num1);

      else if(num2>num1&&num2>num3)

          printf("%d is Greatest",num2);

      else

          printf("%d is Greatest",num3);

    }

 

4. To input any number and check whether the entered number is divisible by 5 but not by 11.

#include<stdio.h>

int main()

{

int a;

printf("Enter an integar=")

scan("%d",&a);

if(a%5==0&&a%11!=0)

printf("Divisible by 5 but not by 11");

else

print("Not required number")'

return 0;

}

 

 

5. To display the name of day on the basis of entered number 1 to 7. For example, 1 for Sunday.

#include<stdio.h>

int main()

{

int day;

printf (“Enter the number :”);

scanf (“%d”, &day);

switch (day)

{

          case 1:

                   printf (“Sunday\n”);

                    break;

          case 2:

                   printf (“Monday\n”);break;

          case 3:

                   printf (“Tuesday\n”);

                   break;

          case 4:

                   printf (“Wednesday\n”);

                   break;

          case 5:

                   printf (“Thursday\n”);

                   break;

          case 6:

                   printf (“Friday\n”);

                   break;

          case 7:

                   printf (“Saturday\n”);break;

          default:

                   printf (“Entered not match”);

}

return 0;

}

 

6. To input any two numbers and display their addition, subtraction, multiplication and division with the help of menu structure.

#include<stdio.h>

int main()

{

int a,b,ch,s;

printf("\n Enter any two numbers=");

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

printf("\n 1. Addition");

printf("\n 2. Subtraction");

printf("\n 3. Multiplication");

printf("\n 4. Division");

printf("\n Enter your choice (1-4)");

scanf("%d",&ch);

switch(ch)

{

case 1:

s=a+b;

printf("\n Sum of two numbers=%d",s);

break;

case 2:

s=a-b;

printf("\n The difference of two numbers = %d",s);

break;

case 3:

s=a*b;

printf("\n The multiplication of two numbers=%d",s);

break;

case 4:

s=a/b;

printf("\n The division of two numbers=%d",s);

break;

default:

printf("\n Invalid choice try again");

}

return 0;

}

 

7. To input cost of price(cp) and selling price(sp) and determine whether there is gain or loss.

#include<stdio.h>

#include<conio.h>

void main()

{

int CP,SP,loss,gain;

print("Enter value of CP and SP;"):

scanf("%d%d,&CP,&SP);

if(SP>CP)

{

gain=SP-CP;

print("Gain=Rs%d",gain);

}

else

{

loss=CP-SP;

printf("Loss=Rs%d",loss);

}

getch();

}

 

8. To find the commission amount on the basis of sales amount as the following conditions:

          Sales amount (Rs)                    Commission

                   0 -1000                                         5%

                   1001-2000                                    10%

                   >2000                                           12%

#include<stdio.h>

int main()

{

int sm,r,cm;

printf("\Enter sales amount\n");

scanf("%d",&sm);

if(sm>2000)

r=12;

else if(sm<2000 && sm>1000)

r=10;

else

r=5;

cm=(sm*r)/100;

printf("commission amount=%d",cm);

return 0;

}

 

9.WAP to check whether input number is prefect square or not

#include<stdio.h>

#include<math.h>

int main()

{

          int b,n;

          float a;

          printf("Enter any no");

          scanf("%d",&n);

          a=sqrt(n);

          b=a;

          if (a==b)

          printf("prefect square");

          else

          printf("not prefect square");

          return 0;

}

 

10 WAP to display the smallest number among the input three numbers.

#include<stdio.h>

   int main()

    {

      int num1,num2,num3;

      printf("Enter three numbers\n");

      scanf("%d%d%d",&num1,&num2,&num3);

      if(num1<num2&&num1<num3)

          printf("%d is smallest",num1);

      else if(num2<num1&&num2<num3)

          printf("%d is smallest",num2);

      else

          printf("%d is smallest",num3);

      return 0;

    }

 

11. WAP to input any three numbers and display the middle number among them.

#include<stdio.h>

   int main()

    {

      int num1,num2,num3;

      printf("Enter three numbers\n");

      scanf("%d%d%d",&num1,&num2,&num3);

      if(num1>num2 && num1<num3||num1<num2 && num1>num3)

          printf("%d is middle",num1);

      else if(num2>num1&&num2<num3||num2<num1&&num2>num3)

          printf("%d is middle",num2);

      else

          printf("%d is middle",num3);

      return 0;

    }

 

12. WAP to input percentage and display the result. (Assume pass percentage is 40 )

#include<stdio.h>

int main()

{

 float per;

printf(" Enter your percentage ");

scanf("%f",&per);

if(per>=40)

printf("Pass");

else

printf("Fail");

return 0;

}

 

13. To input a number and then print whether number is fully divisible by 5 or not.

#include<stdio.h>

int main()

{

int n,r;

printf(" Enter any number ");

scanf("%d",&n);

r=n%5;

if (r==0)

 printf("%d is divisible by 5",n);

else

printf("%d is not divisible by 5",n);

return 0;

}

 

14. WAP to input age display whether you can vote or not. (Assume 18 is the age for casting vote)

#include<stdio.h>

    int main()

    {

      int a;

      printf("enter age");

      scanf("%d",&a);

      if(a>=18)

      printf("You can vote");

      else

      printf("you cant vote");

return 0;

  }

15. WAP to display the greatest number among input two numbers.

#include<stdio.h>

int main()

{

            int a,b;

            printf("Enter two numbers\n");

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

            if(a>b)

            printf("Greatest no=%d",a);

            else

            printf("Greatest no=%d",b);

            return 0;

}

 

16. WAP to check whether input year is leap year or not.

#include<stdio.h>

int main()

{

           int y;

           printf("Enter the year\n");

           scanf("%d",&y);

           if((y%2==0)&&(y%100!=0)||(y%400==0))

           printf("%d is leap year",y);

           else

           printf("%d is not leap year",y);

           return 0;

}

17. To input a number and check whether the number is full divisible by 5 or not.

#include<stdio.h>

int main()

{

int num;

printf("Enter any number");

scanf("%d",&num);

if(num%5==0)

printf("Fully divisible by 5);

else

printf("Not fully divisible by 5);

return 0;

}

 

 

18. To input a number and then print whether number is fully divisible by 2 and 3 or not.

#include<stdio.h>

int main()

{

int n,r1,r2;

printf("Enter a number : ");

scanf("%d",&n);

r1=n%2;

r2=n%3;

if(r1==0&&r2==0)

printf(" %d is divisible by 2 and 3 ",n);

else

printf(" %d is not divisible by 2 and 3 ",n);

return 0;

}

 

19.  (SEE 2079)

Write a program in C-language that asks any two numbers and displays the greatest among them.

#include<stdio.h>

int main()

{

            int a,b;

            printf("Enter any two numbers: ");

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

            if(a>b)

            printf("greatest no: %d",a);

            else

            printf("Greaest no: %d",b);

            return 0;

}

 

20. PABSON SEE PRE-QUALIFING EXAMINATION-2080

 Write a 'C' program to input a character and check whether it is a vowel or consonant.

#include<stdio.h>

int main()

{

                char c;

                printf("Enter any character");

                scanf("%c",&c);

                if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')

                printf("vowel character");

                else

                printf("consonent character");

                return 0;

}

21. To input any three subject marks and display the result. (Assume pass marks is 35 in each subject)

#include<stdio.h>

int main()

{

            int x,y,z;

            printf("Enter three subject marks\n");

            scanf("%d%d%d",&x,&y,&z);

            if(x>=35 && y>=35 && z>=35)

            printf("Pass");

            else

            printf("Fail");

            return 0;

}

22. Write a c program to input any number and print the year, months, and days in the appropriate format.

#include <stdio.h>

int main() {

    int totaldays, years, months, days;

 

    // Asking for input

    printf("Enter the number of days: ");

    scanf("%d", &totaldays);

     // Calculating years, months, and days

    years = totaldays / 360;                    // A year has 360 days

    months = (totaldays % 360) / 30;    // A month has 30 days

    days = (totaldays % 360) % 30;      // Remaining days

     // Printing the result

    printf("%d days is equivalent to %d year(s), %d month(s), and %d day(s).\n", totaldays, years, months, days);

    return 0;

}

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages