C++ Program .Write a program to print following pattern

Write a program to print following pattern 
1
2  3
4  5  6

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,temp=1;
clrscr();
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
  {
  printf(" %d",temp);
  temp=temp+1;
  }
printf("\n");
}
getch();
}


C++ Program .Write a program to argument & return value

#include<stdio.h>
#include<conio.h>
int add(int a,int b);
void main()
{
int a,b,ans;
clrscr();
printf("\n enter the value of a");
scanf("\n %d",&a);
printf("\n enter the value of b");
scanf("\n %d",&b);
ans=add(a,b);
printf("\n addition is n%d",ans);
getch();
}
int add(int a1,int b1)
{
int c;
c=a1+b1;
return c;
}

C++ Program .Write a program to function with no argument & no return value.

#include<stdio.h>
#include<conio.h>
void add();
void main()
{
clrscr();
add();
getch();
}
void add()
{
int a,b,c;
printf("\n enter the value of a");
scanf("\n %d",&a);
printf("\n enter the value of b");
scanf("\n %d",&b);
c=a+b;
printf("\n addition is %d",c);
}



C++ Program .Write a program to check given number is perfect or not using nested if..else.

#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,sum=0;
clrscr();
printf("\n enter the number");
scanf("\n %d",&num);
for(i=1;i<num;i++)
{
if(num%i==0)
  {
  sum=sum+i;
  }
}
if(num==sum)
  {
  printf("\n number is perfect");
  }
else
  {
  printf("\n number is not perfect");
  }
getch();
}

C++ Program .Write a program to call by value parameter are passed by using value.

#include<stdio.h>
#include<conio.h>
void swap(int a,int b);
void main()
{
int a,b;
clrscr();
printf("\n enter the value of a");
scanf("\n %d",&a);
printf("\n enter the value of b");
scanf("\n %d",&b);
swap(a,b);
getch();
}
void swap(int a1,int b1)
{
int temp;
temp=a1;
a1=b1;
b1=temp;
printf("\n swapped value is a1 %d",a1);
printf("\n swapped value is b1 %d",b1);
}

C++ Program .Write a program to call by reference.

#include<stdio.h>
#include<conio.h>
void swap(int *a,int *b);
void main()
{
int a,b;
clrscr();
printf("\n enter the value of a");
scanf("\n %d",&a);
printf("\n Enter the value of b");
scanf("\n %d",&b);
swap(&a,&b);
getch();
}
void swap(int *a1,int *b1)
{
int temp;
temp=*a1;
*a1=*b1;
*b1=temp;
printf("\n swapped value a1 is %d",*a1);
printf("\n swapped value b1 is %d",*b1);
}


C++ Program .Write a program to input an integer number & cheack number is palindrom or not.

#include<stdio.h>
#include<conio.h>
void main()
{
int num,rem,temp,sum=0;
clrscr();
printf("\n enter the value of num");
scanf("\n %d",&num);
temp=num;
while(num>0)
{
rem=num%10;
sum=rem+(sum+10);
num=num/10;
}
if(temp==num)
{
printf("\n number is palindrome");
}
else
{
printf("\n number is not palindrome");
}
getch();
}

C++ Program .Write a program to input integer number & cheack number is armstrong or not.

#include<stdio.h>
#include<conio.h>
void main()
{
int num,rem,temp,sum=0;
clrscr();
printf("\n enter the number");
scanf("\n %d",&num);
temp=num;
while(num>0)
{
rem=num%10;
sum=sum+(rem*rem*rem);
num=num/10;
}
if(temp==num)
{
printf("\n number is armstrong");
}
else
{
printf("\n number is not armstrong");
}
getch();
}


C++ Program .Write a program to convert given character into uppercase &vice versa.

#include<stdio.h>
#include<conio.h>
void main()
{
char ch,ans;
clrscr();
printf("\n enter the character");
scanf("\n %c",&ch);
if(ch>=65 && ch<=90)
{
  ans=ch+32;
  printf("\n lowercase character is %c",ans);
  }
  if(ch>=97 && ch<=122)
  {
  ans=ch-32;
  printf("\n uppercase character is %c",ans);
  }
getch();
}

C++ Program .Write a program to case.

#include<stdio.h>
#include<conio.h>
void main()
{
int ch;
clrscr();
printf("\n enter the character");
scanf("\n %c",&ch);
switch(ch)
{
case 1:
   printf("\n you are in choice 1");
   break;
case 2:
   printf("\n you are in choice 2");
   break;
case 3:
   printf("\n you are in choice 3");
   break;
default:
printf("\n your option is wrong");
break;
}
getch();
}


C++ Program .Write a program to cheack whether given character is uppercase letter,lower case & digit.

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("\n enter the character");
scanf("\n %c",&ch);
if(ch>=65 && ch<=97)
{
  printf("\n character is uppercase");
  }
  if(ch>=97 && ch<=122)
  {
  printf("\n character is lowercase");
  }
  if(ch>=48 && ch<=57)
  {
  printf("\n character is digit");
  }
getch();
}

C++ Program .Write a program to accept a character & display next & previus ascii value.

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("\n enter the character");
scanf("\n %c",&ch);
printf("\n the ascii value of character %d",ch);
printf("\n the next value of character is %d",ch+1);
printf("\n the previous ascii value character is %d",ch-1);
getch();
}


C++ Program .Write a program to cheack greater number in three number.

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\n enter the value of a");
scanf("\n %d",&a);
printf("\n enter the value of b");
scanf("\n %d",&b);
printf("\n enter the value of c");
scanf("\n %d",&c);
if(a>b&&a>c)
{
printf("\n a is grater");
}
else
{
printf("\n c is greater");
}
if(b>a&&b>c)
{
printf("\n b is greater");
}
getch();
}