Friday 4 January 2019

Electricity Bill[c programming examples with output]

C programming examples with output

Electricity Bill
Program

#include<stdio.h>
#include<conio.h>
main()
{
        int cno,pmr,cmr,cu;
        float total;
        char sec;
        char cname[10];
        clrscr();
        printf("Enter the sector                :");
        scanf("%c",&sec);
        printf("Enter customer name        :");
        scanf("%s",cname);
        printf("Enter customer number     :");
        scanf("%d",&cno);
        printf("Enter the previous units     :");
        scanf("%d",&pmr);
        printf("Enter the current units       :");
        scanf("%d",&cmr);
        cu=cmr-pmr;
        if(sec=='a')
          {
            if(cu>300)
            total=cu*2.00;
                 if(cu>200 && cu<=300)
                 total=cu*1.50;
                       if(cu>100 && cu<=200)
                       total=cu*1.00;
                             if(cu<=100)
                             total=cu*0.50;
          }
          if(sec=='i')
          {
              if(cu>300)
              total=cu*4.00;
                     if(cu>200 && cu<=300)
                     total=cu*3.00;
                             if(cu>100 && cu<=200)
                             total=cu*2.00;
                                      if(cu<=100)
                                      total=cu*1.00;
}
if(sec=='d')
   {
          if(cu>300)
          total=cu*2.00;
                  if(cu>200 && cu<=300)
                  total=cu*1.50;
                         if(cu>100 && cu<=200)
                         total=cu*1.00;
                                if(cu<=100)
                                total=cu*0.50;
  }
           printf("\nCustomer name     :  %s",cname);
           printf('\nCustomer number   :  %d",cno);
           prinf("\nPrevious units         :  %d",pmr);
           printf('\nCurrent units           :  %d",cmr);
           printf("\nCategory                 :  %c",sec);
           printf("\nConsumed units      :  %d",cu);
           printf("\nElectric bill             :  %f",total);
           getch();
}

Output
Enter the sector                 :i
Enter customer name        :Ram
Enter customer number    :1234
Enter the privious units     :567
Enter the current units       :890
Customer name                 :Ram
Customer number             :1234
Previous units                   :567
Current units                     :890
Category                           :i
Consumed units                :323

Thursday 3 January 2019

Floyd's Triangle[c programming examples with output]

C programming examples with output


Floyd's Triangle
Program:

#include<stdio.h>
#iniclude<conio.h>
main()
{
      int a,b,c,rows;
      clrscr();
      printf("Enter number of rows: ");
      scanf("%d",&rows);
      c=1;
      for(a=0;a<rows;a++)
      {
             for(b=0;b<=a;b++)
            {
                 if(c<10)
                      printf("%d   "c);
                 else
                      printf("%d   ",c);
              c++;
        }
        printf("\n");
      }
      getch();
}

Output
Enter numbers of rows:5

1
2   3
4   5   6
7   8   9   10
11  12  13  14  15


Check others programming by click here:
Factorial of a number:
Find sum of digits of a number:
Find vowel or not:
Palindrome Number:

Swapping of two integers[c programming examples with output]

C programming examples with output

Swapping of two integers
Program

#incluede<stdio.h>
#include<conio.h>
main()
{
      int a,b;
      clrscr();
      printf("Enter two numbers : ");
      scanf("%d%d",&a,&b);
      printf("\nValue of a :  %d",a);
      printf("\nValue of b :  %d",b);
      a=a+b;
      b=a-b;
      a=a-b;
      printf("\nVAlue of a :  %d",a);
      printf("\nValue of b :  %d",b);
      getch();
}

Output
Enter two numbers:34
56
Value of a:34
Value of b:56
Value of a:56
Value of b:34

Check others programming by click here:
Factorial of a number:
Find sum of digits of a number:
Find vowel or not:
Palindrome Number:

Tuesday 1 January 2019

Find result of a student[c programming examples with output]

C programming examples with output

Find result of a student

Program

#include<stdio.h>
#include<conio.h>
main()
{
        int m1,m2,m3,m4,m5,m6,total;
        char result,grade,name[15];
        float avg;
        clrscr();
        printf("Enter student name: ");
        scanf("%s",name);
        printf("\nEnter 6 marks: ");
        scanf("%d%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5,&m6);
        total=m1+m2+m3+m4+m5+m6;
        avg=total/6;
        if(avg>40)
        {
              result= 'P';
        if(avg>75)
             grade='A';
        else if(avg>60 && avg<=75)
             grade='B';
        else if(avg>50 && avg<=60)
             grade='C';
        else
             grade='D';
        }
        else
            result='f';

        printf("\nStudent name  : %s",name);
        printf("\nMarks         : ");
        printf("\n%d\t%d\t%d\t%d\t%d\t%dt",m1,m2,m3,m4,m5,m6);
        printf("\nAverage marks : %f",avg);
        if(result=='p')
            printf("\nResult        : Pass");
        else
            printf("\nResult        : fail");
            printf("\nGrade         : %c",grade);
        getch();
}

Output

Enter student name: Prem
Marks             :
65  69  73  80  90  97
Average result    : 79.000000
Result            : Pass
Grade             : A


Check others programming by click here:
Factorial of a number:
Find sum of digits of a number:
Find vowel or not:
Palindrome Number: