-->

WAP to find sum,difference, and product of two numbers using switch.

//WAP to find sum,difference, and product of two numbers using switch.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int choice;
int a,b,output;
printf("please enter your two numbers for a and b for operation\n");
scanf("%d%d",&a,&b);
printf("'now,we have following menu\n");
printf( "1.to get sum\n");
printf("2. to get difference\n");
printf("3 to get product\n");
printf(" any other number to exit");
printf("enter your choice 1 or 2 or 3 or any other number\n");
scanf("%d",&choice);
 switch(choice)
          {
                  case 1:
                            printf("we are going to get sum\n");
                           printf("the sum=%d",a+b);
                 break;
               case 2:
                            printf("we are going to get difference \n");
                           printf("the difference=%d",a-b);
                 break;

               case 3:
                            printf("we are going to get product,\n");
                           printf("the product=%d",a*b);
                 break;
             
              default:
                            printf("sorry, not a valid input\n");
                            printf("thank u, terminating....\n");
          }
getch();
}

//program to get following pattern

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

Using pointer, write a program to show addition,subtraction and division (arithmetic calculation ).

//Using pointer, write a program to show addition,subtraction and division (arithmetic                    calculation ).
#include<stdio.h>
#include<conio.h>
void main()
{
int *p,*p1;
int number,number1;
printf("enter a numbers\n");
scanf("%d%d",&number,&number1);
p=&number;
p1=&number1;
printf("the sum is=%d\n",*p+*p1);
printf("the difference is=%d\n",*p-*p1);
printf("the quotient is=%d\n",*p/*p1);
getch();
}

Program to input a value/number and display its address with value using pointer.

//WAP to input a value/number and display its address with value using pointer.
#include<stdio.h>
#include<conio.h>
void main()
{
int *p;
int number;
printf("enter a number\n");
scanf("%d",&number);
p=&number;
printf("the address is=%d\n",p);
printf("the value is=%d\n",*p);
getch();
}

program to print 'n' integers and their factorial value.

//to print 'n' integers and their factorial value.
#include<stdio.h>
include<conio.h>
void main()
{
   int number,i,k,fact;
   printf("enter value(upper) for  number 'number'\n");
  scanf("%d",&number);
  for(i=1;i<=number;i++)
    {
        fact=1;
        for(k=1;k<=i;k++)
           {
                    fact=fact*k;
            }
            printf("the factorial value for %d number=%d\n",i,fact);
    }
getch();
}

program to get y raise to power x using user defined function.

//program to get y  raise to power x using user defined function.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void powervalue();
void main()
{

powervalue();
getch();
}
void powervalue()
{
int x,y,output;
printf("enter base value\n");
scanf("%d",&x);
printf("enter power value\n");
scanf("%d",&y);
output=pow(x,y);
printf("the output =%d\n",output);
getch();
}

program to get sum of 'n' integers using function.

//program to get sum of 'n' integers using function.
#include<stdio.h>
#include<conio.h>
void sum();
void main()
{

sum();
getch();
}
void sum()
{int k=1,n,sum=0;
printf("enter value of 'n'\n");
scanf("%d",&n);
while(k<=n)
   {
      sum=sum+k;
      k++;
   }
printf("sum=%d",sum);
}