-->

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.

hseb solution:program to know a number is even or odd

First part:
Algorithm to know a number is even or odd
step 1:read/input a number 'x'
step 2:Let y= remainder obtained after dividing x by 2
step 3:If y=0 then
          display it is an even
         else
         display it is an odd
step 4:stop

second part:-

Flowchart:-



//'C' program to know a number is even or odd
#include<stdio.h>
#include<conio.h>
void main()
{
int x;
printf("enter a number\n");
scanf("%d",&x);
if(x%2==0)
{
printf("it is an even number");
}
else
{
printf("it is an odd number\n");
}
getch();
}

program to enter some elements and display that in opposite order.

//array program to input elements and to display them in reverse order
  #include<stdio.h>
  #include<conio.h>
  void main()
  {
  clrscr();
  int arr[100];      // array declaration with maximum size 100
  int size;     // size to be used to input elements
  int i;            //variable declaration
  printf("enter size of elements \n");//displays message
  scanf("%d",&size);                  //gets input for array size
  for(i=0;i<size;i++)
   {                            //loop execution
     printf("enter elements\n");//displays message
     scanf("%d",&arr[i]);      //gets input for  array entered by user

   }
   printf("elements, in reverse order, are\n");
   for(i=size-1;i>=0;i--)
   {
   printf("%d\n",arr[i]);       // displays  elements
   }
   getch();

   }
--------------------------------------------------
logics:-
1)declare an array of  partiular size.
2)input elements for this using loop.
3)to display, use loop from given size-1 to 0 location (look above)
that's all
more, u can understand from side by description given in program
-------------------------
screen shot

output:

Write a program to get given pattern

/*WAP to get following
                                  * * * * * 
                        * * * * *
                   * * * * * 
             * * * * *
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k;
for(i=1;i<=5;i++)      //for number of rows. there are five rows so loop moves fives times
  {
    for(k=8;k>=i;k--)
      {
      printf(" ");   // this part is for space. every time , on display, it decreases space.
      }
    for(j=1;j<=4;j++) //it displays star five times.It displays in columns
      {
 printf("* ");
      }
    printf("\n"););
}
getch();
}
---------------------------
logic in mind:-
----------
it has three parts:
first is number of rows
second part is number of columns
third part decreasing space on each display.
1)fist loop is used for number of rows
2) the inner loop is for space to display
3)the inner most is for star display every time.

Program's screen:-


program's output:


Note:-
From here onward, we are writing program using return and int main().
so using return, it looks like.
#include <stdio.h>
#include<conio.h>
int main()
{
  int i,j,k;
for(i=1;i<=5;i++)      //for number of rows. there are five rows so loop moves fives times
  {
    for(k=8;k>=i;k--)
      {
      printf(" ");   // this part is for space. every time , on display, it decreases space.
      }
    for(j=1;j<=4;j++) //it displays star five times.It displays in columns
      {
 printf("* ");
      }
    printf("\n");
}
   getch();
  return 0;
}
---------------------------------------------------
read me:-

nothing you have to do here. Just put int main() in the beginning and return 0 at the end

wap to display star pattern

/*program to display following

* * * * *
    * * * * *
* * * * *
         * * * * *
             * * * * *

*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k;
for(i=5;i>=1;i--)      //for number of rows. there are five rows so loop moves fives times
  {
    for(k=i;k<=7;k++)
      {
      printf(" ");   // this part is for space. every time , on display, it increases space.
      }
    for(j=1;j<=5;j++) //it displays star five times.It displays in columns
      {
printf("* ");
      }
    printf("\n");
}
getch();
}
---------------------------
logic in mind:-
----------
it has three parts:
first is number of rows
second part is number of columns
third part increasing space on each display.
1)fist loop is used for number of rows
2) the inner loop is for space to display
3)the inner most is for star display everytime.
------------------------------------------------------
program screenshot


output is






WEAP to display following star pattern

/*program to display following

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
for(i=1;i<=5;i++)      //for number of rows. there are five rows so loop moves fives times
  {
    for(j=1;j<=5;j++) //it displays star five times.It displays in columns
      {
printf("* ");
      }
    printf("\n");
}
getch();
}

------------------------------------
logic in mind:-
1)we have to display five rows and five columns.
2) we have used outer loop five times.
3)and inner loop five times.
-------------------------------
 program 's screenshot





output