C

Friday, 29 September 2017

Program Showing Type Conversion Across Assignment

#include<stdio.h>
 main()
 {
int a;
clrscr();
a=1;
printf("\n when a=1 then output is %d\n",a);
a='C';
printf("\n when a='C' then output is %d\n",a);
a=5.2;
printf("\n when a=5.2 then output is %d\n",a);
 }


Program Showing Use of Constants.

#include<stdio.h>
#define PASS_MARKS 40
main()
{
         printf("Passing Marks is : %d", PASS_MARKS);
}



Thursday, 7 September 2017

Program To Search An Element From Array

#include<stdio.h>
main()
{
int i,n,e,a[30];
clrscr();
printf("\nEnter total number of elements : ");
scanf("%d",&n);
printf("Enter %d Integer Numbers\n",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the element you want to search : ");
scanf("%d",&e);
i=0;
while(i<n&&e!=a[i])
{
i++;
}
printf("The Element of Array is located at : %d position",i+1);
return(0);
}


Program To Sort The Array Elements

#include<stdio.h>
main()
{
int n,i,j,temp,a[30];
clrscr();
printf("\nEnter The Total Number Of Elements You Want In Array :");
scanf("%d",&n);
printf("Enter %d Integer Numbers\n",n);
for(i=0;i<n;++i)
scanf("%d",&a[i]);
for(i=0;i<n;++i)
{
for(j=i+1;j<n;++j)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("The Sorted Array Elements Is\n");
for(i=0;i<n;++i)
printf("%d\n",a[i]);

}


Program To Reverse Of An Array Elements

#include<stdio.h>
main()
{
int a[25],n,i,j,temp;
clrscr();
printf("\nEnter The Number Of Elements You Want In Array : ");
scanf("%d",&n);
printf("Enter The %d Integer Numbers\n",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
j=i-1;
i=0;
while(i<j)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
i++;
j--;
}
printf("The Elements Of Reversed Array Is :");
for(i=0;i<n;i++)
printf("%d\n" ,a[i]);
return(0);
}


Program To Find Smallest And Biggest Number In Array Of Integer Numbers

#include<stdio.h>
main()
{
int a[20],n,i,big,small;
clrscr();
printf("\nEnter Total Numbers You Want In Array : ");
scanf("%d",&n);
printf("\nEnter The %d Integer Numbers\n",n);
for(i=0;i<=n;i++)
scanf("%d",&a[i]);
big=a[0];
for(i=0;i<=n;i++)
if(a[i]>big)
big=a[i];
printf("\nThe Largest Number In Array Is : %d",big);
small=a[0];
for(i=0;i<=n;i++)
if(a[i]<small)
small=a[i];
printf("\nThe Smallest Number Is: %d",small);
return(0);
}


Tuesday, 5 September 2017

Program To Check Whether A Given String Is Palindrome Or Not.

#include<stdio.h>
#include<string.h>
main()
{
char strng[30];
int i,lngth,flag=0;
printf("Enter a string : ");
scanf("%s",&strng);
lngth=strlen(strng);
for(i=0;i<lngth;i++)
{
if(strng[i]!=strng[lngth-i-1])
{
flag=1;
break;
}
}
if(flag)
printf("%s is not a palindrome");
else
printf("%s is a palindrome");
returm 0;
}


Program To Check Whether A Given Number Is Palindrome Or Not.

#include<stdio.h>
main()
{
int num;
int temp;
int digit;
int rnum=0;
clrscr();
printf("Enter The Integer Number : ");
scanf("%d",&num);
temp=num;
do{
digit=temp%10;
temp=temp/10;
rnum=rnum*10+digit;
}
while(temp>0);
if(rnum==num)
printf("The Given Number Is Palindrome");
else
printf("The Given Number Is Not Palindrome");
}


Write a program to draw a circle using mid-point circle drawing algorithm.

#include<iostream.h> #include<graphics.h> #include<conio.h> void drawcircle(int x0, int y0, int r) {         ...