Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6176015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:01:34+00:00 2026-05-24T00:01:34+00:00

i am trying to write a program which inputs two numbers from user as

  • 0

i am trying to write a program which inputs two numbers from user as strings….if the first number is greater than the second number they are multiplied and the result is returned…i converted the input numbers into character arrays and then used ascii codes to convert the charcters into actual numbers…then i performed calculations on the numbers…here are the functions that i used…

double greater1(char a[],char b[],int size1,int size2)//the arrays here are those containing the two numbers
{ double first;
double second;
 for(int i=0;i<size1;i++)
 first=first+(pow(10.0,(double)(size1-i-1))*(a[i]-48));
 for(int i=0;i<size2;i++)
 second=second+(pow(10.0,(double)(size2-i-1))*(b[i]-48));
 return(first>second?first:second);
}   

double smaller1(char a[],char b[],int size1,int size2)
{ double first;
double second;
 for(int i=0;i<size1;i++)
 first=first+(pow(10.0,(double)(size1-i-1))*(a[i]-48));
 for(int i=0;i<size2;i++)
 second=second+(pow(10.0,(double)(size2-i-1))*(b[i]-48));
 return(first<second?first:second);
}     

double multiply(char a[], char b[],int size1,int size2) 
{double first=greater1(a,b,size1,size2);
double second=smaller1(a,b,size1,size2);
//cout<<second;....(a)
//cout<<smaller1(a,b,size1,size2);....(b)
//cout<<smaller1(a,b,size1,size2);....(c)
//cout<<smaller1(a,b,size1,size2);....(d)
double mult=first*second;
return mult;
} 

now to test these functions i input 43 and 10…but the product which was returned was 860…so to find the error i inserted the lines (a),(b),(c),(d)….(a) gave output 20,(b) gave 30 and after that all further lines (c),(d)… were giving output as 10…when i inserted

cout<<smaller1(arr1,arr2,ln1,ln2);//these parameters were the ones also passed to the above three functions             

in main(), everytime i got the output 10….so there must be some problem with using smaller1() in multiply func…plz can anyone point out the problem

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:01:35+00:00Added an answer on May 24, 2026 at 12:01 am

    It’s easy actually: you haven’t initialized first and second in smaller1 and greater1. Local variables are never initialized implicitly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a C++ program that takes the following inputs from
I'm trying to write a simple program in VC++ which will just initialize the
I'm trying to write a C# program, where when a user enters some data
I am new to programming and Java and trying to write a program which
As an experiment i am trying to write the following program which allows me
I'm trying to write a program which calls a library function ( http://www.diku.dk/hjemmesider/ansatte/pisinger/3dbpp.c )
I am trying to write a program wit Perl which should returns the frequency
I'm trying to write a program to process the BSD-style process accounting file under
I'm trying to write a program that uses sockets to connect with other instances
I'm trying to write a program in C (on Linux) that loops until the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.