Results 1 to 9 of 9

Thread: c++ help

  1. #1
    hasib ahmed's Avatar
    hasib ahmed is offline Advance Member
    Last Online
    12th November 2022 @ 11:45 PM
    Join Date
    08 Sep 2008
    Location
    rawalpindi
    Age
    34
    Gender
    Male
    Posts
    850
    Threads
    106
    Credits
    83
    Thanked
    15

    Default c++ help

    A number is known as a perfect number - if sum of its divisors (excluding itself) is equal to the number, deficit – if sum is less than number, abundant – if sum is greater than number. Write an algorithm that checks a number for perfect, deficit and abundant.
    e.g, 6, its divisors sum = 1 + 2 + 3 = 6. As sum = number, so number is perfect
    ma ishq-e-kainaat ma zanjeer ho saku
    mujh ko hisar-e-zaat ke shar se rahai de


  2. #2
    Kashif Mehmood1's Avatar
    Kashif Mehmood1 is offline Advance Member
    Last Online
    23rd January 2022 @ 06:51 PM
    Join Date
    30 May 2009
    Location
    Rawalpindi
    Age
    33
    Gender
    Male
    Posts
    1,392
    Threads
    49
    Credits
    1,198
    Thanked
    58

    Default

    void main ()
    {
    int num,sum=0;
    cout<<"enter number";
    cin>>num;
    for(int i=1; i <=num/2; i++)
    {
    if (num%i==0)
    sum= sum+i;
    }
    if(sum==num)
    cout<<"number is perfect";
    else if(sum<num)
    cout<<"deficit";
    else
    cout<<"abundant";
    }

  3. #3
    hasib ahmed's Avatar
    hasib ahmed is offline Advance Member
    Last Online
    12th November 2022 @ 11:45 PM
    Join Date
    08 Sep 2008
    Location
    rawalpindi
    Age
    34
    Gender
    Male
    Posts
    850
    Threads
    106
    Credits
    83
    Thanked
    15

    Default

    Quote Kashif Mehmood1 said: View Post
    void main ()
    {
    int num,sum=0;
    cout<<"enter number";
    cin>>num;
    for(int i=1; i <=num/2; i++)
    {
    if (num%i==0)
    sum= sum+i;
    }
    if(sum==num)
    cout<<"number is perfect";
    else if(sum<num)
    cout<<"deficit";
    else
    cout<<"abundant";
    }

    bundel of thanks yar ab pta chal gya kahan error tha

  4. #4
    hasib ahmed's Avatar
    hasib ahmed is offline Advance Member
    Last Online
    12th November 2022 @ 11:45 PM
    Join Date
    08 Sep 2008
    Location
    rawalpindi
    Age
    34
    Gender
    Male
    Posts
    850
    Threads
    106
    Credits
    83
    Thanked
    15

    Default

    The process of finding the largest number (i.e. the maximum of a group of numbers) is used frequently in computer applications. For example, a program that determines the winner of a sales contest inputs the number of units sold by each salesperson. Write a pseudo code program (algorithm) that uses a for statement to determine and prompt the largest number of 10 numbers input by the user. Your program should use three variables, as follows:
    Counter: a counter to count to 10 (i.e. to keep track of how many numbers have been input and to determine when all 10 numbers have been processed).
    Number: the current number input to the program.
    Largest: the largest number found so far.

  5. #5
    hasib ahmed's Avatar
    hasib ahmed is offline Advance Member
    Last Online
    12th November 2022 @ 11:45 PM
    Join Date
    08 Sep 2008
    Location
    rawalpindi
    Age
    34
    Gender
    Male
    Posts
    850
    Threads
    106
    Credits
    83
    Thanked
    15

    Default

    ??

  6. #6
    bais is offline Senior Member
    Last Online
    31st July 2015 @ 02:07 PM
    Join Date
    23 Aug 2008
    Location
    Izlooo
    Gender
    Male
    Posts
    3,519
    Threads
    96
    Thanked
    263

    Default



    jaldi ma ya bana hai.....dekh lo...

    #include<stdio.h>
    #include<conio.h>


    int main(){
    int number[100], largest, count, counter,size;

    printf("Size of Array:\n\n");
    scanf("%d", &size);

    printf("\nEnter Your Number:\n");
    for(counter=0;counter<size;counter++){
    scanf("%d", &number[counter]);
    }

    count = number[0];
    for(counter = 1 ; counter < size ; counter++){
    if(count < number[counter])
    count = number[counter];
    }

    printf("\nLargest Value = %d", count);
    getch();
    return 0;
    }
    Last edited by bais; 16th November 2011 at 09:28 PM.

  7. #7
    Kashif Mehmood1's Avatar
    Kashif Mehmood1 is offline Advance Member
    Last Online
    23rd January 2022 @ 06:51 PM
    Join Date
    30 May 2009
    Location
    Rawalpindi
    Age
    33
    Gender
    Male
    Posts
    1,392
    Threads
    49
    Credits
    1,198
    Thanked
    58

    Default

    100 ki jaga 10 aye ga. kun 10 numbers input lenay hain

  8. #8
    bais is offline Senior Member
    Last Online
    31st July 2015 @ 02:07 PM
    Join Date
    23 Aug 2008
    Location
    Izlooo
    Gender
    Male
    Posts
    3,519
    Threads
    96
    Credits
    0
    Thanked
    263

    Default

    Quote Kashif Mehmood1 said: View Post
    100 ki jaga 10 aye ga. kun 10 numbers input lenay hain
    nahi g....100 lihko ya 1000 b problem nahi hai just ik value assign ki hai....program jb run hota hia ye pochta hai user se k kitnae ki array banai hai?

    read the whole code and execute it & then comment.

  9. #9
    Salluhassan's Avatar
    Salluhassan is offline Senior Member+
    Last Online
    10th February 2020 @ 06:32 PM
    Join Date
    02 Aug 2010
    Location
    Lahore
    Gender
    Male
    Posts
    2,241
    Threads
    29
    Credits
    114
    Thanked
    217

    Default

    han ... ye static array hai , ismay runtime per user say input nahi lay saktay ho .. ur program should use dynamic memory to assign data .

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •