20 nickels in a dollar
#include <stdio.h> #include<string.h> main() { char s[80]; int d; clrscr(); printf("enter the month of your birthday: "); gets(s); if(!(strcmp(s, "january"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=19) printf("\n CAPRICORN"); else printf("\n AQUARIUS"); } if(!(strcmp(s, "february"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=18) printf("\n AQUARIUS"); else printf("\n PISCES"); } if(!(strcmp(s, "march"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=20) printf("\n PISCES"); else printf("\n ARIES"); } if(!(strcmp(s, "april"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=19) printf("\n ARIES"); else printf("\n TAURUS"); } if(!(strcmp(s, "may"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=20) printf("\n TAURUS"); else printf("\n GEMINI"); } if(!(strcmp(s, "june"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=20) printf("\n GEMINI"); else printf("\n CANCER"); } if(!(strcmp(s, "july"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=22) printf("\n CANCER"); else printf("\n LEO"); } if(!(strcmp(s, "august"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=22) printf("\n LEO"); else printf("\n VIRGO"); } if(!(strcmp(s, "september"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=22) printf("\n VIRGO"); else printf("\n LIBRA"); } if(!(strcmp(s, "october"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=22) printf("\n LIBRA"); else printf("\n SCORPIO"); } if(!(strcmp(s, "november"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=21) printf("\n SCORPIO"); else printf("\n SAGITTARIUS"); } if(!(strcmp(s, "december"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=21) printf("\n SAGITTARIUS"); else printf("\n CAPRICORN"); } getch(); }
#include<stdio.h> int main() { int a[20],min,max; int n; printf("\nEnter the num of elements: "); scanf("%d",&n); printf("Enter the elements\n"); for(int i=0;i<n;i++) { scanf("%d",&a[i]); if(i==0) { min=max=a[i]; } if(a[i]<min) min=a[i]; else if(a[i]>max) max=a[i]; } printf("The largest element is %d. The smallest element is %d.", max, min); }
int maxprod (int n) { return n/2; } int main (void) { int n, a, b; n= 7; /* for example */ a= maxprod (n); b= n-a; printf ("%d+%d=%d, %d*%d=%d\n", a, b, a+b, a, b, a*b); }
# include # include void main(){int a[20], i, n ;clrscr() ;printf("Enter the limit : ") ;scanf("%d", &n) ;printf("Enter the elements") ;for(i = 0 ; i < =n ; i++)scanf("%d", &a[i]) ;printf("The positive elements are") ;printf("the negative elements are);for(i = 0 ; i < n ; i++){if(a[i] > 0)printf("%d", a[i]) ;if(a[i]
20 numbers on a dartboard
20 nickels in a dollar
There are 22 ways to make change from a dollar using nickels, dimes, and quarters. 1. 4 q 2. 10 d 3. 20 n 4. 2 q , 5 d 5. 3 q , 2 d , 1 n 6. 1 q , 7 d, 1 n 7. 9 d, 2 n 8. 8 d, 4 n 9. 7 d, 6 n 10. 6 d , 8 n 11. 5 d , 10 n 12. 4 d , 12 n 13. 2 d , 16 n 14. 1 d , 18 n 15. 5 n , 3 q 16. 3 n , 1 q , 6 d 17. 7 n , 1 q , 4 d 18. 9 n , 1 q , 3 d 19. 11 n , 1 q , 2 d 20. 13 n , 1 q , 1 d 21. 14n , 3 d 22. 15n , 1 q
a (sub n) = 11 + (n - 1) x d
N-Y-P-D- - 1967 Cry Brute 1-20 was released on: USA: 6 February 1968
sum_ap = n(2a + (n-1)d)/2 → 2sum = n(2a + (n-1)d) → 2sum = 2an + dn² - dn → dn² +(2a - d)n - 2sum = 0 a = 3 (first term) d = 4 (common difference) sum = 820 → 4n² + (2×3 - 4)n - 2 × 820 = 0 → 4n² + 2n - 2 × 820 = 0 → 2n² + n - 820 = 0 → (2n + 41)(n - 20) = 0 As n must be positive, the (2n + 41) gives a negative value for n so cannot be a solution, leaving n - 20 = 0 → n = 20 There are 20 terms in the AP.
#include <stdio.h> #include<string.h> main() { char s[80]; int d; clrscr(); printf("enter the month of your birthday: "); gets(s); if(!(strcmp(s, "january"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=19) printf("\n CAPRICORN"); else printf("\n AQUARIUS"); } if(!(strcmp(s, "february"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=18) printf("\n AQUARIUS"); else printf("\n PISCES"); } if(!(strcmp(s, "march"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=20) printf("\n PISCES"); else printf("\n ARIES"); } if(!(strcmp(s, "april"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=19) printf("\n ARIES"); else printf("\n TAURUS"); } if(!(strcmp(s, "may"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=20) printf("\n TAURUS"); else printf("\n GEMINI"); } if(!(strcmp(s, "june"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=20) printf("\n GEMINI"); else printf("\n CANCER"); } if(!(strcmp(s, "july"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=22) printf("\n CANCER"); else printf("\n LEO"); } if(!(strcmp(s, "august"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=22) printf("\n LEO"); else printf("\n VIRGO"); } if(!(strcmp(s, "september"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=22) printf("\n VIRGO"); else printf("\n LIBRA"); } if(!(strcmp(s, "october"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=22) printf("\n LIBRA"); else printf("\n SCORPIO"); } if(!(strcmp(s, "november"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=21) printf("\n SCORPIO"); else printf("\n SAGITTARIUS"); } if(!(strcmp(s, "december"))) { printf("\n enter the date of your birthday: "); scanf("%i", &d); if(d<=21) printf("\n SAGITTARIUS"); else printf("\n CAPRICORN"); } getch(); }
#include<stdio.h> #include<conio.h> int a[20][20],q[20],visited[20],n,i,j,f=0,r=-1; void bfs(int v) { for(i=1;i<=n;i++) if(a[v][i] && !visited[i]) q[++r]=i; if(f<=r) { visited[q[f]]=1; bfs(q[f++]); } } void main() { int v; printf("\n Enter the number of vertices:"); scanf("%d",&n); for(i=1;i<=n;i++) { q[i]=0; visited[i]=0; } printf("\n Enter graph data in matrix form:\n"); for(i=1;i<=n;i++) for(j=1;j<=n;j++) scanf("%d",&a[i][j]); printf("\n Enter the starting vertex:"); scanf("%d",&v); bfs(v); printf("\n The node which are reachable are:\n"); for(i=1;i<=n;i++) if(visited[i]) printf("%d\t",i); else printf("\n Bfs is not possible"); getch(); }
1/2*(n2-3n) = number of diagonals 1/2*(202-60) = 170 diagonals
printf ("square of %d is %d\n", $n, $n*$n);
Suppose the number is n/d. Then n/d >= d => n <= d2 if d < 0 or n >= d2 if d > 0.
/* a number divisible by x should be a multiple of x */ int i, n,x; scanf ("%d", &n); scanf ("%d",&x); for(i=x;i =< n;i+=x) { printf ("%d", x); }