Ads Top

SUM OF NUMBERS USING STRUCTURE

#include<conio.h>
#include<iostream.h>
struct student
{
   int a,b;
   int total;
};
   void main()
{

   clrscr();
   struct student s;
   cout<<"Enter two numbers: ";
   cin>>s.a>>s.b;
   s.total = s.a+s.b;
   cout<<"The sum is "<<s.total;
   getch();
}

OUTPUT :
Enter two numbers : 8
4
The sum is 12


No comments:

Touchfeeds. Powered by Blogger.