write a program that input four digit number and find how
many 7 that number contains

Answers were Sorted based on User's Feedback



write a program that input four digit number and find how many 7 that number contains..

Answer / vitthal kadam

#include<iostream.h>

int main ()
{
int num,cnt,temp;
char ch;
cout<< "Enter any number in between [0-99999]: ";
cin >> num;
temp = num;
cnt = 0;
while (temp)
{
if (temp%10 == 7)
cnt++;
temp = temp/10;
}
cout<<"count of 7 in the entered number is " << cnt ;
cin>>ch;
return 0;
}

Is This Answer Correct ?    4 Yes 0 No

write a program that input four digit number and find how many 7 that number contains..

Answer / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int num,n,i=0,p;
printf("\nEnter the number ");
scanf("%d",&num);
while(num>0)
{
n=num%10;
p=num/10;
num=p;
if(n==7)
{
i++;
}
}
printf("\nthe total number of occurence of the digit 7
is %d",i);
getch();
}

Is This Answer Correct ?    2 Yes 0 No

write a program that input four digit number and find how many 7 that number contains..

Answer / kumar

#include <iostream>
#include <string>

using namespace std;

int main ()
{
string str;
cout << "Enter a 4 digit number with '7' in it:";
cin >> str;
str.resize(4);
cout << "The 4 digit numebr you have entered is:" << str
<<endl;
int ipos = 0, count =0;
ipos = str.find_first_of('7');
while (ipos!=-1)
{
count ++;
ipos = str.find_first_of('7',(ipos+1));
}
if (count)
cout <<"Number of '7' in the string: "<<count<<endl;
else
cout <<"There are no 7's in the string entered"<<endl;
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

write a program that input four digit number and find how many 7 that number contains..

Answer / gundaraj

void main()
{
int a[4],i,count=0;
cout<<"enter 4 digit number";
for(i=0;i<=3;i++)
{
cin>>a[i];
if(a[i]==7)
count++;
}
cout<<"The number of 7's are "<<count;
}

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More STL Interview Questions

Describe the My Computer and My Documents folders; identify the elements that are present in every Window.

0 Answers  


What is the name of your birth place?

0 Answers  


WHAT IS FIBONACCI SERIES?

4 Answers   Stewart,


What is the STL?

2 Answers   Epson, HP,


What do you mean by stl?

1 Answers  


How is stl different from c++ standard library?

0 Answers  


Give the output of the following program main() {char *p='a'; int *i=100/*p; } what will be the value of *i= 1

6 Answers   Sun Microsystems,


What is a list in c++ stl?

0 Answers  


if 4-5 year old brother is standing on d roof with me and watching d moon, suddenly moon coverd by cloud then how will i explain d hiding of moon to my brother.

8 Answers   MBT,


tell about sorted linked list

1 Answers  


what's the difference between abstract class and concreate class? what's the meaning of standard template library(STL)?

2 Answers  


What is C++ could you enplane me please?

1 Answers  


Categories