Sunday 6 January 2019

Check Leap Year Or Not in c[c programming examples with output]

C programming examples with output

To Check Leap Year Or Not
Program

#include<stdio.h>
#include<conio.h>
main()
{
     int year,i;
     clrscr();
     printf("Enter year : ");
     scanf("%d",&year);
     if(year%4==0)
         printf("%d is a leap year.",year);
     else
         printf("%d is not a leap year.",year);
     getch();
}

Output:
Enter year:2020
2020 is a leap year.
Enter year:2017
2017 is not a leap year.

Best Budget Laptop For Web Developers 2019

Copy String with c program[c programming examples with output]

C programming examples with output

Copy String
Program

#include<stdio.h>
#include<string.h>
main()
{
      char source[]="C programming";
      char destination[50];
      strcpy(destination,source);
      printf("Source string: %s\n",source);
      printf("Destination string: %s\n",destination);
      return 0;
}

Output:
Source string: C programming
Destination string: C programming

Checking if given number is binary number or not in c[c programming examples with output]

C programming examples with output

Checking if given number is binary number or not
Program

#include<stdo.h>
#include<conio.h>
main()
{
     int r,c;
     long n,t;
     clrscr();
     printf("Enter any number : ");
     scanf("%ld",&n);
     t=n;
     c=r=0;
     while(n>0)
     {
         if(n%10==0 || n%10==1)
         c++;
         r++;
         n=n/10;
     }
        if(c==r)
            printf("\n%ld is a binary number",t);
       else
            printf("\n%ld is not a binary number",t);
       getch();
}

Output:
Enter any number:12345
12345 is not a binary number
Enter any number:10000001
10000001 is a binary number

Celsius To Fahrenheit with c program[c programming examples with output]

C programming examples with output

Celsius To Fahrenheit
Program

#include<stdio.h>
#include<conio.h>
void main()
{
     float c,f;
     clrscr();
     printf("Enter temperature in centigrade: ")
     scanf("%f",&c);
     f=(1.8*c)+32;
     printf("Temperature in Fahrenheit= %f",f);
     getch();
}

Output:
Enter temp in centigrade:100
Temperature in Fahrenheit=212