Refrence Variable In C++

In Oops there are two type of variables
1.Instance Variable
2.Refrence Variable

Instance variable:-Variable which occupy seprate memory in the program is known as instance variable.

Refrence variable:-Variable which do not occupy seprate its just alternative name of instance variable.

Syntax to create Refrance Variable
data type &refrence variable name =existing variable name.

Example

Int a=10;
Int &b=a;

Cout>> a;
Cout>>b;

b=50;

Cout>> a;
Cout>>b;

Output
10
10
50
50.

How to Print Special Kite Pattern In C

Click On Image To ZOOM
//Code

#include<stdio.h>
main()
{
 int i,j,k,n;

 for(i=0;i<4;i++)
 {
  for(j=0;j<3-i;j++)
  {
   printf(" ");
  }
  for(k=0;k<2*i+1;k++)
  {
   printf("*");
  }
  printf("\n");
 }
 for(i=0;i<3;i++)
 {
  for(j=0;j<i+1;j++)
  {
  printf(" ");
  }
  for(k=0;k<5-2*i;k++)
  {
  printf("*");
  }
  printf("\n"); 
 }
 for(i=1;i<2;i++)
 {
  for(j=0;j<i+1;j++)
  {
  printf(" ");
  }
  for(k=0;k<2*i+1;k++)
  {
  printf("*");
  }
  printf("\n");
 }

}

Star Pattern2

Click On Image To ZOOM
//Code

#include<stdio.h>
main()
{
int i,j,k,n;
printf("Enter no of lines\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=n;j-i>0;j--)
{
printf(" ");
}
for(k=0;k<=i;k++)
{
printf("* ");
}
printf("\n");
}
}

How to Print Fibonacci Series In C

Click Image To ZOOM

//Code
#include<stdio.h>
main()
{
int a,b,c,i,n;
a=0;b=1;
printf("Enter No Upto Display Fibonacci Series\n");
scanf("%d",&n);
printf("\n%d\n%d\n",a,b);
for(i=0;i<n-2;i++)
{
c=a+b;
a=b;   /*after a=0,b=1,we have sum c=1,now to add b&c for series in loop
       just change b to a and c to b*/
    b=c;
    
printf("%d\n",c);
}

}

Star Pattern3

Click On Image To ZOOM
//Code

#include<stdio.h>
main()
{
int i,j,k,n;
printf("Enter no of lines\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n-1-i;j--)
{
printf(" ");
}
for(k=0;k<2*i+1;k++)
{
printf("*");
}
printf("\n");
}
}

Star Pattern1

Click On Image To ZOOM


//Code
#include<stdio.h>
main()
{
int i,j,n;
printf("Enter no of lines\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf("*");
}
printf("\n");
}
}




Find Armstrong Number Between 1-500 Program in C

//Code

#include<stdio.h>
main()
{
int sum,k,r,i;
for(i=1;i<=500;i++)
{
k=i;
sum=0;
while(k>0)
{
r=k%10;
sum=sum+r*r*r;
k=k/10;

}
if(sum==i)
{
printf("Armstron No = %d\n",i);
   }

}

}

Program in C To Check Armstrong no

//Code

#include<stdio.h>
main()
{
int n,sum=0,k,r;
printf("Enter No To Check\nArmstrong Number OR Not\n");
scanf("%d",&n);
k=n;
while(n>0)
{
r=n%10;
sum=r*r*r+sum;
n=n/10;
}
if(k==sum)
printf("%d is an Armstrong no\n",sum);
else
printf("NOT an Armstrong no");

}

How to Calculate SUM Digits Of a Number

//code

#include<stdio.h>
main()
{
int n,sum=0;
printf("Enter no \n");
scanf("%d",&n);
while(n>0)
{
sum=sum+n%10;
n=n/10;
}
printf("Sum of no is=%d\n",sum);

}

How To Print Reverse Of A Number In C

//Code

#include<stdio.h>
main()
{
int n,rev=0;
printf("Enter no to reverse\n");
scanf("%d",&n);
while(n>0)
{
rev=rev*10+n%10;
n=n/10;
}
printf("Reverse of no is=%d\n",rev);
}