C Programs
C Programs
C Programs
#include<stdio.h>
int leap(int );
int main()
{
int year;
printf("Enter any year : ");
scanf("%d", &year);
if(leap(year))
printf("\n%d is leap year",year);
else
printf("\n%d is not leap year",year);
return 0;
}
int leap(int y)
{
if((y%100==0 && y%400==0)||(y%4==0))
return 1;
else
return 0;
}
-------------CHECKED-------------------
#include<stdio.h>
void main()
int n,i;
float a,sum=0;
printf("Enter a number\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
sum=sum+i;
a=sum/(n);
printf("Average is %f",a);
---------------------------------------------
-------------CHECKED------------------
#include <stdio.h>
void main()
scanf("%d",&matrix[c][d]);
transpose[d][c] = matrix[c][d];
printf("%d\t",transpose[c][d]);
printf("\n");
---------------------------------------------
----------------CHECKED-----------------
#include<stdio.h>
void main()
int i,m,flag=0;
int arr[]={1,2,3,4,5,6,7,8};
printf("Enter the element you want to search \n");
scanf("%d", &m);
if(arr[i]==m)
flag=1;
break;
if(flag==0)
printf("Not present");
else
printf("Present");
--------------------------------------------
---------------------CHECKED----------------
#include <stdio.h>
int main()
scanf("%s",s1);
s2[i]=s1[i];
s2[i]='\0';
return 0;
-----------------------------------------------------
----------------------CHECKED-------------------------
#include <stdio.h>
int main()
scanf("%d", &size);
printf("Enter %d integers\n", size);
scanf("%d", &array[c]);
maximum = array[0];
maximum = array[c];
location = c+1;
return 0;
------------------------------------------------
--------------------CHECKED-----------------
#include<stdio.h>
void main()
int i,count=0;
char ch[20];
gets(ch);
for(i=0;ch[i]!='\0';i++)
count++;
printf("Reverse is:");
for(i=count-1;i>=0;i--)
printf("%c",ch[i]);
-------------------------------------------
-------------CHECKED-------------------
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
main()
int i, n;
int *arr;
clrscr();
if(arr ==NULL)
exit(0);
for(i=0;i<n;i++)
scanf("%d", &arr[i]);
return 0;
---------------------------------------------
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main() {
char ch;
clrscr();
while (1) {
ch = fgetc(fp1);
if (ch == EOF)
break;
else
putc(ch, fp2);
fclose(fp1);
fclose(fp2);