For this, you will need the Code Blocks Compiler.
Hello World! Welcome to the programming world. Today we will create a program using C to get the square root of the given number. So, let's start coding.
For this, you will need the Code Blocks Compiler.
1 Comment
Hello every one. Welcome to today's C programming project. Today we will create a program using C which will take input of two numbers, the given number and the power. So, let's move to coding.
Download the Code Blocks compiler setup from here Start Code Blocks and create a new project by clicking on "Create a New Project", Now select Files from left panel of the new Wizard, then give a name of your project and at last click on finish. Now a new project workspace will be created. Now type the below red color highlighted code in the blank page: /*This program has been created by quvi.weebly.com- Author Mehbubul Hasan AL- Quvi. All rights reserved to Red Cross, 2012. Date created and built on 31 December, 2012.*/ #include <math.h> #include <stdio.h> int main () { int number, i, result; printf ("Enter a number and its power (Separate by a space between them): "); scanf ("%d %d", &number, &i); result = pow (number, i); printf ("\n%d to the power %d equals to %d", number, i, result); return 0; } /*Sample created by Mehbubul Hasan AL- Quvi.*/ Now, go to the build menu and click on Compile current file.Hope you will find no error. Now again go to build menu and click on Run or press Ctrl+ F10. You will find the program working properly. You will see the following output when you execute the program: Enter a number and its power (Separate by a space between them): Now, if you enter 2 3 You will see this, 2 to the power 3 is 8. If you find any error or problem, please let me know them through your comments. Oh! I forgot to tell that you can run this program online here Happy coding!! Today we'll write a very fine and efficient program using c language to get the factorial of the given number. For this we'll use Code Blocks Compiler. Click the below link to get its setup file. Then install it. Download CodeBlocks Setup So, let's get started for coding. Start Codeblocks and Click on "Create a New Project" and then click on Files from the left Panel and select C/C++ Source File, then click OK. Now just copy and paste he below code: #include <stdio.h> int main() { int num, i=1, factorial=1; printf ("Enter a number: "); scanf ("%d", &num); for (i=1;i<=num;i++) { factorial = factorial*i; } printf ("\nThe factorial of %d is %d.",num,factorial); return 0; } Now click on Build and then click on Compile Current File.
Then again click on Build and click on Run. Now the program will run. It will work fine. Run it enter any number such as 5 and then Enter. It will show you 120 which is the factorial of 5. Happy Coding!!! Assalamu Alaikum. Hello world! Welcome to today's c programming project. Today we'll make a program using c to check whether the given number is prime or not. So, open Codeblocks and start a new project. Select Files >> C/C++ Source>>File name with path>>and then click ok. This way create a new c programming project workspace. Oh! I forgot to tell that if you do not have codeblocks or some other compilers for c, you can download CodeBlocks from the below link. Download CodeBlocks Now, just copy the below code and paste it in the codeblocks new project workspace.: /*This program has been created, build, presented by, Mehbubul Hasan AL- Quvi. http://www.rokzzquvi.weebly.com*/ #include <stdio.h> int main() { int num, i, z=0; printf ("Enter a number: "); scanf ("%d", &num); for (i=3; i<=num/2; i=i+2) { if (num%i==0) { z=1; } } if (num == 0) { printf ("\n%d is zero", num); } else if (num<2) { printf ("\n%d is not a prime number.", num); } else if (num==2) { printf ("\n%d is a prime number.", num); } else if (num%2 == 0) { printf ("\n%d is not a prime number.", num); } else if (z==0 && num!=1) { printf ("\n%d is a prime number.", num); } else { printf ("\n%d is not a prime number.", num); } return 0; } /*Sample of Mehbubul Hasan AL- Quvi. All rights reserved to Red Cross*/ /*http://www.rokzzquvi.weebly.com*/ Now, click on Build, then click compile current file. Now, again click on Build and then run.
The program will run and it must work fine without any errors. However, if you find any bug or errors, please let me know that through your comments. |
AuthorHi, welcome to my site. My name is Mehbubul Hasan AL- Quvi and I'm a blogger as well as a freelancer. I'm a student of RAJUK UTTARA MODEL COLLEGE in Dhaka Bangladesh. ArchivesCategories
All
|