chhotu shaw & gaurav shaw
exercise:-1
1. write a program to print sample strings like "hello word".ans: #include<stdio.h>
#include<conio.h>
void main()
{
printf("hello word");
getch();
}
2. "welcome to c programming" with different formats using escape sequences.
ans: \\ \
\" "
\' '
\? ?
\a alert
\b back space
\n new line
\t horizontal tab
\v vertical tab
\r carriage return
example:- #include<stdio.h>
#include<conio.h>
void main()
{
printf("hello \nword");
printf("\nhello \tword!");
printf("\n\"hello word!\"");
printf("\nhello\bword!");
getch();
}
3. print different data types in 'c' amd there ranges.
ans:- #include<stdio.h>
#include<conio.h>
#define size(X) sizeof(x)*8
void signed-one(int);
void unsigned-one(int);
void main();
{
printf("\n range of int");
signed-one(size(int));
printf("\n range of unsigned (int));
unsigned-one(size(unsigned int));
printf("\n range of char");
signed-one(size(char));
printf("\n range of unsigned char");
unsigned_one(size(unsigned short));
}
void signed_one(1nt wunt){
jnt min,max,pro;
pro=1;
while(count !=1){
pro=pro<<1;
count=count--;
}
min=-pro;
min=min+1;
max=pro-1;
printf("\n%d to %d",min,max);
}
void unsigned-one(int count)
{
unsigned int min,max,pro=1;
while(count!=0){
pro=pro<<1;
count=count--;
}
min=0;
max=pro-1;
printf("\n%4 to%4",min,max);
}
EXERCISE:-2
1.write a program to demonstrate arithmetic operators.(+,-,*,/,%)
ans:-#include<stdio.h>
#include<conio.h>
void main()
{
float div;
int add,sub,mul,mod,a,b;
clrscr();
printf("input the two number");
scanf("%d%d",&a&b);
add=a+b;
printf("\n add=%d",add);
sub=a-b;
printf("\n sub=%",sub);
mul=a*b;
printf("\n mul=%d",mul);
div=a/b;
printf("\n div=%d",div);
mod=a%b;
printf("\n mod=%d",mod);
getch();
}
2. Demonstrate logical operators.(logical and, logical or).
logical operator :-
logical operator are used to combined to are more condition or two complement the evalumention of the origenal condition in consetrastion the result of the operation of a logical operator is a bullion value either true or fluse.
&&- logical AND
||- logical OR
logical AND:-
logical AND is denoted by double ampersand character(&&), it is used to check the combination of more than one condition; it is a binary operator.
logical OR:-
logical OR is denoted by double pipe character(||), it is used to check the combination of more than one condition: if is a binary operator which require two operator.
Comments
Post a Comment