-->

neb40:Explain about operator and its types.

ans:
operator:- It is a symbol or a character used in programming. It is used to carry out some operation.
for example: +,-,= etc
It is of following types.
1)Arithmetic operator: It is used to do arithmetic calculations/operation.
 It has following types.

 +         -----------> used for addition.example is a+b. It means we are performing addition with the help of operand a and b
-           ------------>It is used for subtraction.Example is a-b.  It means we are performing subtraction with the help of operand a and b
* -------------------->used for multiplication.example is a*b. It means we are performing multiplication with the help of operand a and b
/---------------->used for division.example is a/b. It means we are performing division with the help of operand a and b
%---------------->used for remainder division.example is a%b. It means we are performing division with the help of operand a and b.It gives us remainder after division.

2)relational operator: 
This operator is used to perform comparisons between variables.It supports us to take decision logically. example,x>y ,x>=y etc
Relational operator has following types.


>------> It is used to show greater than. like x>y
>=----->It is used to show greater than or equals to.like x>=y
<-------->It is used to show a variable is smaller than another.like x<y
<=-------> It is used to show smaller than or equals to with another variable.Like x<=y
!=----------> I simply says , two variables are not equal in value.like x!=y
==---------->It says two variables have same value.It is used to test values of two variables.

3)Logical operator:-
                                   This operator is quite helpful when we want to combine multiple  conditions and take decision.It returns values in the form of 0 o 1.It works logically.
Its types are:

3.a)and (&&)-----------> It is called 'and'operator.It is used to combine multiple conditions.It gives us true output if all of them are true otherwise we get false output.
 example:if(a>b && a>c)
                      {
                            display a     
                        }
 we can see here that to be greatest,value of 'a' must be greater than b and c. So we use here '&&'
   
  3.b)or(||):- It is called 'or'operator.It is used to combine multiple conditions.It gives us true output if anyone of them is true or all are true otherwise we get false output.
 example:if(a==90 || b==90 || c==90)
                      {
                            display right angle triangle  
                        }
 we can see here that to be right angled triangle,either 'a'or 'b'or 'c' a must be 90 . So we use here '||'.

3.c) !(not )operator:-
                                It is used to reverse the result.
example
int a=5;
if(!(a==5))
{
printf("it is\n");
}
else
{
printf("it is not\n");
}
here ,the value is 5 but we get output "it is not".It is called reversing the output.

4) Assignment operator:
                                an operator ,symbolized by '=' character,is called assignment operator.It assigns value to variable.
example:
int a=6;
It means, we are assignming value 6 to variable a.

5)Unary operator:- this operator  works on one operand only.It has two types.
                               I) increment operator:- It increases the value of given variable by one.For example: ++y or y++
                                             It can be classified into pre-increment and post increment.
                                                 pre-increment:- It is written as ++x.It means first increase the value and then use that.
                                                 post-increment: It is written as x++.It means, first use that and then increase its value by one.

                               II)decrement operator:- It decreases the value of given variable by one.For example: --y or y--
                                             It can be classified into pre-decrement and post decrement.
                                                 pre-decrement:- It is written as --x.It means first decrease the value and then use that.
                                                 post-decrement: It is written as x--.It means, first use that and then decrease its value by one.


Besides these all, we have some other operators .like  bitwise,

neb42:WAP to show use of command “remove” and “rename” in data file handling with the help of example.

ans:
remove:this function is used to delete data file from the system.
syntax is:
remove("filename");

we have following example as a program.

//WAP to show use of command “remove” in data file handling with the help of example.
 #include<stdio.h>
#include<conio.h>
void main()
{
char choice;
printf("enter ur choice\n");
choice=getchar();
if(chice=='y')
        {
              remove("data.txt");
            printf("data file deleted sccessfully\n");
         }
else
{
printf("sorry, data filenot found\n");
}
getch();
}

rename: it is used to rename the file.
syntax is
rename("old name","new name");
 example is given below.
//WAP to show use of command “rename” in data file handling with the help of example.
 #include<stdio.h>
#include<conio.h>
void main()
{
char choice;
printf("enter ur choice\n");
choice=getchar();
if(chice=='y')
        {
              rename("data.txt","data1.txt");
            printf("data file renaming done successfully\n");
         }
else
{
printf("sorry, data file not found\n");
}
getch();
}


neb38:WAP to count total number of students having age in range 20 and 40 out of ‘n’ number of students.

//WAP to count total number of students having age in range 20 and 40 out of ‘n’ number of students
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,count=0;
in age[1000];
printf("enter total students' number-below 1000\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter age\n");
scanf("%d",&age[i]);
   if(age[i]>=20 && age[i]<=40)
              {
                count++;
              }
 }
printf("total students=%d\n",count);
getch();
}


neb39:Differentiate between break and continue with example

Differentiate between break and continue with example
ans:
differences are :

break
continue
1
It terminates the execution.
It takes the iteration to next level(skipping).
2
It can be used in loop and switch.
It can be used in switch
3
It uses keyword ‘break’.
It uses keyword ‘continue’.
4
Its syntax is
break;
Its syntax is
continue;
5
Example is
For(i=1;i<=4;i++)
{
  If(i<=2)
    Printf(“%d\n”,i);
     Break;
}
}
Example is
For(i=1;i<=4;i++)
{
  If(i<=2)
    Printf(“%d\n”,i);
     continue;
}
}

output is:1 
output is:1,2

neb37:Differentiate between while and do.. while loop.

Differentiate between while and do.. while loop.
ans:
Following are differences between while and do...while loop




while
Do..while
1
It is called pre-testing loop.
it is called post-testing loop
2
It uses keyword ‘while’.
it uses keyword ‘do.. while’
3
Its syntax is
Initialization;
While(condition)
{
Statement;
Increment/decrement;
}
 Its syntax is
Initialization;
do
{
Statement;
Increment/decrement;
              }while(condition);
4
nothing will happen if the condition is false.
 even after false(condition), it will run at least once.
5
Its flowchart is



Its flowchart is


6
example is
Int i=1;
While(i<=5)
{
Printf(“%d”,i);
I++;
}
 example is
Int i=1;
do
{
Printf(“%d”,i);
I++;
}while(i<=5);

q36)Wap to display those records which have price >340. Records are with fields name,price and edition.

//Wap to display those records which have price >340. Records are with fields name,price and edition.
#include<stdio.h>
include<conio.h>
void main()
{
FILE *k;                                                                    //  pointer for file declaration
char book_name[30],author_name[40];                   //identifier declaration
int book_edition;                                                         //       "             "
k=fopen("book.dat","r");

while((fscanf(k,"%d %s %d",&book_price,book_name,&book_edition)!=EOF))//reading data from data file
{
 if(book_price>340)                                                   // condition validating
{
printf("book name=%s ,book edition=%d and price=%d",book_name,book edition,book_price); //displaying data
}
}
fclose(k);                                                                                   //closing data file
getch();
}

NEB35:WAP top read all records stored in a file book.dat. Fields are name,price and author's name.

//WAP top read all records stored in a file book.dat. Fields are name,price and author's name.
#include<stdio.h>
include<conio.h>
void main()
{
FILE *k;                                                                    //  pointer for file declaration
char book_name[30],author_name[40];                   //identifier declaration
int book_price;                                                         //       "             "
k=fopen("book.dat","r");

while((fscanf(k,"%d %s %s",&book_price,book_name,author_name)!=EOF))//reading data from data file
{
printf("book name=%s ,author name=%s and price=%d",book_name,author_name,book_price); //displaying data
}
fclose(k);                                                                                   //closing data file
getch();
}