Write and run a program that reads a six digit integer and prints the sum of its six digits. Use the quotient operator(/) and the remainder operator(%) to extract the digit from the integer. For example, if N is the integer 876543 then n/1000%10 is its thousands digit 6.
<< Go to Index Page >>
<< Go to Index Page >>
#include
উত্তরমুছুনmain()
{
int i, j, n=100000, sum=0;
while(scanf("%d", &i)==1)
{
while(i>0)
{
j=i/n;
i=i%n;
n=n/10;
sum+=j;
}
printf("%d\n", sum);
sum=0;
n=100000;
}
return 0;
}
Great job.Why didn't use getch();?
উত্তরমুছুনIt is a continuous program. never end if you don't close the exe window. For that reason, getch() is useless.
উত্তরমুছুন#include"stdio.h"
উত্তরমুছুনmain(){
int a,i,sum=0,count=0;
scanf("%d",&a);
if(a!=0){
while(a>0){
i=a%10;
a=a/10;
sum+=i;
count++;
}
printf("Sum is %d\n",sum);
printf("Number of digit is %d\n",count);
}
}
#include
উত্তরমুছুনmain()
{
int x,y,k=0;
printf("Enter the number");
scanf("%d",&x);
while(x>0)
{
y=x%10;
k=k+y;
x=x/10;
}
printf("%d",k);
getch();
}
NAME:Mahmuda sultana
উত্তরমুছুনID:201330499
#include
using namespace std;
class A
{
public:
int i,sum=0,count=0;
int get_inp(int a)
{
b=a;
}
protected:
int b;
};
class B:public A
{
public:
int arithmatic()
{
if(b!=0)
{
while(b>0)
{
i=b%10;
b=b/10;
sum+=i;
count++;
}
cout<<"Sum is:"<>a;
bb.get_inp(a);
bb.arithmatic();
return 0;
}
Summer 2017
উত্তরমুছুনID#201610042
Answer to Question No 7:
https://drive.google.com/file/d/0B99eePh0LV8gLVY0YndXQmdPMzg/view?usp=drivesdk
ID : 201620195
উত্তরমুছুনhttps://drive.google.com/open?id=0B9K31ospCyFjVkdHOXE3Y001a1k
https://drive.google.com/open?id=0BzTqZMBWR6eObXRtaW5JOWhiQjA
উত্তরমুছুনhttps://drive.google.com/open?id=0B8369pAqjVVpdHBPMnhLZ2RIb3M
উত্তরমুছুনID:201520552
উত্তরমুছুনhttps://drive.google.com/open?id=0B5pG0kIjzgEKU2c1N010dloyWEk
ID 201610456
উত্তরমুছুনMD USUF MIA
https://drive.google.com/open?id=0B_PIGnOMR0K2Nk9UbU90NjFmN3M
ID 201610456
উত্তরমুছুনMD USUF MIA
without using any loop
https://drive.google.com/open?id=0B_PIGnOMR0K2RUh0TW5GZ3d4c1k
Id= 201710494
উত্তরমুছুনhttps://www.dropbox.com/s/p5u5fzl67jpfnow/prob%207.cpp?dl=0
https://drive.google.com/open?id=0Byxq3aat_mNSd19RWWdTNlZIQU0
উত্তরমুছুনhttps://drive.google.com/open?id=0B3bVD5Ppt_STUjJJcmEydTBJbEU
উত্তরমুছুন