मराठी
महाराष्ट्र राज्य शिक्षण मंडळएचएससी विज्ञान (संगणक विज्ञान) इयत्ता १२ वी

Write a program in C++ to accept a positive integer and display its multiplication table. (Hint: if n = 5, then 5, 10, 15, 20, ......., 50) - Computer Science 1

Advertisements
Advertisements

प्रश्न

Write a program in C++ to accept a positive integer and display its multiplication table.

(Hint: if n = 5, then 5, 10, 15, 20, ......., 50)

कोड लेखन
Advertisements

उत्तर १

Without using a class:

#include<iostream h>
#include<conio.h>
void main()
{
      int n, i;
      cout<<"Enter a number of which table is to be created";
      cin>>n;
      for(i=1; i<=10; i++)
      {
            cout<<n*i<<endl;
      }
      getch();
}
shaalaa.com

उत्तर २

Using a class:

#include<iostream.h>
#include<conio.h>
class table
{
      int n, i;
      public;
      void display()
      {
            cout<<"Enter a number of which table is to be created";
            cin>>n;
            for(i=1;i<=10;i++)
            {
                  cout<<n*i<<endl;
            }
      }
};
void main()
{
table t;
t.display();
}
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2024-2025 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×