Aryan C Program
Aryan C Program
And
it must be a whole number greater than 1. Example: 5 can only
be divided evenly by 1 or 5, so it is a prime number.
#include<stdio.h>
#include<conio.h>
int main()
{
int num,n,div,p;
printf("Enter any number: ");
scanf("%d", &num);
for(n=2; n<=num; n++)
{
for(div=2; div<n; div++)
{
if(n%div==0)
{
p=0;
break;
}
p=1;
}
if(p)
printf("\t%d",n);
}
getch();
return 0;
}
------------------------------------------------------------write a program to accept five integer value from the user and
store it in an array. also display the maximum and minimum
value
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i, n ,max=0,min=0;
int a[100];
clrscr();
printf("Enter the limit:\n");
scanf("%d",&n);
printf("Enter the Value:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
max=min=a[0];
for(i=0;i<n;i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("\nmaximum=%d\n\nminimum=%d",max,min);
getch();
}
-------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3], sum[3][3], i=0, j=0;
clrscr();
printf("Enter the elements of the first array :");
for (i=0;i<=2 ;i++ )
{
for(j=0; j<=2; j++)
{
scanf("%d\n", &a[i][j]);
printf("\n");
}
}
printf("Enter the elements of the second array :")
for(i=0; i<=2; i++)
{
for(j=0; j<=2; j++)
{
scanf("%d", &b[i][j]);
}
}
/*Now placing the sum of the two matrices in the third one */
for (i=0;i<=2 ;i++ )
{
for(j=0; j<=2; j++)
{
sum[i][j] = a[i][j] + b[i][j];
}
}
/* Now displaying the sum of the two matrices by following code
snippet */
printf("\nThe sum of the matrices obtained is as follows :");
for(i=0; i<=2; i++)
{
for(j=0; j<=2; j++)
{
printf("\n%d", sum[i][j]);
printf("\n");
}
}
getch();
}
while (i < j) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
// increment i
j--;
// decrement j
}
//Print out the Result of Insertion
printf("\nResult after reversal : ");
for (i = 0; i < num; i++) {
printf("%d \t", arr[i]);
}
return (0);
}