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:

Factorial of a number[c programming examples with output]

C programming examples with output

Factorial of a number

Program
#include<stdio.h>
#include<conio.h>
main()
{
       int a,b,c;
       clrscr();
       printf("Enter any number: ");
       scanf("%d",&a);
       c=a;
       b=1;
       while(c>0)
       {
       b=b*c;
       c-;
       }
       printf("Factorial of %d is:  %d",a,b);
       getch();
}

Output

Enter any number:6
Factorial of 6 is:720