Monday, June 3, 2019

Write a program to count the individual numbers of the given number


/* ***********************************************
    Write a program to count the individual numbers of the given number

 date:03-06-2019
 created by:ANIL DURGAM

*****************************************************/


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int sum=0,n,rem=0;
    printf("please enter the number\n");
    scanf("%d",&n);

    while(n>0)
    {
        rem=n%10;
        sum+=rem;
        n/=10;
    }
    printf("sum of the digits of the given number is ==%d\n",sum);
    return 0;
}



Write a program to print 1 to 10 using while loop


/* ***********************************************
    Write a program to print 1 to 10 using while loop

 date:03-06-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i=1;
    while(i<=10)
    {
         printf("%d\n",i);
         i++;

    }

    return 0;
}



Write a program to find the grade of the student


/* ***********************************************
    Write a program to find the grade of the student
    of the 4 subjects

 date:03-06-2019
 created by:ANIL DURGAM


 program details
 per>=85                        Grade =A
 per>70 && below per <85        Grade=B
 per>55 && beloW per<=70        Grade=C
 per>=40 && beloW per<=55       Grade=D
 per<40                         Grade=E

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int m1,m2,m3,m4,total,percent;
    char Grade;
    printf("please enter the marks of four subjects\n");
    scanf("%d%d%d%d",&m1,&m2,&m3,&m4);
    //printf("m1=%d,m2=%d,m3=%d,m4=%d\n",m1,m2,m3,m4);
    total=(m1+m2+m3+m4)/4;
    if(total>=85)
        Grade='A';
    else if(total<85 && total>=70)
        Grade='B';
    else if(total<70 && total>=55)
        Grade='C';
    else if(total<55 && total>=40)
        Grade='D';
    else if(total<40)
        Grade='E';


    printf("avg=%d\nGrade==%c\n",total,Grade);
    return 0;
}



Sunday, June 2, 2019

initialize the integer pointer

/* ***********************************************
    Write a program to initialize the integer pointer

 date:03-06-2019
 created by:ANIL DURGAM

*****************************************************/

#include<stdio.h>
int main()
{
int a = 30;
int *ptr;

ptr = &a;
printf("\nValue of ptr : %u",ptr);

return(0);
}



print pattern related programs

pattern 2

print pattern in c


/* ***********************************************
    Write a program to print pattern

 date:03-06-2019
 created by:ANIL DURGAM

*****************************************************/

#include<stdio.h>
#include<math.h>
int main()
{
int i,j,k,n,step=1;
printf("enter row size:");
scanf("%d",&n);
for(i=1;i<=2*n-1;i++)
{

for(k=1;k<=abs(n-i);k++)
{
printf(" ");
}
for(j=1;j<=step;j++)
{
printf("*");
}


if(i<n)
{
step+=2;
}
else
{
step-=2;
}
printf("\n");
}
return 0;
}




print pattern in c

/* ***********************************************
    Write a program to print pattern

 date:31-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include<stdio.h>
//#include<math.h>
int main()
{
int i,j,k,n,step=1;
printf("enter row size:");
scanf("%d",&n);
for(i=1;i<=2*n-1;i++)
{
for(j=1;j<=step;j++)
{
printf("*");
}

if(i<n)
{
step+=1;
}
else
{
step-=1;
}
printf("\n");
}
return 0;
}



Friday, May 31, 2019

Write a program to print decimal numbers to hexa decimal format in arrays...in c

/* ***********************************************
    Write a program to print  decimal numbers to hexa decimal format in arrays

 date:31-05-2019
 created by:ANIL DURGAM

*****************************************************/


#include <stdio.h>
#include <stdlib.h>

int main()
{

    int i;
    char ch[30]={120,120,31,18,01,8,69,86,70,33,30,80,42,00,01,140,221,13,10};
    char str[50];
    char str2[50];

    strcpy(str2,"");
    for(i=0;i<20;i++)
    {
         strcpy(str,"");
         sprintf(str,"%x",ch[i]);
         strcat(str2,str);
    }
    printf("%s",str2);

    return 0;
}

program to print reverse of the given numbers...in c

/* ***********************************************
    Write a program to print reverse of the given numbers

 date:31-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

int main()
{   int a=0,b=0;
    printf("please enter a number\n");
    scanf("%d",&a);
    b=a%10;
    printf("%d",b);
    b=a/10;
    a=b%10;
    printf("%d",a);
    a=b/10;
    printf("%d\n",a);
    return 0;
}

Thursday, May 30, 2019

program to print prime numbers below 100...in c


/* ***********************************************
    Write a program to print prime numbers below 100

 date:30-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

void prime_fn(int num);

void main()
{
   int n;

  // printf("Enter a number to check if it is prime\n");
  // scanf("%d",&n);
  for(n=2;n<100;n++)
  {
       prime_fn(n);
  }

   return 0;
}

void prime_fn(int num)
{
    int c;
     for ( c = 2 ; c <= num - 1 ; c++ )
   {
      if ( num%c == 0 )
      {
         //printf("%d isn't prime.\n", num);
     break;
      }
   }
   if ( c == num )
      printf("%d is prime.\n", num);
}

program to find prime number or not using functions in c


/* ***********************************************
    Write a program to find prime number or not using functions

 date:30/-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

void prime_fn(int num);

void main()
{
   int n;

   printf("Enter a number to check if it is prime\n");
   scanf("%d",&n);
    prime_fn(n);
   return 0;
}

void prime_fn(int num)
{
    int c;
     for ( c = 2 ; c <= num - 1 ; c++ )
   {
      if ( num%c == 0 )
      {
         printf("%d isn't prime.\n", num);
     break;
      }
   }
   if ( c == num )
      printf("%d is prime.\n", num);
}

program to find prime number or not ...in c


/* ***********************************************
    Write a program to find prime number or not

 date:30-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

main()
{
   int n, c = 2;

   printf("Enter a number to check if it is prime\n");
   scanf("%d",&n);

   for ( c = 2 ; c <= n - 1 ; c++ )
   {
      if ( n%c == 0 )
      {
         printf("%d isn't prime.\n", n);
     break;
      }
   }
   if ( c == n )
      printf("%d is prime.\n", n);

   return 0;
}


python class topic video