0% found this document useful (0 votes)
7 views

Student Practical C Programs

Uploaded by

anuj2006arote
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Student Practical C Programs

Uploaded by

anuj2006arote
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

============================================================

#include<stdio.h>
void main()
{
int number;
clrscr();
printf("Enter a number");
scanf("%d",&number);
printf("\ncube of %d is %d",number,number*number*number);
getch();
}

==================================
#include <stdio.h>

void main() {
char ch;
clrscr();

// Use getchar() to read a single character


printf("Enter a character: ");
ch = getchar();

// Use putchar() to print the character


printf("You entered: ");
putchar(ch);
getch();
}
============================================================
#include<stdio.h>
void main()
{
char name[25];
clrscr();
printf("\nEnter your full name");
gets(name);
printf("Hello ");
puts(name);
getch();
}
======================================================================
#include<stdio.h>
void main()
{
int num1,num2,add,sub,mul,div,rem;
clrscr();
printf("\nEnter two numbers");
scanf("%d%d",&num1,&num2);

add=num1+num2;
printf("\n%d + %d=%d",num1,num2,add);

sub=num1-num2;
printf("\n%d - %d=%d",num1,num2,sub);

mul=num1*num2;
printf("\n%d * %d=%d",num1,num2,mul);
div=num1/num2;
printf("\n%d / %d=%d",num1,num2,div);

rem=num1%num2;
printf("\n%d %% %d=%d",num1,num2,rem);
getch();

}
======================================================
#include<stdio.h>
void main()
{
int a=20,b=10;
clrscr();
printf("Is %d > %d : %d",a,b,a>b);
printf("\nIs %d < %d : %d",a,b,a<b);
printf("\nIs %d >= %d : %d",a,b,a>=b);
printf("\nIs %d <= %d : %d",a,b,a<=b);
printf("\nIs %d == %d : %d",a,b,a==b);
printf("\nIs %d != %d : %d",a,b,a!=b);
getch();
}

================================================================
#include<stdio.h>
void main()
{
int a=20,b=10;
clrscr();
printf("Logical Operators");
printf("\nIs (a<50 && b>5): %d",(a<50 && b>5));
printf("\nIs (a<50 || b>5): %d",(a<50 || b>5));
printf("\nIs !(a<50): %d",!(a<50));
getch();
}

=======================================================================
#include <stdio.h>

void main() {
int num,num1,d,e,f,g,a,b,result,result1;
clrscr();

num=8;
result=num<<1;
printf("8<<1=%d",result);

num1=4;
result1=num1>>1;
printf("4>>1=%d",result1);

d=6;
e=5;
printf("(6&5)=%d\n",(d&e));

f=5;
g=4;
printf("(5|4)=%d\n",(f|g));
a=2;
b=4;
printf("(2^4)=%d\n",(a^b));

getch();
}
=============================================================================

#include<stdio.h>
void main()
{
int a=5,b=10,c=9,d,commaop;

clrscr();

printf("%d\n",sizeof(a));//4
printf("Address of a=%x\n",&a);

d=( (b>c) ? b : c );
printf("%d\n",d);

commaop=(10,20);
printf("comma operator result=%d",commaop);

printf("a++=%d\n",a++);
printf("b--=%d\n",b--);

getch();

}
===================================================================================
===================
#include<stdio.h>
void main()
{
int a=5,b=10,c=20,d=30,e=40,x,y,z,l,m,n,f,g;
a+=5;
b-=5;
c*=2;
d/=5;
e%=10;
printf("a+=5:%d",a);
printf("\nb-=5:%d",b);
printf("\nc*=2:%d",c);
printf("\nd/=5:%d",d);
printf("\ne%%=10:%d",e);

x=5;
x<<=2;
printf("\n5<<2=%d",x);

y=20;
y>>=2;
printf("\ny>>2=%d",y);

d=46;
e=28;
d&=e;
printf("\n(d&=e)=%d\n",d);

f=41;
g=20;
f|=g;
printf("\n(f|=g)=%d\n",f);

l=110;
m=95;
l^=m;
printf("\n(l^=m)=%d\n",l);
getch();
}
===============================================================================

You might also like