Old is Gold solution of Programming in C Class 12 Solution of 2074 Set B

Old is Gold solution of Programming in C Class 12 Solution of 2074 Set B

 

2074 Set B Q. n. no 1

a.      What is a switch case statement in C Program? Explain with examples.

Click here

b.     Explain For loop in C with examples

Click here

2074 Set B Q. n. no 2

Describe the syntax of array. Write a program to sort ten integer numbers in ascending order.

Describe the syntax of array.

Syntax of array

data_type variable[size];

Write a program to sort ten integer numbers in ascending order.

#include<stdio.h>

#include<conio.h>

void main()

{

          int num[10], i, j, temp;

          printf("\n Enter 10 integers");

          for(i=0;i<10;i++)

          {

                   scanf("%d", &num[i]);

          }

          for(i=0;i<10;i++)

          {

                   for(j=i+1;j<10;j++)

                   {

                             if(num[i]>num[j])

                             {

                                      temp=num[i];

                                      num[i]=num[j];

                                      num[j]=temp;

                             }

                   }

          }

          printf("\n Printing in ascending order");

          for(i=0;i<10;i++)

          {

                   printf("\n %d", num[i]);

          }

          getch();

}

Output

C program to sort 10 integers in ascending order


2074 Set B Q. n. no 3

What is the method of function declaration and call in C? Write a Program to find out given number is odd or even using function

What are the method of function declaration and call in C?

 Click here

Write a Program to find out given number is odd or even using function

#include<stdio.h>

#include<conio.h>

void evenodd(int);

void main()

{

          int n;

          printf("\n Enter a number");

          scanf("%d", &n);

          evenodd(n);

          getch();

}

void evenodd(int n)

{

          if(n%2==0)

          {

                   printf("\n %d is even number", n);

          }

          else

          {

                   printf("\n %d is odd number", n);

          }

}

Output

C program to find even or odd using function


2074 Set B Q. n. no 4

What is string? Explain any four-string function with examples

What is string?

Click here

Explain any four-string function with examples

Click here

2074 Set B Q. n. no 5

What is structure in C? Write a program to enter the 20 employees’ name, age and salary using structure and print them

What is structure in C?

Click here

Write a program to enter the 20 employees’ name, age and salary using structure and print them

#include<stdio.h>

#include<conio.h>

void main()

{

          struct record

          {

                   int age, sal;

                   char name[20];

          };

          struct record a[20];

          int i;

          printf("\n Enter Name age and salary of 20 employees");

          for(i=0;i<20;i++)

          {

          scanf("%c%d%d", a[i].name, &a[i].age, &a[i].sal);

    }

    for(i=0;i<20;i++)

    {

          printf("\n Name=%c\tAge=%d\tSalary=%d", a[i].name, a[i].age, a[i].sal);

    }

          getch();

}

Output


Also check



 

 

Post a Comment

0 Comments