Showing posts with label C programming examples with output. Show all posts
Showing posts with label C programming examples with output. Show all posts

Tuesday 17 September 2019

ONLINE EXAMINATION[c programming language]

ONLINE EXAMINATION

Program:

#include<stdio.h>
#include<conio.h>
void prn();
main()
{
int i,m=0;
long ht;
char name[20];
char f[10];
char ch[50]="STATE TRUE OR FALSE. EACH CARRIES ONE MARK.";
clrscr();
prn();
gotoxy(5,4);
printf("STUDENT NAME    : ");
scanf("%s",name);
gotoxy(5,6);
printf("HALLTICKET NUMBER : ");
scanf("%ld",&ht);
clrscr();
prn();
gotoxy(2,5);
printf("%s",ch);
gotoxy(2,6);
for(i=0;i<strlen(ch);i++)
printf("-");
printf("\n\n");
printf("1. Structure is not a data type :");
scanf("%s",&f[0]);
if(f[0]==101  ||  f[0]==70)
m++;
printf("\n");
printf(2. C program is a collection of functions:");
scanf("%s",&f[1]);
if(f[1]==116 || f[1]==80)
m++;
printf("\n");
printf("3. In an array we can accept more than one value of same type :");
scanf("%s",&f[2]);
if(f[2]==116  || f[2]==84)
m++;
printf("\n");
printf("4. String is a character array :");
scanf("%s",&f[3]);
if(f[3]==116 || f[3]==84)
m++;
printf("\n");
printf("5. Any function cannot be called from any other function :");
scanf("%s",&f[4]);
if(f[4]==102 || f[4]==70)
m++;
printf("\n");
printf("6.fflush() is a macro: ");
scanf("%s",&f[5]);
if(f[5]==102 || f[5]==70)
m++;
printf("\n");
printf("7. When the file is opened in 'a+' mode modification is possible: ");
scanf("%s",&f[6]);
if(f[6]==102 || f[6]==84)
m++;
printf("\n");
printf(8. Break is a reverse word: ");
scanf("%s",&f[7]);
if(f[7]==116 || f[7]==84)
m++;
printf("\n");
printf("9. STRCHR finds the first occurrence of a given character in a string: ");
scanf("%s",&f[8]);
if(f[8]==116 || f[8]==84)
m++;
printf("\n");
printf("10. FILE STRUCTURE CONTAINS INFORMATION ABOUT THE FILE BEING USED: ");
scanf("%s",&f[9]);
if(f[9]==116 || f[9]==84)
m++;
clrscr();
prn();
printf("\n\n");
printf("STUDENT NAME               :%s",name);
printf("\n HALL TICKET NUMBER      :%ld",ht);
printf("\nTOTAL MARKS              :%d",m);
getch();
}
void prn()
{
gotoxy(25,2);
printf("C EXAMINATION");
gotoxy(25,3);
printf("_____________");
}

Output:
                                              C EXAMINATION
STUDENT NAME                : Avinash
HALL TICKET NUMBER   : 9192001

                                              C EXAMINATION
1.Structure is not a data type:f
2. C program is a collection of functions:t
3. In an array we can accept more than one value of same type :t
4. String is a character array :t
5. Any function cannot be called from any other function :f
6.fflush() is a macro:f
7. When the file is opened in 'a+' mode modification is possible:f
8. Break is a reverse word:t
9. STRCHR finds the first occurrence of a given character in a string: t
10. FILE STRUCTURE CONTAINS INFORMATION ABOUT THE FILE BEING USED:t

                                              C EXAMINATION
STUDENT NAME                  : Avinash
HALL TICKET NUMBER     :9192001
TOTAK MARKS                     :10


                                  Best Budget Laptop For Web Developers 2019

Best Budget Laptop For Programmershttps://amzn.to/2LOr3w9
Mi Fitness Band (On Offer) -   https://amzn.to/2AxC7IF
Honor Band 4(Fitness Band)https://amzn.to/2NkLjZz

Sunday 24 February 2019

Generating Numbers in the Combination of given Numbers[c programming examples with output]

Generating Numbers in the Combination of given Numbers

Program:

#include<stdio.h>
#inclue<conio.h>
main()
{
        int t,r,range,i,j,s,d;
        int a[5],b[5];
        long n;
        clrscr();
        printf("Enter no. of numbers for combination : ");
        scanf("%d",&d);
        printf("\nENter numbers for combination : ");
        for(i=0;i<d;i++)
           scanf("%d",&a[i]);
           printf("\nEnter the range : ");
           scanf("%d",&range);
           for(i=1;i<=range;i++)
          {
               n=i;s=0;t=0;
               while(n>0)
               {
                   j=0;
                   r=n%10;
                   t++;
                   while(j<d)
                   {
                       if(r==a[j])
                       s++;
                       j++;
          }
          n=n/10;
  }
         if(s==t)
             printf("%d\t",i);
         }
  getch();
}

OutPut:

Enter no. of numbers for combination:2
Enter numbers for combination:4
8
Enter the range:500
4    8    44    48    84    88
444  448  484   488

                                        Best Budget Laptop For Web Developers 2019
Best Budget Laptop For Programmershttps://amzn.to/2LOr3w9

Friday 8 February 2019

Program To Find The Sum Of The Given n Integers Using An Array[c programming examples with output]

Write A Program To Find The Sum Of The Given n Integers Using An Array

/*Program To Find Sum Of n Integers*/
#include<stdio.h>
#include<conio.h>
main()
{
    int x[50],n,i,sum;
    clrscr();
    printf("\n How many integers??");
    scanf("%d",&n);
        /*loop to read N integers*/
         f or(i=0;i<n;i++)
   {
       printf("\n Enter the %dth value: ",i+1);
       scanf("%d",&x[i]);
   }
   sum=0;
      /*loop to find sum of all integers*/
         for(i=0;i<n;i++)
       sum=sum=sum+x[i];
       printf("\nSum of all integers=%d",sum);
       getch();
}

OutPut:
How many integers??5
Enter the 1th value: 36
Enter the 2th value: 45
Enter the 3th value: 52
Enter the 4th value: 40
Enter the 5th value: 61
Sum of all integers=234

                                                   
                                         Best Budget Laptop For Web Developers 2019
Best Budget For Programmers: https://amzn.to/32GkrqC

Friday 11 January 2019

Pattern 10 using c[c programming examples with output]

C programming examples with output

Pattern
Program

#include<stdio.h>
#include<conio.h>
void main()
{
     int i,j;
     clrscr();
     for(i=1;i<=5;i++)
     {
         for(j=1;j<=i;j++)
         {
              printf("*");
         }
              printf("\n");
     }
     getch();
}

Output

*
**
***
****
*****

Best Budget Laptop For Web Developers 2019

Best Budget Laptop For Programmers: https://amzn.to/32GkrqC

Pattern 9 using c[c programming examples with output]

C programming examples with output

Pattern


Program
#include<stdio.h>
#include<conio.h>
void main()
{
    char i'j;
    clrscr();
    for(i='E';i>='A';i--)
    {
        for(j='E';j>="A';j--)
        {
            printf("%c",j);
        }
            printf("\n");
    }
    getch();
}

Best Budget Laptop For Web Developers 2019
Best Laptop For Programmers: https://amzn.to/32GkrqC

Pattern 8 using c[c programming examples with output]

C programming examples with output

Pattern
Program
#include<stdio.h>
#include<conio.h>
void main()
{
     char i,j;
     clrscr();
     for(i='E';i>='A';i--)
     {
         for(j='E';j>='A';j--)
        {
            printf("%c",i);
         }
            printf("\n");
     }
     getch();
}

Output:
EEEEE
DDDDD
CCCCC
BBBBB
AAAAA

Pattern 7 using c[c programming examples with output]

C programming examples with output

Pattern

Pattern
Program

#include<stdio.h>
#include<conio.h>
void main()
{
       int i,j;
       clrscr();
       for(i=5;i>=1;i--)
       {
            for(j=5;j>=1;j--)
            {
                  printf("%d",j);
             }
                  printf("\n");
             }
      getch();
}


Pattern 6 using c[c programming examples with output]

C programming examples with output

Pattern


Program

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j;
    clrscr();
    for(i=5;i>=1;i--)
    {
        for(j=1;j<=5;j++)
        {
            printf("%d",i);
        }
            printf("\n");
     }
    getch();
}


Pattern 5 using c[c programming examples with output]

C programming examples with output

Pattern
Program

#include<stdio.h>
#include<conio.h>
void main()
{
     char i,j;
     clrscr();
     for(i='A';i<='E';i++)
     {
         for(j='A';j<='E';j++)
         {
              printf("%c",j);
         }
     printf("\n);
      }
     getch();
}

Output

A B C D E
A B C D E
A B C D E
A B C D E
A B C D E

Pattern 4 using c[c programming examples with output]

C programming examples with output

Pattern
Program
#include<stdio.h>
#include<conio.h>
void main()
{
char i,j;
clrscr();
for(i='A';i<='E';i++)
{
for(j='A';j<='E';j++)
{
printf("%c",i);
}
printf("\n");
}
getch();
}

Output:

AAAAA
BBBBB
CCCCC
DDDDD
EEEEE

Pattern 3 using c[c programming examples with output]

C programming examples with output

Pattern
                                                 

Program

#include<stdio.h>
#include<conio.h>
void main()
{
     int i,j;
     clrscr();
     for(i=1;i<=5;i++)
     {
         for(j=1;j<=5;j++)
         {
              printf("%d",j);
         }
              printf("\n);
         }
     getch();
}

Output:

12345
12345
12345
12345
12345

Pattern 2 using c[c programming examples with output]

C programming examples with output


Pattern
                                                   

Program

#include<stdio.h>
#include<conio.h>
void main()
{
      int i,j;
      clrscr();
      for(i=1;i<=5;i++)
     {
         for(i=1;j<=5;j++)
          {
              printf("%d",i);
          }
              printf("\n");
          }
      getch();
     }

Output:

11111
22222
33333
44444
55555

Pattern 1 using c[c programming examples with output]

C programming examples with output

Pattern
Program

#include<stdio.h>
#include<conio.h>
void main()
{
      int i,j;
      clrscr();
      for(i=1;i<=5;i++)
      {
          for(j=1;j<=5;j++)
         {
            printf("*");
         }
            printf("\n");
      }
       getch();
}

Output:

*****
*****
*****
*****
*****

Monday 7 January 2019

Condensing A Number into Single Digit with c programming[c programming examples with output]

C programming examples with output

Condensing A Number into Single Digit
Program

#include<stdio.h>
#include<conio.h>
main()
{
      int r,i,j,s;
      int a[10];
      long n;
      clrscr();
      printf("Enter any number : ");
      scanf("%ld",&n);
      do
      {
             s=0;i=0;
             while(n>0)
            {
                   r=n%10;
                   a[i]=r;
                   s=s+r;
                   i++;
                   n=n/10;
            }
            --i;
     if(i!=0)
             n=s;
             if(i==0 || i==1)
             {
                   printf("single digit= %d",n);
                   break;
             }
}while(i>0);
getch();
}

Output:
Enter any number:9876543221
((9+8+7+6+5+4+3+2+1)=(45)=(4+5)=9)
single digit=9
Enter any number:32190
single digit=6
Enter any number:1092387456
single digit=9

Best Budget Laptop For Web Developers 2019

Sunday 6 January 2019

Program For Shutdown Computer[c programming examples with output]

C programming examples with output

Shutdown Computer
Program

#include<stdio.h>
#include<stdlib.h>
main()
{
      char ch;
      printf("Do you want to shutdown your computer now(y/n)\n");
      scanf("%c",&ch);
      if(ch=='y' || ch=='Y')
      system("C:\\Windows\\system32\\shutdown/s");
      return 0;
}

Pyramid Of Numbers With C[c programming examples with output]

C programming examples with output

Pyramid Of Numbers
Program

#include<stdio.h>
#include<conio.h>
main()
{
     int rows,t,i,j,k,s;
     clrscr();
     printf("Enter no.of rows to print : ");
     scanf("%d",&rows);
     t=1;
    for(i=1;i<=rows;i++)
    {
        for(j=0;j<(rows-i);j++)
        printf(" ");
        s=(2*i)-1;
            for(k=0;k<s;k++)
       {
            if(t<10)
            printf("%d ",t);
            else
            printf("%d ",t);
            t++;
       }
           printf("\n\n");
    }
    getch();
}

Output:
Enter no, of rows to print:5
                1
             2  3  4
           5 6  7  8  9
       10 11 12 13 14 15 16
    17 18 19 20 21 22 23 24 25

Print Date with c[c programming examples with output]

C programming examples with output

Print Date
Program

#include<stdio.h>
#include<conio.h>
#include<dos.h>
int main()
{
       struct date d;
       getdate(&d);
       printf("Current system date is %d%d/%d,d.da_day,d.da_mon,da_year);
       getch();
       return 0;
}

Local Variables[c programming examples with output]

C programming examples with output

Local Variables
Program

#include<stdio.h>
#include<conio.h>
void fun1();
void fun2();
main()
{
      int t;
      clrscr();
      t=1000;
      fun2();
      printf("\n");
      printf("%d",t);
      getch();
}
     void fun1()
{
     int t;
     t=10;
     printf("%d",t);
}
void fun2()
{
    int t;
    t=100;
    fun1();
    printf("\n");
    printf("%d",t);
}

Output:
10
100
1000

Length of string using Pointer in c[c programming examples with output]

C programming examples with output

Length of string using Pointer
Program

#include<stdio.h>
int string_In(char*);
void main()
{
      char str[20];
      int length;
      printf("\nEnter any string: ");
      gets(str);
      length=string_In(str);
      printf("The length of the given string %s is: %d",str,length);
}
      int string_In(char*p)
{
      int count=0;
      while(*p!='\0'){
      count++;
      p++;
}
return count;
}

Output:
Enter any string: programming
The length of the given string programming is: 11

Addition using pointer in c[c programming examples with output]

C programming examples with output

Addition using pointer
Program

#include<stdio.h>
int main()
{
      int first,second,*p,*q,sum;
      printf("Enter two integers to add\n");
      scanf("%d%d",&first,&second);
      p=&first;
      q=&second;
      sum=*p+*q;
      printf("Sum of entered numbers=%d\n",sum);
      return 0;
}

Output:
Enter two integers to add
4
6
Sum of entered numbers=10