Help me with C programs

Write a program that outputs all perfect numbers less than 1000

Write a program that inputs two fractions in the form a/b and c/d , and outputs their sum in the form p/q cancelled down to its simplest form ?โ€‹

Everyone - please enclose the code in
 ... [ /code ] tags
 
thank you

Replies

  • Kaustubh Katdare
    Kaustubh Katdare
    Re: help me with my c programmes

    Hi, How about showing us your efforts?
  • abbd1990
    abbd1990
    i can't solve those two programmes so that i post them here ๐Ÿ˜
  • shalini_goel14
    shalini_goel14
    abbd1990
    i can't solve those two programmes so that i post them here ๐Ÿ˜
    ok, not a problem. C users will post them for you here ๐Ÿ˜‰. By the way will Java programs work for you?
  • Ashraf HZ
    Ashraf HZ
    What biggie meant was, can you try typing the basic C structure first (eg the "#include" preprocessor directive)? Then we can see what area you are struggling at ๐Ÿ˜€ You'll learn better if you show us your attempts.

    Unless, you have no clue at all?
  • Kaustubh Katdare
    Kaustubh Katdare
    I only wanted him to try. Once you know the formula for generating perfect numbers; rest is cakewalk.

    I'd still want him to post the incorrect program and ask CEans to guide him than looking for a ready-made program.
  • shalini_goel14
    shalini_goel14
    The_Big_K
    I only wanted him to try. Once you know the formula for generating perfect numbers; rest is cakewalk.

    I'd still want him to post the incorrect program and ask CEans to guide him than looking for a ready-made program.
    Even I also don't wanted to give him/her ready made program but I don't even want to give him/her a bad impression from this forum in the starting itself. I want him/her to be more active.๐Ÿ˜€
  • prakash.athani
    prakash.athani
    Hey abbd1990, check these two small programs. Are these two what you wanted? ๐Ÿ˜€


    Write a program that outputs all perfect numbers less than 1000
    /*
    C program to display all perfect numbers less than 1000
    */
    #include 
    #include 
     
    int main() {
     
                  int i,j,num,sum;
                  clrscr(); // To clear the screen
     
                  printf("The perfect numbers less than 1000 are:");
                  for(i=1;i<1000;i++) {
                         num=i;
                         sum=0;
     
                         for(j=1;j
    Write a program that inputs two fractions in the form a/b and c/d , and outputs their sum in the form p/q cancelled down to its simplest form ?
    /*
    C program to accept two fractions in the form a/b and c/d and display 
    their sum in the form p/q cancelled down to its simplest form
    */
     
    #include 
    #include 
     
    int main() {
     
                  int nr,nr1,nr2,dr,dr1,dr2,i;
                  char nrsign=' ',drsign=' ';
     
                  clrscr(); //To clear the screen
     
                  printf("\nFirst fraction :");
                  printf("\n\tInput Numerator:");
                  scanf("%d",&nr1);
                  printf("\n\tInput Denominator:");
                  scanf("%d",&dr1);
                  printf("\nSecond fraction :");
                  printf("\n\tInput Numerator:");
                  scanf("%d",&nr2); 
                  printf("\n\tInput Denominator:");
                  scanf("%d",&dr2);
                  printf("\nYour Inputs:");
                  printf("\n\tFirst fraction : %d/%d",nr1,dr1);
                  printf("\n\tSecond fraction : %d/%d",nr2,dr2);
     
                  nr=nr1*dr2+nr2*dr1;
                  dr=dr1*dr2;
     
                  if(nr<0) {
                              nrsign='-';
                              nr=-nr;
                  }
                  if(dr<0) { 
                              drsign='-';
                              dr=-dr;
                  }
     
                  i=2;
                  while(i<=dr){
     
                              if(nr%i==0 && dr%i==0){
                                      nr=nr/i;
                                      dr=dr/i;
                                      i=2;
                              }
                              else i=i+1;
                  }
     
                  printf("\nResult : %c%d /%c%d",nrsign,nr,drsign,dr);
                  getch();
                  return 0;
    }
  • Ashutosh_shukla
    Ashutosh_shukla
    Hey buddy you got the code but if you would have tried and posted incorrect code we all would have been much more happy anyways welcome to the forum and we hope better efforts from those joining in but if you have any problem we are always there to help you
  • abbd1990
    abbd1990
    thanks very much my friends for your kind help

You are reading an archived discussion.

Related Posts

I have a small remotely controlled vehicle and I want it to be able to determine its orientation. Can someone recommend some sort of electronic compass that fits easily into...
I m Mtech student and has to create a model based on mecatronics(mech.+electronics) so plz help me out wat to make?
Hi there. I am 23 student from Scotland. Just started an Electronics and Electrical course at uni. Glad to be part of the forum and....um...yea... hello :dance:
Hi there. Wooo my first proper post. Right down to buisness. I have been using the schematics package tina. And I have a problem. This may be simple but I...
Hi mates, i have installed kubuntu in my pc. am in need some basic codes of linux and some more info about linux.