Wednesday, 17 July 2013



//// sum of 1st and 4th digit ////

#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#include "iostream"

using namespace std; 

int _tmain(int argc, _TCHAR* argv[])
{
       int a,b,c,d,sum;
       cout<<"enter 4-digit number";
       cin>>d;
       a=d/1000;
       d=d%1000;
       b=d/100;
       d=d%100;
       c=d/10;
       d=d%10;
       sum=a+d;
       cout<<"sum="<<sum;
       getch();

}

0 comments :

Post a Comment