-->

hseb20:program to get maximum and minimum value

//program to get maximum and minimum value
#include<stdio.h>
#include<conio.h>
void main()
{
int a[200],size,i,max,min;
printf("enter value of size to be stored in array\n");
scanf("%d",&size);
for(i=0;i<size;i++)
{
   printf("enter value for location=%d",i);
   scanf("%d",&a[i]);
}
max=a[2];
min=a[1];
for(i=0;i<size;i++)
{
   if(max<a[i])
     {
       max=a[i];
     }
 else if (min>a[i])
   {
     min=a[i];
    }
}
printf("the maximum value=%d\n",max);
printf("the minimum value=%d\n",min);
getch();
}


hseb19 solution:program to do different operation using switch

//program to carry out different operation  using switch.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int choice;
int length_rect,breadth_rect;
char string[200];
printf("'we have following menu\n");
printf( "1.to get length of string\n");
printf("2. to get area of rectangle\n");
printf("3 to reverse a string\n");
printf("4 exit");
printf("enter your choice 1 or 2 or 3 or 4\n");
scanf("%d",&choice);
 switch(choice)
          {
                  case 1:
                            printf("we are going to get length of string\n");
                            printf("enter string\n");
                            gets(string);
                           printf("the length=%d",strlen(string));
                 break;
               case 2:
                            printf("we are going to get area of rectangle\n");
                            printf("enter its length and breadth\n");
                            scanf("%d%d",&length_rect,&breadth_rect);
                            printf("the area=%d",length_rect*breadth_rect);
                 break;

               case 3:
                            printf("we are going to reverse the string\n");
                            printf("enter your string\n");
                            gets(string);
                           printf("the reverse=%s",strrev(string));
                 break;
             case 4:
                            printf("we are going to exit\n");
                 break;

              default:
                            printf("sorry, not a valid input\n");
                            printf("thank u, terminating....\n");
          }
getch();
}

hseb sol17:program to get all even numbers lying between 1 and 100

//program  to print/display all even numbers lying between 1 and 100.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
printf("enter value of 'n'\n");
scanf("%d",&n);
for(k=1;k<=n;k++)
   {
     if(k%2==0)
      {      printf("%d,",k);
      }
  }
getch();
}

hseb16 sol:program to get given star pattern

/*program to get following pattern
      * * * * *
      * * * *
      * * *
      * *
      * 
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
for(i=5;i>=1;i--)
  {
     for(j=1;j<=i;j++)
          {
                printf("* ");
          }
       printf("\n");
 }
getch();
}

hseb_12_sol:Program to know a number is Armstrong or not

/*program to check a number is Armstrong or not .
we are taking number with three digits*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,k,rem,sum=0;
printf("enter a three digit number to be checked\n");
scanf("%d",&i);
k=i;
while(i!=0)
{
     rem=i%10;
    sum=sum+pow(rem,3);
    i=i/10;
  }
 if(sum==k)
 {
       printf("%d is Armstrong\n",k);

 }
else
{
printf("%d is not Armstrong\n",k);;}
getch();
}

hseb solution:Program to get series 1,3,5,7....

//program  to print/display series 1 ,3,5,7,.......nth.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
printf(enter value of 'n'\n");
scanf("%d",&n);
for(k=1;k<=n;k=k+2)
   {          
       printf("%d,",k);
   }
getch();
}

hseb solution:program to show type casting concept

Type casting:This is used to convert one data type to another. Particularly, the conversion is done from low level to high level. Here level means total bytes occupied in memory. So the conversion is done from int to float or float to double or int to double and not vice versa.

It's of two types.
           1)Implicit casting::- In this , computer itself converts one data type to another that is called auto conversion.    
// program to show type casting concept

#include<stdio.h>
#include<conio.h>
void main()
{
int a=3,b=2;
float c;
c=a/b;
printf("%f",c);

}
Its output is 1.00. It is incorrect.
So, it should be avoided.

2)Explicit casting:
 In this conversion, we forcefully tell computer to convert one data type to another.It gives us right answer. To use this, we put word float in front of both numbers.
Example,
// program to show type casting concept

#include<stdio.h>
#include<conio.h>
void main()
{
int a=3,b=2;
float c;
c=(float) a/b;
printf("%f",c);

}
Its output is 1.5. It is correct.
Here, the computer, first converts both values(numerator and denominator ) into float then goes for division.
So, it should be used.