Showing posts with label Basic programming exercises and solutions in C. Show all posts
Showing posts with label Basic programming exercises and solutions in C. Show all posts

Sunday, October 27, 2019



Programing problem : Toph-EasyProblems-Missing number






Solution : Code in C  language 

#include<stdio.h> int main() { int a,b,c,d,e,f; scanf("%d",&a); scanf("%d %d %d",&b,&c,&d); e=b+c+d; f=a-e; printf("%d",f); return 0; }


Programing problem : Toph-Easyproblem-Pie Are Squared


Given the radius of a circle, calculate and print its area.
The area of a circle can be computed using the following formula:
A = \pi r^2
For pi, you can use 3.141592653589793, or acos(-1).

Input

The input will contain one floating point number r (r < 2000).

Output

Print the area of the circle (accurate to 10-4).


Solution : Code in  C  language 


#include<stdio.h> int main(){ int r; double pi=3.141592653589793,area; scanf("%d",&r); area=pi*r*r; printf("%f",area); return 0; }




Programing Problem : Copycut





solution : Code in C language 

#include<stdio.h> int main () { int a; scanf("%d",&a); printf("%d",a); return 0; }

Friday, October 4, 2019


প্রোগামিং সমস্যাঃ অধোগামী সংখ্যা

সমস্যার বিবরনঃ
এমন একটি প্রোগাম লিখতে হবে যেটি  থেকে  পর্যন্ত সবগুলো সংখ্যাকে বড় থেকে ছোট ক্রমানুসারে প্রিন্ট করতে হবে ।

ইনপুটঃ
প্রোগামটিতে কোন ইনপুট নেই ।

আউটপুটঃ
প্রতি লাইনে মোট পাচটি করে সংখ্যা থাকবে এবং প্রতিটি সংখ্যা একটি   ‘t’ দিয়ে আলাদা করতে হবে ।

Example :

Output
1000    999      998      997      996
995      994      993      992      991     
990      989      988      987      986     
985      984      983      982      981
……       …….      …….      ……       …….
……       …….      …….      ……..     ……..
35        34         33         32        31
30        29         28          27       26
25        24         23          22       21
20        19         18          17       16
15        14         13          12       11
10         9           8             7        6
5           4            3             2       1

সমাধানঃ
#include<stdio.h>

int main ()
{
    int i ;
    for(i=1000;i>= 1;i--)
    {
        printf("%d\t",i);
        i=i-1;
        printf("%d\t",i);
         i=i-1;
        printf("%d\t",i);
         i=i-1;
        printf("%d\t",i);
         i=i-1;
        printf("%d\n",i);

    }
    return 0;
}





Tuesday, September 24, 2019

C Programe : print odd numbers from 1 to 50



code

//  print odd numbers
#include <stdio.h>

int main() {
int i;
printf("odd numbers between 1 to 50 (inclusive):\n");
for (i = 1; i <= 50; i++)
{
if(i%2 == 1)
{
  printf("%d ", i);
}
}
return 0;
}


sample output : 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2 , 29, 31, 33, 35, 37, 39, 41, 43 ,                                         45,47,49  

C programe :  print even numbers from 1 to 50

pictorial presentation : 
                                      




code : 
//  print even numbers
#include <stdio.h>

int main() {
int i;
printf("Even numbers between 1 to 50 (inclusive):\n");
for (i = 1; i <= 50; i++)
{
if(i%2 == 0)
{
  printf("%d ", i);
}
}
return 0;
}

sample output : 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50


//take input 5 numbers and sum of all even number between them

C program : Take 5 numbes input and sum of all between number between them

#include <stdio.h>
int main() {
    int total=0;
int i, numbers[5];
printf("input the first number\n: ");
    scanf("%d", &numbers[0]);
    printf("input the second number\n: ");
    scanf("%d", &numbers[1]);
    printf("input the third number\n: ");
    scanf("%d", &numbers[2]);
printf("input the fourth number\n: ");
    scanf("%d", &numbers[3]);
    printf("input the fifth number\n: ");
    scanf("%d", &numbers[4]);
for(i = 0; i < 5; i++) {
if((numbers[i]%2) != 1)
{
   total += numbers[i];
}
    }
    printf("Sum of all even values: %d", total);
return 0;
}


Monday, September 23, 2019

"সি"তে সর্বোচ্চ সংখ্যা নির্ণয় করার জন্য প্রোগাম 

// find out the maximum value 
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a, b, c, result, max;
    printf("\nInput the first integer: ");
    scanf("%d", &a);
    printf("\nInput the second integer: ");
    scanf("%d", &b);
    printf("\nInput the third integer: ");
    scanf("%d", &c);
    result=(a+b+abs(a-b))/2;
    max=(result+c+abs(result-c))/2;
    printf("\nMaximum value of  integer: %d", max);
printf("\n");
    return 0;
}


Categories

About Me

My photo
I am Md Fakhrul Islam. I am a student of EEE of Daffodil International University I am expert in SEO and Graphic designing.

Contact Form

Name

Email *

Message *

Popular Posts