Recent

recentposts

Revision 01

 Revision _1

Lets have a quick revision of previous concepts by practicing same question using different methods. 


Write a Program to add the number .


Method :1


#include<iostream.h>

#include<conio.h>


void main( ) {

clrscr( ) ;

 

int numb1 , numb2 , answer ;

 

cout<<”\n Enter the first number = ” ;

cin>>numb1 ;

cout<<”\n Enter the first number = ” ;

cin>>numb1 ;

 

answer = numb1 + numb2 ;

 

cout<<”\n The Result is = ”<<answer ;

 

getch() ;

}

 


Method :2


#include<iostream.h>

#include<conio.h>


void main() {

clrscr() ;

 

int numb[2] , answer ;

 

cout<<”\n Enter the first number = ” ;

cin>>numb[0] ;

cout<<”\n Enter the first number = ” ;

cin>>numb[1] ;

 

answer = numb[0] + numb[1] ;

 

cout<<”\n The Result is = ”<<answer ;

 

getch() ;

}

 

 

Method :3


#include<iostream.h>

#include<conio.h>


void main() {

clrscr() ;

 

int numb[2]  ;

 

cout<<”\n Enter the first number = ” ;

cin>>numb[0] ;

cout<<”\n Enter the first number = ” ;

cin>>numb[1] ;

 

numb[0] = numb[0] + numb[1] ;

/* here, first the addition will be performed and then the output of addition will be stored in numb[0] */

/* Storing the output in numb[0] which will reduce the number of variable requirement which reduce the memory used . */

 

cout<<”\n The Result is = ”<<numb[0] ;

 

getch() ;

}

 

 

Method : 4


#include<iostream.h>

#include<conio.h>

 

void ourfunction int a[] ) {

    int sum ;

    sum a[0] + a[1] ;

    cout<<"\n The result is = "<< sum ;

}

 

void main () {

    clrscr() ;

 

    int num[2]  ;

    

    cout<<"\n Enter the number = " ;

    cin>>num[0] ;

    cout<<"\n Enter the number = " ;

    cin>>num[1] ;

 

    ourfunction ( num ) ;

 

    getch() ;

}

 


Method : 5


#include<iostream.h>

#include<conio.h>

 

int ourfunction int a[] ) {

    int sum ;

    sum a[0] + a[1] ;

    return sum ;

}

 

void main () {

    clrscr() ;

 

    int num[2] , result  ;

    

    cout<<"\n Enter the number = " ;

    cin>>num[0] ;

    cout<<"\n Enter the number = " ;

    cin>>num[1] ;

 

    result ourfunction( num ) ;

    cout<<"\n The result is = "<<result 

 

    getch() ;

}

 


Method : 6


#include<iostream.h>

#include<conio.h>

 

void ourfunction (  ) {

    int num[2] , result  ;

    

    cout<<"\n Enter the number = " ;

    cin>>num[0] ;

    cout<<"\n Enter the number = " ;

    cin>>num[1] ;

   

    result = num[0] + num[1] ;

    cout<<”\n The result is = ”<<result ;

 

}

 

void main () {

    clrscr() ;

 

    ourfunction(  ) ;

 

    getch() ;

}

 

 

Method : 7


#include<iostream.h>

#include<conio.h>

 

int ourfunction (  ) {

    int num[2] , result  ;

    

    cout<<"\n Enter the number = " ;

    cin>>num[0] ;

    cout<<"\n Enter the number = " ;

    cin>>num[1] ;

   

    result = num[0] + num[1] ;

    return result ;

 

}

 

void main () {

    clrscr() ;

   

    int value ;

    value = ourfunction(  ;

    cout<<”\n The result is = ”<< value ;

    getch() ;

}


revision


 

 

 

SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

Please give your valuable suggestions