pages

Wednesday, 26 May 2021

c-program to print the reverse of the number by using pointer | c-programming

program to reverse the number by using pointer in c-programming

In this program ,we will now  takes input as a number and print the reverse of the number by using pointer in c-programming.



 //program to reverse of the number by using pointer
#include<stdio.h>
#include<conio.h>
void main()
{
         int n,rev,num;
         int *n1,*rev1,*num1;
         n1=&n,rev1=&rev,num1=&num;
         *num1=0;
         printf("enter the number:-");
         scanf("%d",&n);
         while(*n1!=0){
                  *rev1=*n1%10;
                  *num1=*num1*10+*rev1;
                  *n1=*n1/10;
         }
         printf("\n the reverse of the number is %d",*num1);
         getch();
}


output:



For more c-programming:-


















Friday, 21 May 2021

c-program to calculate the length of string using pointer | c-programing

 Program to calculate the length of string using pointer in c-programming

In this program , we will now taking  input as a string and calculate the length of string by using pointer.

pointer : pointer is a variables that stores address of another variables.

#include<stdio.h>
#include<conio.h>
void main()
{
         char str[50];
         char *i,count=0;
         i=str;
         printf("enter the string:-");
         gets(str);
         while(*i!='\0'){
                  count++;
                  i++;
         }
         printf("\n the length of the string is %d:-",count);
         getch();
}

output:-



For more c-programming:-















c-program to print the 10 number and also print the reverse of each number | c-programming languages

 program to print the 10 numbers and also print the reverse of each number in c-proramming 

In this program we will now input 10 numbers form the user by using array and print the number and also print the reverse of the each number in c-programming. 


//program to print the 10 number and also print reverse of the number
#include<stdio.h>
#include<conio.h>
void main()
{
         int a[10],b[10],i,n,num=0,rev=0;
         printf("enter the 10 numbers:-");
         for(i=0;i<10;i++)
                  scanf("%d",&a[i]);
         for(i=0;i<10;i++){
                  n=a[i];
                  num=0;
                  while(n!=0){
                           rev=n%10;
                           num=num*10+rev;
                           n=n/10;
                  }
                  b[i]=num;
         }
         for(i=0;i<10;i++)
                  printf("the number is %d and reverse is %d\n",a[i],b[i]);
         getch();
}

output:-




For more c-programming:-


















Wednesday, 19 May 2021

c-programming to print the sum of even and odd number in 10 numbers by using array | c-programming

 program to print the sum of even and odd number in 10 numbers in array in c-programming

In this program we will now takes 10 numbers form the user and print the sum of even and odd number and also print the even and odd in c-programming.

#include<stdio.h>
#include<conio.h>
void main()
{
         int a[10],i,even,odd,sum=0,evensum=0,oddsum=0;
         printf("enter the 10 number:-");
         for(i=0;i<=9;i++){
                  scanf("%d",&a[i]);
         }
         for(i=0;i<=9;i++){
                  sum=sum+a[i];
                  if(a[i]%2==0){
                           printf("even number is %d\n",a[i]);
                           evensum=evensum+a[i];
                  }
                  else{
                           printf("odd number is %d\n",a[i]);
                           oddsum=oddsum+a[i];
                  }
         }
         printf("\n the sum of even number is %d",evensum);
         printf("\n the sum of odd number is %d",oddsum);
         printf("\n the sum of the number is %d",sum);
         getch();
}

output:-



For more c-programming:-


















c-program to find the biggest number in 10 numbers by using array | c-programming

Program to print the 10 number  and find  the biggest number  in 10 numbers in c-programming

In this program we will now input 10 number by the user using array and find the biggest number in 10 number in c-program

//program to find the biggest elements
#include<stdio.h>
#include<conio.h>
void main()
{
         int a[10],i,max;
         printf("enter the number:-");
         for(i=0;i<=9;i++){
                  scanf("%d",&a[i]);
         }
         max=a[0];
         for(i=0;i<=9;i++){
           printf("%d ",a[i]);
            if(max<a[i])
                  max=a[i];
         }
         printf("\n the biggest number in the array is %d",max);
         getch();
}

output:-


For more c-programming:-




















Sunday, 16 May 2021

c-program to swap three number by using pointer in c-languages

 program to swap three number by using  pointer in c-programming:

In this program, we will now takes three number from the user and swap this three number by using pointer.

#include<stdio.h>
#include<conio.h>
int fun(int *,int *,int *);
void main()
{
         int x,y,z;
         printf("enter the three number:-");
         scanf("%d %d %d",&x,&y,&z);
         printf("\n before swapping:x=%d y=%d and z=%d",x,y,z);
         fun(&x,&y,&z);
         printf("\n after swapping: x=%d y=%d and z=%d",x,y,z);
         getch();
}
int fun(int *a,int *b,int *c)
{
         int i;
         i=*b;
         *b=*a;
         *a=*c;
         *c=i;
}


output:-



For more c-programming


















c-program to calculate the area of triangle by using pointer | c-programming

 If the length of the sides of a triangle are denoted by a,b,c and  then what is the area of the triangle by using pointer ?


In  this program , we have to taking  three input i,e sides of the triangles form the user and calculate the area of the triangle .

#include<stdio.h>
#include<conio.h>
void main()
{
         float s=0,a,b,c,area=0;
         float *x,*y,*z,*sum,*area1;
         printf("enter the three number:-");
         scanf("%f %f %f",&a,&b,&c);
         x=&a,y=&b,z=&c,sum=&s,area1=&area;
         s=(a+b+c)/2;
         printf("\n the area of the triangle are follow");
         area=sqrt(s*(s-a)*(s-b)*(s-c));
         printf("\n the solution is %.2f",*area1);
         getch();
}

output :-

                              


For more c-programming:-