-->

Facebook

Jasper Roberts - Blog

Wednesday, December 21, 2016

Write a C Program to find Gratest of 3 numbers to print the given no in ascending order.

void main()
{
     int a,b,c;
     clrscr();
     printf("enter the values of a,b and c");
    scanf("%d%d%d",&a,&b,&c);

   if(a<b && a<c)
  {
       if(b<c)
  {
       printf(" %d%d%d", a,b,c);
  }
 else if(b>c){
        printf(" %d%d%d",a,c,b);
  }
else if(b<c && b<a)
{
if(c<a)
       printf(" %d%d%d",b,c,a);
else
printf("%d%d%d",b,a,c);
}
else if(b<a)
         printf("%d%d%d",c,b,a);
else
         printf(%d%d%d",c,a,b);
}
}

OUTPUT:
Enter the values of a,b and c
6
4
5
4 5 6

Monday, December 19, 2016

Write a C Program to Find power of a number using recursion.

  1. #include<stdio.h>
  2. #include<conio.h>

  3. int main() {
  4. int pow,no;
  5. long int res;
  6. long int power(int,int);
  7. printf("Enter a number: ");
  8. scanf("%d",&no);
  9. printf("\n Enter power: ");
  10. scanf("%d",&pow);
  11. res=power(no,pow);
  12. printf("\n%d to the power %d is: %ld",no,pow,res);
  13. return 0;
  14. }
  15. int i=1;
  16. long int sum=1;
  17. long int power(int num,int pow) {
  18. if(i<=pow) {
  19. sum=sum*no;
  20. power(no,pow-1);
  21. } else
  22. return sum;
  23. }
OUTPUT:
Enter a number: 5
Enter power: 2
5 to the power 2 is: 25

Tuesday, December 13, 2016

Write a C program to print address of a variable

#include<stdio.h>
#include<conio.h>

void main( )
{

int a;
clrscr();
printf(“Address of a = %u“,&a);
getch();

}

OUTPUT:
Address of a =64453