Posts

C Program To Add, Subtract, Multiply, Divide Two Numbers

♣ Try it Out :: #include<stdio.h> #include<conio.h> int main() { int num1, num2; printf("\nEnter two Integers: "); scanf("%d %d", &num1, &num2); int add = num1 + num2; int sub = num1 - num2; int mul = num1 * num2; float div = 1.0 * num1 / num2; printf("\nSum of two numbers: %d + %d = %d\n", num1, num2, add); printf("Difference of two numbers: %d - %d = %d\n", num1, num2, sub); printf("Multiplication of two numbers: %d * %d = %d\n", num1, num2, mul); printf("Division of two numbers: %d / %d = %.2f", num1, num2, div); getch(); return(0); } ♣ Output :: Enter two Integers: 8 7 Sum of two numbers: 8 + 7 = 15 Difference of two numbers: 8 - 7 = 1 Multiplication of two numbers: 8 * 7 = 56 Division of two numbers: 8 / 7 = 1.14 ♣ Downloads :: Download source code Download executable file

C Program To Divide Any Number By Another

♣ Try it Out :: #include<stdio.h> #include<conio.h> int main() { // code to divide any integer by another int a, b; printf("\nEnter two Integers: "); scanf("%d %d", &a, &b); float div1 = 1.0 * a / b; printf("Result1: %d / %d = %.2f\n", a, b, div1); // code to divide any floating number by another float c, d, div2; printf("\nEnter two Floating numbers: "); scanf("%f %f", &c, &d); div2 = c / d; printf("Result2: %.2f / %.2f = %.2f\n", c, d, div2); getch(); return(0); } ♣ Output :: Enter two Integers: 5 6 Result1: 5 / 6 = 0.83 Enter two Floating numbers: 5.5 5 Result2: 5.50 / 5.00 = 1.10 ♣ Downloads :: Download source code Download executable file

C Program To Multiply Two Numbers

♣ Try it Out :: #include<stdio.h> #include<conio.h> int main() { // code for multiplying integers int a, b, mul1; printf("\nEnter two Integers: "); scanf("%d %d", &a, &b); mul1 = a * b; printf("Result1: %d * %d = %d\n", a, b, mul1); // code for multiplying floating numbers float c, d, mul2; printf("\nEnter two Floating numbers: "); scanf("%f %f", &c, &d); mul2 = c * d; printf("Result2: %.2f * %.2f = %.2f\n", c, d, mul2); getch(); return(0); } ♣ Output :: Enter two Integers: 8 6 Result1: 8 * 6 = 48 Enter two Floating numbers: 5 5.5 Result2: 5.00 * 5.50 = 27.50 ♣ Downloads :: Download source code Download executable file

C Program To Subtract Two Numbers

♣ Try it Out :: #include<stdio.h> #include<conio.h> int main() { // code for integers int a, b, sub1; printf("\nEnter two Integers: "); scanf("%d %d", &a, &b); sub1 = a - b; printf("sub1 is: %d - %d = %d\n", a, b, sub1); // code for floating numbers float c, d, sub2; printf("\nEnter two Floating numbers: "); scanf("%f %f", &c, &d); sub2 = c - d; printf("sub2 is: %.2f - %.2f = %.2f\n", c, d, sub2); getch(); return(0); } ♣ Output :: Enter two Integers: 100 45 sub1 is: 100 - 45 = 55 Enter two Floating numbers: 12 5.3 sub2 is: 12.00 - 5.30 = 6.70 ♣ Downloads :: Download source code Download executable file

C Program To Add Two Numbers

♣ Try it Out :: #include<stdio.h> #include<conio.h> int main() { // code to add two integers int a, b, sum1; printf("\nEnter two Integers: "); scanf("%d %d", &a, &b); sum1 = a + b; printf("sum1 is: %d + %d = %d\n", a, b, sum1); // code to add two floating numbers float c, d, sum2; printf("\nEnter two Floating numbers: "); scanf("%f %f", &c, &d); sum2 = c + d; printf("sum2 is: %.2f + %.2f = %.2f\n", c, d, sum2); getch(); return(0); } ♣ Output :: Enter two Integers: 5 6 Sum1 is: 5 + 6 = 11 Enter two Floating numbers: 5 .5 Sum2 is: 5.00 + 0.50 = 5.50 ♣ Downloads :: Download source code Download executable file

C Program To Take Input From Users

♣ Try it Out :: #include<stdio.h> #include<conio.h> int main() { int num; printf("Enter an Integer: "); scanf("%d", &num); printf("You have entered: %d", num); getch(); return(0); } ♣ Output :: Enter an Integer: 569474 You have entered: 569474 ♣ Downloads :: Download source code Download executable file

C Program To Print On Screen

এই প্রোগ্রামটি আমার জীবনের প্রথম C প্রোগ্রাম। এটি কম্পিউটারের স্ক্রিনে 'Hello World!' প্রিন্ট করে। এই প্রোগ্রামের কোডে #include হচ্ছে একটি প্রি-প্রসেসর ডিরেক্টিভ। এটি সি কম্পাইলারকে ফাইল ইনক্লোড করার নির্দেশ দেয়। আর এক্ষেত্রে সিস্টেম ফাইল হচ্ছে stdio.h । কম্পাইলারটি জানে এটি একটি সিস্টম ফাইল, এটিকে < > (enclosed in) কারেক্টারের মধ্যে রাখতে হয়। এখানে <stdio.h> Standard Input Output হেডার ফাইলটি ব্যবহার করা হয়েছে printf() এবং scanf() ফাংশনের জন্য। printf() কম্পিউটারের স্ক্রিনে আউটপুট প্রদান করে। আর এক্ষেত্রে main() হচ্ছে একটি স্পেশাল ফাংশন। যখনই প্রোগ্রামটি ব্যবহার করা হয় এই main() ফাংশনটি প্রথমেই রান করে। প্রত্যেকটি ফাংশন শুরু করতে হয় { ব্রাকেটের মাধ্যমে এবং শেষ করতে হয় } ব্রাকেটের মাধ্যমে। এবং আমাদের প্রয়োজনীয় সকল কোড এই { } (brace) -এর ভিতরেই লিখতে হয়। \n (New line) কার্সরকে পরবর্তী লাইনের প্রথমে স্থাপন করে। নিচের প্রোগ্রামটি দেখলে ধারণা আরও ক্লিয়ার হবে, ইনশাআল্লাহ। ♣ Try it Out :: #include<stdio.h> int main() { printf(...