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

Define the terms: field, record, table and database

5 Answers  


a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.

0 Answers  


Question 1)Read the data from one file and remove all the duplicated words and generate an output file containg only using words.Program should also print number of occurance of each words on standard output.(Program must be use STL and iostream object). Question 2)Write a program to convert the lower case contents of file to upper case using STL. Question 3)What is the output of this problem. int i=12; int &r =i; r+r/4; int +p =&r; int *p = &r; P+=r; return 1; Answer :a)12 b)17 c) 30 d)24 E)15 Question 4) #include #include #include void main() { char srcstr[30],desstr[30]; int i,len; clrscr(); cout<<"\nenter the string\n"; cin>>srcstr; len=strlen(srcstr); for(i=0;srcstr[i]!='\0';i++) { desstr[--len]=srcstr[i]; } desstr[i]='\0'; cout<<"\nreversed string is\n"; for(i=0;desstr[i]!='\0';i++) { cout< } getch(); } Answer : A) string output b)tuptuo gnirts c) string d)output Question 5) Class Test { static const Tk=LEN; int q; public: foo(intx =LEN):q(x){}; TGet Q() const { return q:} void call test Foo<long :9> foo(10); std::const<< foo.Getq(); Answer: 7,8,9,10,11 question 6) class A { int a; char b; }; class B:public A { char b; int a; }; What is the size? Answer a)5 bytes for class A and 5 bytes class B b)4 bytes for class A and 8 bytes class B. c).... d)....

2 Answers   Bally Technologies,


What are the various types of stl containers?

0 Answers  


differentiate between private, public and protected data members of the class using example.

1 Answers  


Write a program in C/C++ to implement reader- writer problem

1 Answers   Wipro,


What is the STL?

2 Answers   Epson, HP,


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 FIBONACCI SERIES?

4 Answers   Stewart,


Is stl open source?

0 Answers  


What is meant by stl in c++?

0 Answers  


Explain how to insert a hyperlink in to an Excel worksheet and save a Word document as a Web page.

1 Answers  


Categories