W.A.P. C++

WAP | CPP | Programs in C++ | C++ Solutions

Snehil Khanor's Binary Log
Showing posts with label first program. Show all posts
Showing posts with label first program. Show all posts

Write a program to store elements in m x n 2D array (Matrix)


m(row) and n(coloumns) are taken from user.. Elements are taken from user.. matrix is displayed in tabular form..
This should be your first program for Matrix.
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. int a[10][10],m,n,i,j;
  7. cout<<"Enter number of rows: ";
  8. cin>>m;
  9. cout<<"Enter number of coloumns: ";
  10. cin>>n;
  11. cout<<endl<<"Enter elements of matrix: "<<endl;
  12. //Coding by: Snehil Khanor
  13. //http://WapCPP.blogspot.com
  14. for(i=0;i<m;i++)
  15. {
  16. for(j=0;j<n;j++)
  17. {
  18. cout<<"Enter element a"<<i+1<<j+1<<": ";
  19. cin>>a[i][j];
  20. }
  21. }
  22. cout<<endl<<"Displaying Matrix: "<<endl<<endl;
  23. for(i=0;i<m;i++)
  24. {
  25. for(j=0;j<n;j++)
  26. {
  27. cout<<a[i][j]<<" ";
  28. }
  29. cout<<endl<<endl;
  30. }
  31. getch();
  32. }

write a program to store and display 10 numbers in an array


10 numbers are first stored in array and then the array is displayed.
This should be your first array program.
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. int ar[10];
  7. cout<<"Enter array element: "<<endl;
  8. for(int i=0;i<10;i++)
  9. //Coding by: Snehil Khanor
  10. //http://WapCPP.blogspot.com
  11. {
  12. cout<<"Enter element "<<i<<": ";
  13. cin>>ar[i];
  14. }
  15. cout<<"Elements of array: "<<endl;
  16. for(i=0;i<10;i++)
  17. cout<<"Element at index number "<<i<<" is: "<<ar[i]<<endl;
  18. getch();
  19. }

Write a program to display the input


This is an ideal first program for learning "cin"
Two numbers are taken from the user and then displayed as output.
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. int a,b;
  7. cout<<"enter first no. ";
  8. cin>>a;
  9. //Coding by: Snehil Khanor
  10. //http://WapCPP.blogspot.com
  11. cout<<"enter second no. ";
  12. cin>>b;
  13. cout<<"First no. is "<<a;
  14. cout<<"\nSecond no.is "<<b;
  15. getch();
  16. }

Write a program to output a messege


This is an ideal First C++ (CPP) program.
All necessary things are described with in the program in comments.
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h> //These are the Header files and are essential..
  2. #include <conio.h> // They varies program to program.
  3. void main() //This is a special type of function.Program starts and ends in MAIN.
  4. {
  5. //Coding by: Snehil Khanor
  6. //http://WapCPP.blogspot.com
  7. clrscr(); //This clears previous outputs from the output screen
  8. cout<<"Hello India"; //This is responsible for diplaying a messege
  9. cout<<"\nThis is my first C++ programme";
  10. getch(); //This helps to sustain the output on Screen.
  11. }

Search

About WAP C++

Here you'll find a wide range of programs' solution ranging from beginer level to advanced level.
All programs here are made, compiled and tested by me..and are running absolutely fine.. still if you find any bug in any program do let me know :)

Followers

Subscribe via email

Enter your email address:

Delivered by FeedBurner

my Binary Log



eXTReMe Tracker