Reverse Gear Finals

  • Uploaded by: sourabh
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Reverse Gear Finals as PDF for free.

More details

  • Words: 870
  • Pages: 8
We uploaded exe files of these programs.And participants had to send us code that generate same exe. Solution to Problem 1. #include<stdio.h> #include #include<string.h> #include<math.h> #include int nprime(int); int main() { int num1=1,num2,x,y; int sum; printf("enter 0 for exit:"); while(num1!=0) { printf("\nEnter two numbers less than 1000:\n"); scanf("%d",&num1); if(num1<=0||num1>=1000) exit(1); else { scanf("%d",&num2); if(num2>=1000||num2<0) exit(1); x=nprime(num1); y=nprime(num2); sum=x*y; printf("OUTPUT:%d",sum); } } }

int nprime(int n) { int count=0,i,j,k,rem; if(n==0||n==1) return(0); else { for(i=2;i<=n;i++) { k=0; for(j=1;j<=i;j++) { rem=i%j; if(rem==0) k++; } if(k==2) count++; } return(count);

} } Judge’s Input file for problem 1 1 1 1 0 3 3 3 4 4 3 55 66 86 09 45 89 53 087 09 552 823 600 006 007 67 00 236 000 0 Judge’s Output file for problem 1 enter 0 for exit: Enter two numbers less than 1000: OUTPUT:0 Enter two numbers less than 1000: OUTPUT:0 Enter two numbers less than 1000: OUTPUT:4 Enter two numbers less than 1000: OUTPUT:4 Enter two numbers less than 1000: OUTPUT:4 Enter two numbers less than 1000: OUTPUT:288 Enter two numbers less than 1000: OUTPUT:92 Enter two numbers less than 1000: OUTPUT:336 Enter two numbers less than 1000: OUTPUT:368 Enter two numbers less than 1000: OUTPUT:404 Enter two numbers less than 1000: OUTPUT:15587 Enter two numbers less than 1000: OUTPUT:12 Enter two numbers less than 1000: OUTPUT:0 Enter two numbers less than 1000: OUTPUT:0 Enter two numbers less than 1000:

Solution to Problem 2. #include<stdio.h> #include #include<math.h> #include<stdlib.h> long int reverse(long int); long int prime(long int); int main() { long int num=1,rnum,ans,pbn; printf("enter 0 for exit"); while(num!=0) { printf("\nEnter any number greater than 100:"); scanf("%d",&num); if(num<=100) exit(1); rnum=reverse(num); pbn=prime(rnum); pbn=int(pbn); ans=reverse(pbn); printf("OUTPUT:%ld",ans); } return(0); } long int reverse (long int n) { long int mod,rev=0; while(n>0) { mod=n%10; rev=(rev*10)+mod; n=n/10; } return(rev); } long int prime(long int no) { long int j,i; int rem,k; for(j=(no-1);j>0;j--) { k=0; for(i=1;i<=j;i++) { rem=j%i; if(rem==0) k++; } if(k==2) return(j); else continue;

} } Judge’s Input File 101 110 111 211 233 313 667 4455 5665 6576 9999 11111 33444 33211 67776 333444 0 Judge’s Output File enter 0 for exit Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater Enter any number greater

than than than than than than than than than than than than than than than than than

100:OUTPUT:79 100:OUTPUT:7 100:OUTPUT:901 100:OUTPUT:901 100:OUTPUT:133 100:OUTPUT:113 100:OUTPUT:167 100:OUTPUT:1355 100:OUTPUT:9565 100:OUTPUT:7376 100:OUTPUT:3799 100:OUTPUT:39011 100:OUTPUT:71444 100:OUTPUT:31211 100:OUTPUT:36776 100:OUTPUT:703444 100:

Solution to problem 3 #include<stdio.h> #include<math.h> #include int main() { double a,b,c,A,B,C; int i=0; printf("enter 0 in all 3 no's to exit"); //clrscr(); while(1) { // fflush(stdin); printf("\nenter three numbers:"); scanf("%lf%lf%lf",&a,&b,&c);

if(a==0&&b==0&&c==0) return 0; if(a>0 && b>0 && c>0) { if(a>=b && a>=c) { if(a>=b+c) { printf("Invalid Input"); } else { A=acos(((b*b)+(c*c)-(a*a))/(2*b*c))*180/3.141592654; printf("%lf",A); } } else if(b>=a && b>=c) { if(b>=a+c) { printf("Invalid Input"); } else { B=acos(((a*a)+(c*c)-(b*b))/(2*a*c))*180/3.141592654; printf("%lf",B); } } else if(c>=a && c>=b) { if(c>=b+a) { printf("Invalid Input"); } else { C=acos(((b*b)+(a*a)-(c*c))/(2*b*a))*180/3.141592654; printf("%lf",C); } } } else { printf("Invalid Input"); } /*fflush(stdin); printf("\npress 1 to exit"); printf("\npress any other number to continue"); fflush(stdin); scanf("%d",&i);*/ } return 0; }

Judge’s Input for Problem 3 3 4 5 3 4 6 1 1 1 1 2 3 5 3 4 7 9 11 13 13 1 0 0 0 Judge’s Output for Problem 3 enter 0 in all 3 no's to exit enter three numbers:90.000000 enter three numbers:117.279613 enter three numbers:60.000000 enter three numbers:Invalid Input enter three numbers:90.000000 enter three numbers:85.903956 enter three numbers:87.795772 enter three numbers: Solution to problem 4 #include<stdio.h> #include<math.h> #include int main() { double a,b,c,A,B,C; int i=0; printf("enter 0 in all 3 no's to exit"); //clrscr(); while(1) { // fflush(stdin); printf("\nenter three numbers:"); scanf("%lf%lf%lf",&a,&b,&c); if(a==0&&b==0&&c==0) return 0; if(a>0 && b>0 && c>0) { if(a>=b && a>=c) { if(a>=b+c) { printf("Invalid Input"); } else { A=acos(((b*b)+(c*c)-(a*a))/(2*b*c))*180/3.141592654; printf("%lf",A); } } else if(b>=a && b>=c) { if(b>=a+c) {

printf("Invalid Input"); } else { B=acos(((a*a)+(c*c)-(b*b))/(2*a*c))*180/3.141592654; printf("%lf",B); } } else if(c>=a && c>=b) { if(c>=b+a) { printf("Invalid Input"); } else { C=acos(((b*b)+(a*a)-(c*c))/(2*b*a))*180/3.141592654; printf("%lf",C); } }

} else { printf("Invalid Input"); } /*fflush(stdin); printf("\npress 1 to exit"); printf("\npress any other number to continue"); fflush(stdin); scanf("%d",&i);*/

} return 0; } Judge’s Input to Problem 4: aA aBcDeF zZzZzZzZ xxxxxxxxx ApPlE ZZ ZZA Yz 0 Judge’s Output to Problem 4: Enter 0 to exit.String of minimum length 2 will only generate output Enter a string:102 Enter a string:125 Enter a string:20 Enter a string:30 Enter a string:130 Enter a string:132 Enter a string:101 Enter a string:131 Enter a string:

Solution to problem 5 /*this program gives the sum of nth terms of fibonacci and pascals triangle*/ #include<stdio.h> #include<stdlib.h> int fact(int a) { int sum=1,i; for(i=1;i<=a;i++) sum=sum*i; return (sum); } int main() { int i,j,n,sumf,num,k,sump; printf("Enter 0 to exit:\n"); while(1) { printf("Enter a positive number less than 38:"); scanf("%d",&num); if(num<0||num>38) continue; if(num==0) exit(0); i=j=0; sumf=1; for(k=0;k<(num-1);k++) {i=j; j=sumf; sumf=i+j; } n=1; while((n*(n+1)/2)

Related Documents

Reverse Gear Finals
November 2019 16
Reverse Gear
October 2019 12
Reverse Gear Prelims
November 2019 8
Gear
December 2019 32
Finals
December 2019 35
Finals
November 2019 35

More Documents from ""

New Microsoft Word Document
November 2019 18
Reverse Gear Finals
November 2019 16
Accounting Studies
April 2020 13
Computer Hardware
April 2020 13