if statement Syntex if (codition) Statement Or if (condition) { Statement1 Statement1 } If else statement Syntax if(condition) Statement else Statement Or if(condition) { Statement1 Statement2 } Else { Statement1 Statement2 } Example: #include<iostream.h> #include<conio.h> void main() { int a,b; clrscr(); cout<<”\n enter value of a and b”; cin>>a>>b; if(a>b) cout<<”a is greater”; else cout<<”b is greater “; getch(); } WAP to find whether a number is even or odd? WAP to enter a temperature in celcius and convert it into Fahrenheit and if the temperature is 98.6 F or more than display fever otherwise normal. F=9*c/5+32; WAP to find whether a number is positive or negative. WAP to find whether a year is leap or not. /* input selling price and cost price of an item and print whether seller has made profit or loss and how much*/ import java.io.*; class profit_loss { public static void main(String args[]) throws IOException
if statement Syntex if (codition) Statement Or if (condition) { Statement1 Statement1 } If else statement Syntax if(condition) Statement else Statement Or if(condition) { Statement1 Statement2 } Else { Statement1 Statement2 } Example: #include<iostream.h> #include<conio.h> void main() { int a,b; clrscr(); cout<<”\n enter value of a and b”; cin>>a>>b; if(a>b) cout<<”a is greater”; else cout<<”b is greater “; getch(); } WAP to find whether a number is even or odd? WAP to enter a temperature in celcius and convert it into Fahrenheit and if the temperature is 98.6 F or more than display fever otherwise normal. F=9*c/5+32; WAP to find whether a number is positive or negative. WAP to find whether a year is leap or not. /* input selling price and cost price of an item and print whether seller has made profit or loss and how much*/ import java.io.*; class profit_loss { public static void main(String args[]) throws IOException
Java%20Notes_Class_9.docx