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;
}



functions in python

def test():     print("good morning") test() output: good morning