Anda di halaman 1dari 2

prog 2

#include<stdio.h>
main()
{
int a;
printf("enter the no");
scanf("%d",&a);
char ca='a';
float b;
printf("enter the decimal no\n");
scanf("%f",&b);
printf("the octal value =%o\n",a);
printf("the hexadecimal value =%x\n",a);
printf("%i\n",a);
printf("the %%e value is %e\n",b);
printf("the %%g value is %g\n",b);
printf("the character is=%c\n",ca);
char ch[20];
printf("enter the string\n");
scanf("%s",ch);
printf("the string=%s\n",ch);
printf("shorthand addition =%d\n",(a+=2));
printf("shorthand subtraction =%d\n",(a-=2));
printf("shorthand multiplication=%d\n",(a*=2));
printf("shorthand division=%d\n",(a/=2));
}
prog1
#include<stdio.h>
void main()
{
int n1,n2;
printf("enter two nos\n");
scanf("%d%d",&n1,&n2);
printf("logical AND=%d\n",((n1>0)&&(n1>n2)));
printf("logical OR=%d\n",((n1>n2)||(n1!=0)));
printf("logical NOT=%d\n",!n1);
printf("BITWISE AND=%d\n",(n1&n2));
printf("BITWISE OR=%d\n",(n1|n2));
printf("BITWISE Negation=%d\n",~n1);
printf("Right shift operator=%d\n",(n1>>3));
printf("Left sift operator=%d\n",(n2<<3));
printf("'>' operator=%d\n",(n1>n2));
printf("'<' operator=%d\n",(n1<n2));
printf("'==' operator=%d\n",(n1==n2));
printf("sizeof() operator=%d\n",sizeof(n1));
}
prog3
#include<stdio.h>
main()
{
int num1,a,b,c,d;
printf("enter the no\n");
scanf("%d",&num1);
d=num1%10;
c=(num1/10)%10;
b=(num1/100)%10;

a=(num1/1000)%10;
printf("the no after adding 1 to each digit=%d%d%d%d",++a,++b,++c,++d);
}
prog4(a)
#include<stdio.h>
main()
{
int a,b,c,x,y;
printf("enter 3 nos");
scanf("%d%d%d",&a,&b,&c);
y=(a>c)?a:c;
x=(y>b)?y:b;
printf("the biggest no is %d",x);
}
prog4(b)
#include<stdio.h>
main()
{
int a,b,c;
printf("enter 3 nos\n");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(b>c))
printf("%d is biggest",a);
if((b>a)&&(b>c))
printf("%d is biggest",b);
if((c>a)&&(c>b))
printf("%d is biggest",c);
}
prog5
#include<stdio.h>
main()
{
int n1;
printf("enter a no");
scanf("%d",&n1);
if(n1&1)
printf("odd no\n");
else
printf("even no\n");
}

Anda mungkin juga menyukai