Showing posts with label area. Show all posts
Showing posts with label area. Show all posts

Write a program to count number of words in a line

A line is taken from user and number of words is calculated..


Select To use this code as it is.. select and copy paste this code into code.cpp file :)



  1. #include<iostream.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4. void main()
  5. {
  6. clrscr();
  7. char str[100];
  8. int w=1;
  9. cout<<"Please enter a String: ";
  10. gets(str);
  11. //Coding by: Snehil Khanor
  12. //http://WapCPP.blogspot.com
  13. for (int i=0;str[i]!='\0';i++)
  14. {
  15. if(str[i]==' ')
  16. w++;
  17. }
  18. cout<<"There are "<<w<<" words.";
  19. getch();
  20. }

Write a program to find area of a circle

Radius of circle is taken from user and Area is calculated

Select To use this code as it is.. select and copy paste this code into code.cpp file :)



  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. float r,a;
  7. cout<<"enter radius ";
  8. //Coding by: Snehil Khanor
  9. //http://WapCPP.blogspot.com
  10. cin>>r;
  11. a=3.14*r*r;
  12. cout<<"The area is "<<a;
  13. getch();
  14. }

Check out this stream