Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Feheranite to Celsius

#include<conio.h> #include<iostream.h> void main() { float f,c; clrscr(); cout<<Enter temperature in Fahrenheit : ; cin>>f; c=(f-32)/1.8; cout<<endl<<Temperature in Celsius : <<c; getch(); }

wap to count the no of vowels in a given string


#include<iostream.h> using namespace std; int main() { int vow_cnt=0; char name[15]; cout<<"Enter a name"<<endl; cin>>name; for(int i=0;i<strlen(name);i++) { if(name[i] == 'a' || name[i] == 'e'||name[i] == 'i'||name[i] == 'o'||name[i] == 'u') {

vow_cnt++; } } cout<<"Total Vowels in the string are=>"<<vow_cnt<<endl; } I/P : jithendra o/P : 3

Sum Of n natural numbers


#include<iostream.h> #include<conio.h> void main() { clrscr(); int i,n,sum=0; cout<<"How many numbers? "; cin>>n; for(i=1;i<=n;++i) { sum+=i; cout<<"\nSUM="<<sum<<endl; } getch(); }

wap to perform arithmetic calculations using switch statement


#include<iostream.h> #include<conio.h>

void main()

{ clrscr(); float a,b,res; int ch,q; cout<<"Arithmetic Operatios"; cout<<"\n\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n5.Mode"; cout<<"\n Enter your choice:"; cin>>ch;

switch(ch) { case 1: { cout<<"\n\nEnter two variables:"; cin>>a>>b; res=a+b; cout<<"\n Result="<<res; } break;

case 2: { cout<<"\n\nEnter two variables:"; cin>>a>>b; res=a-b; cout<<"\n Result="<<res; } break;

case 3: { cout<<"\n\nEnter two variables:"; cin>>a>>b; res=a*b; cout<<"\n Result="<<res; } break;

case 4: { cout<<"\n\nEnter two variables:";

cin>>a>>b; if(a>=b) { res=a/b; cout<<"\n Result="<<res; } else cout<<"\n\n\t1st varable should be greater than 2nd.!!!"; } break;

case 5: { cout<<"\n\nEnter two variables:"; cin>>a>>b; if(a>=b) { q=a/b; res=a-(b*q); cout<<"\n Result="<<res; } else cout<<"\n\n\t1st variable should be greater than 2nd..!!!"; } break; }

; getch(); }

wap to find whether a given no is even or odd

1. 2. 3. 4. 5. 6. 7.

#include<iostream.h> #include<conio.h> void main() { clrscr(); int n; cout<<"Enter no.: ";

8. cin>>n; 9. //Coding by: Snehil Khanor 10. //http://WapCPP.blogspot.com 11. if(n%2==0) 12. cout<<"EVEN"; 13. else 14. cout<<"ODD"; 15. getch(); 16. }

You might also like