Nusrat_Ullah

Spring 2018 -- Number 4

Sep 3rd, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.60 KB | None | 0 0
  1. Spring 2018
  2. 4(c) number ta baade 4 er baki gula.
  3.  
  4. 4.a.
  5.  
  6. #include<stdio.h>
  7. int main()
  8. {
  9.     double a,b,c,x,y;
  10.     scanf("%lf %lf %lf",&a,&b,&c);
  11.     y=sqrt((b*b)-(4*a*c));
  12.     if(y>=0){
  13.         x=(-b+y)/2*a;
  14.         printf("X1 = %.2lf\n",x);
  15.         x=(-b-y)/2*a;
  16.         printf("X2 = %.2lf\n",x);
  17.     }
  18.     else{
  19.         printf("Impossible Calculation");
  20.     }
  21.     return 0;
  22. }
  23.  
  24.  
  25. 4.b.
  26.  
  27. #include<stdio.h>
  28. int main()
  29. {
  30.     int n,i,f=0;;
  31.     scanf("%d",&n);
  32.     for(i=2;i<(n/2);i++){
  33.         if(n%i==0){
  34.             f=1;
  35.             break;
  36.         }
  37.     }
  38.     if(f==1){
  39.         printf("Composite Number\n");
  40.     }
  41.     else{
  42.         printf("Not a Composite Number\n");
  43.     }
  44.     return 0;
  45. }
  46.  
  47.  
  48. 4.d.
  49.  
  50. #include<stdio.h>
  51. int main()
  52. {
  53.     int i,j,n;
  54.     scanf("%d",&n);
  55.     int source[n+3],destination[n+3];
  56.     for(i=0;i<n;i++){
  57.         scanf("%d",&source[i]);
  58.     }
  59.     for(i=0,j=n-1;i<n;i++,j--){
  60.         destination[j]=source[i];
  61.     }
  62.     printf("destination: ");
  63.     for(i=0;i<n;i++){
  64.         printf("%d ",destination[i]);
  65.     }
  66.     return 0;
  67. }
  68.  
  69.  
  70. 4.e.
  71.  
  72. #include<stdio.h>
  73. int main()
  74. {
  75.     char str[100];
  76.     int i,wo=0,w=0,s=0;
  77.     scanf("%[^\n]s",str);
  78.     for(i=0;str[i]!='\0';i++){
  79.         if(str[i]==' '||str[i]=='.'){
  80.             wo++;
  81.             if(str[i]=='.'&&str[i+1]==' '){
  82.                 w++;
  83.             }
  84.             if(str[i]=='.'){
  85.                 s++;
  86.             }
  87.         }
  88.     }
  89.     printf("Number of Words: %d\n",wo-w);
  90.     printf("Number of White Spaces: %d\n",wo-s);
  91.     printf("Number of Full Stops: %d\n",s);
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment