Академический Документы
Профессиональный Документы
Культура Документы
.#include<stdio.h>
int main()
{
unsigned int i=0,j=0,sum=1,num;
printf("nEnter the limit for the series ");
scanf("%d",&num);
while(sum<num)
{
printf("%d ",sum);
i=j;
j=sum;
sum=i+j;
}
getch();
}
INPUT:
Output:
0112
PRIME NUMBER
void main ()
int no,i=2;
clrscr ();
scanf ("%d",&no);
while (i<=no)
if (no%i==0)
break;
i++;
if (i==no)
else
getch ();
Output:
ARRANGE THE ELEMENTS IN ARRAY IN DESSENDING ORDER.
main()
{
int a[100],i,n,j,search,temp;
printf("\n how many no's in array");
scanf("%d",&n);
printf("\n enter %d elements in array",n);
for(i=0;i
scanf("%d",&a[i]);
for(i=0;i
{
for(j=i+1;j
{
if(a[i]
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("%4d",a[i]);
}
getch();
}
Input:
76
87
34
12
98
Output:
98
87
76
34
12
#include "stdio.h"
#include "conio.h"
main()
{
int a[100],i,n,j,search,temp;
printf("\n how many no's in array");
scanf("%d",&n);
printf("\n enter %d elements in array",n);
for(i=0;i
scanf("%d",&a[i]);
for(i=0;i
{
for(j=i+1;j
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("%4d",a[i]);
}
getch();
}
Input:
76
87
34
12
98
Output:
12
34
76
87
98
return 0;
}
WAP TO FIND OUT YEAR IS LEAP OR NOT
void main ()
int a;
clrscr ();
if (a%4==0)
else
getch ();
}
Output:
#include<stdio.h>
#include<string.h>
main()
{
char str[50] revstr[50];
int i=0 j=0;
printf(“ Enter the string to be reversed :”);
scanf( s str);
for(i=strlen(str)-1;i>=0;i--)
{
revstr[j]=str[i];
j++;
}
revstr[j]='\0';
printf( Input String : s str);
printf( \nOutput String : s revstr);
getch();
Input:
Output:
Output String=hcetb
call by value
main()
{
int x=50, y=70;
interchange(x,y);
printf(“x=%d y=%d”,x,y);
}
interchange(x1,y1)
int x1,y1;
{
int z1;
z1=x1;
x1=y1;
y1=z1;
printf(“x1=%d y1=%d”,x1,y1);
}
output:
x1=70 y1=50
x=50 y=70
call by reference
main()
{
int x=50, y=70;
interchange(&x,&y);
printf(“x=%d y=%d”,x,y);
}
interchange(x1,y1)
int *x1,*y1;
{
int z1;
z1=*x1;
*x1=*y1;
*y1=z1;
printf(“*x=%d *y=%d”,x1,y1);
}
output:
*x=70 *y=50
x=70 y=50
Output:
Enter the string:Malayalam
Entered string is palindrome