Professional Documents
Culture Documents
By
2
About Me……………
__ ___________________________
Student of CSE
3
Table of Contents
1. Dedication ……………………………………………………………… 7
2. Introduction…………………………………………………………… 8
4
16. C program to reverse a number ……………………………………23
5
35. C program remove spaces, blanks from a string ………… . .50
6
Dedication
Dennis Ritchie
7
Introduction
8
Any comments or Suggestions are welcome
Facebook: www.facebook.com/Noor016
Website: www.onlinejogot.tk
Email: noor.bd92@gmail.com
Cell: 01672902634
9
Problems & Solutions
C programming code
#include<stdio.h>
int main()
{
printf("Hello world\n");
return 0;
}
10
C program to add two numbers: This c language program perform the basic arithmetic
operation of addition on two numbers and then prints the sum on the screen. For example if
the user entered two numbers as 5, 6 then 11 ( 5 + 6 ) will be printed on the screen.
C programming code
#include<stdio.h>
int main()
{
int a, b, c;
c = a + b;
return 0;
}
C programming code
#include<stdio.h>
int main()
{
int a;
printf("Enter an integer\n");
scanf("%d", &a);
return 0;
}
11
c program to check odd or even: We will determine whether a number is odd or even by using
different methods all are provided with a code in c language. As you have study in
mathematics that in decimal number system even numbers are divisible by 2 while odd are
not so we may use modulus operator(%) which returns remainder, For example 4%3 gives 1 (
remainder when four is divided by three). Even numbers are of the form 2*p and odd are of
the form (2*p+1) where p is is an integer.
We can use bitwise AND (&) operator to check odd or even, as an example consider binary of 7
(0111) when we perform 7 & 1 the result will be one and you may observe that the least
significant bit of every odd number is 1, so ( odd_number & 1 ) will be one always and also (
even_number & 1 ) is zero.
In c programming language when we divide two integers we get an integer result, For
example the result of 7/3 will be 2.So we can take advantage of this and may use it to find
whether the number is odd or even. Consider an integer n we can first divide by 2 and then
multiply it by 2 if the result is the original number then the number is even otherwise the
number is odd. For example 11/2 = 5, 5*2 = 10 ( which is not equal to eleven), now consider
12/2 = 6 and 6 *2 = 12 ( same as original number). These are some logic which may help
you in finding if a number is odd or not.
int main()
{
int n;
printf("Enter an integer\n");
scanf("%d",&n);
if ( n%2 == 0 )
printf("Even\n");
else
printf("Odd\n");
return 0;
}
int main()
{
int n;
printf("Enter an integer\n");
12
scanf("%d",&n);
if ( n & 1 == 1 )
printf("Odd\n");
else
printf("Even\n");
return 0;
}
int main()
{
int n;
printf("Enter an integer\n");
scanf("%d",&n);
if ( (n/2)*2 == n )
printf("Even\n");
else
printf("Odd\n");
return 0;
}
int main()
{
int n;
printf("Enter an integer\n");
scanf("%d",&n);
return 0;
}
13
C program to perform basic arithmetic operations i.e. addition , subtraction, multiplication
and division of two numbers. Numbers are assumed to be integers and will be entered by the
user.
C programming code
#include <stdio.h>
int main()
{
int first, second, add, subtract, multiply;
float divide;
printf("Sum = %d\n",add);
printf("Difference = %d\n",subtract);
printf("Multiplication = %d\n",multiply);
printf("Division = %.2f\n",divide);
return 0;
}
C programming code
#include<stdio.h>
int main()
{
char ch;
printf("Enter a character\n");
scanf("%c",&ch);
14
else
printf("%c is not a vowel.\n", ch);
return 0;
}
Output:
int main()
{
char ch;
printf("Enter a character\n");
scanf("%c",&ch);
switch(ch)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
printf("%c is a vowel.\n", ch);
break;
default:
printf("%c is not a vowel.\n", ch);
}
return 0;
}
15
C program to check leap year
C program to check leap year: c code to check leap year, year will be entered by the user.
C programming code
#include <stdio.h>
int main()
{
int year;
if ( year%400 == 0)
printf("%d is a leap year.\n", year);
else if ( year%100 == 0)
printf("%d is not a leap year.\n", year);
else if ( year%4 == 0 )
printf("%d is a leap year.\n", year);
else
printf("%d is not a leap year.\n", year);
return 0;
}
C programming code
#include<stdio.h>
int main()
{
int n, sum = 0, remainder;
printf("Enter an integer\n");
scanf("%d",&n);
while( n != 0 )
{
remainder = n % 10;
16
sum = sum + remainder;
n = n / 10;
}
return 0;
}
Factorial program in c
Factorial program in c: c code to find and print factorial of a number, three methods are
given, first one uses a for loop, second uses a function to find factorial and third using
recursion. Factorial is represented using !, so five factorial will be written as 5!, n factorial as
n!. Also
n! = n*(n-1)*(n-2)*(n-3)...3.2.1 and zero factorial is defined as one i.e. 0!=1.
#include<stdio.h>
#include<conio.h>
int main()
{
int c, n, fact = 1;
printf("Factorial of %d = %d\n",n,fact);
getch();
return 0;
}
17
number by 31, 30, 29, ..., 1, 0 bits using a loop and bitwise AND the number obtained with
1(one), if the result is 1 then that bit is 1 otherwise it is 0(zero).
C programming code
#include <stdio.h>
int main()
{
int n, c, k;
if ( k & 1 )
printf("1");
else
printf("0");
}
printf("\n");
return 0;
}
Above code only prints binary of integer, but we may wish to perform operations on binary so
in the code below we are storing the binary in a string. We create a function which returns a
pointer to string which is the binary of the number passed as argument to the function.
char *decimal_to_binary(int);
int main()
{
int n, c, k;
char *pointer;
pointer = decimal_to_binary(n);
printf("Binary string of %d is: %s\n", n, t);
18
free(pointer);
return 0;
}
char *decimal_to_binary(int n)
{
int c, d, count;
char *pointer;
count = 0;
pointer = (char*)malloc(32+1);
if ( pointer == NULL )
exit(EXIT_FAILURE);
if ( d & 1 )
*(pointer+count) = 1 + '0';
else
*(pointer+count) = 0 + '0';
count++;
}
*(pointer+count) = '\0';
return pointer;
}
long factorial(int);
long find_ncr(int, int);
long find_npr(int, int);
int main()
{
int n, r;
long ncr, npr;
19
printf("Enter the value of n and r\n");
scanf("%d%d",&n,&r);
return 0;
}
result = factorial(n)/(factorial(r)*factorial(n-r));
return result;
}
result = factorial(n)/factorial(n-r);
return result;
}
long factorial(int n)
{
int c;
long result = 1;
return ( result );
}
C programming code
#include <stdio.h>
int main()
{
int n, sum = 0, c, value;
printf("Enter %d integers\n",n);
20
for ( c = 1 ; c <= n ; c++ )
{
scanf("%d",&value);
sum = sum + value;
}
return 0;
}
int main()
{
int x, y, temp;
temp = x;
x = y;
y = temp;
getch();
return 0;
}
21
You can also swap two numbers without using temp or temporary or third variable. In that
case c program will be as shown :-
#include<stdio.h>
int main()
{
int a, b;
a = a + b;
b = a - b;
a = a - b;
To understand above logic simply choose a as 7 and b as 9 and then do what is written in
program. You can choose any other combination of numbers as well. Sometimes it's a good
way to understand a program.
int main()
{
int x, y, *a, *b, temp;
a = &x;
b = &y;
temp = *b;
*b = *a;
*a = temp;
return 0;
}
22
#include<stdio.h>
int main()
{
int x, y;
swap(&x, &y);
return 0;
}
temp = *b;
*b = *a;
*a = temp;
}
C programming code
#include<stdio.h>
int main()
{
int n, reverse = 0;
while( n != 0 )
{
reverse = reverse * 10;
reverse = reverse + n%10;
23
n = n/10;
}
return 0;
}
Palindrome Numbers
Palindrome number in c: A palindrome number is a number such that if we reverse it, it will
not change. For example some palindrome numbers examples are 121, 212, 12321, -454. To
check whether a number is palindrome or not first we reverse it and then compare the number
obtained with the original, if both are same then number is palindrome otherwise not. C
program for palindrome number is given below.
int main()
{
int n, reverse = 0, temp;
temp = n;
while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}
if ( n == reverse )
printf("%d is a palindrome number.\n", n);
else
24
printf("%d is not a palindrome number.\n", n);
return 0;
}
*
***
*****
*******
*********
We have shown five rows above, in the program you will be asked to enter the numbers of rows
you want to print in the pyramid of stars.
C programming code
#include<stdio.h>
int main()
{
int row, c, n, temp;
printf("Enter the number of rows in pyramid of stars you wish to see ");
scanf("%d",&n);
temp = n;
temp--;
printf("\n");
25
}
return 0;
}
*
***
*****
***
*
C programming code
#include<stdio.h>
int main()
{
int n, c, k, space = 1;
space = n - 1;
space--;
printf("\n");
space = 1;
space++;
26
for ( c = 1 ; c <= 2*(n-k)-1 ; c++ )
printf("*");
printf("\n");
}
return 0;
}
int main()
{
int n, i = 3, count, c;
if ( n >= 1 )
{
printf("First %d prime numbers are :\n",n);
printf("2\n");
}
27
i++;
}
return 0;
}
There are many logic to check prime numbers, one given below is more efficient then above
method.
for ( c = 2 ; c <= (int)sqrt(n) ; c++ )
//only checking from 2 to square root of number is sufficient.
main()
{
int n, c = 2;
return 0;
}
int check_prime(int);
int main()
{
int n, result;
result = check_prime(n);
28
if ( result == 1 )
printf("%d is prime.\n", n);
else
printf("%d is not prime.\n", n);
return 0;
}
int check_prime(int a)
{
int c;
C code
#include<stdio.h>
#include<conio.h>
int main()
{
int number, sum = 0, temp, remainder;
printf("Enter a number\n");
scanf("%d",&number);
temp = number;
while( temp != 0 )
{
remainder = temp%10;
sum = sum + remainder*remainder*remainder;
temp = temp/10;
}
29
if ( number == sum )
printf("Entered number is an armstrong number.");
else
printf("Entered number is not an armstrong number.");
getch();
return 0;
}
C code
#include<stdio.h>
#include<conio.h>
int main()
{
int r;
long number = 0, c, sum = 0, temp;
printf("Enter the maximum range upto which you want to find armstrong
numbers ");
scanf("%ld",&number);
getch();
return 0;
30
}
Fibonacci series in c
Fibonacci series in c programming: c program for Fibonacci series without and with
recursion. Using the code below you can print as many number of terms of series as desired.
Numbers of Fibonacci sequence are known as Fibonacci numbers. First few numbers of series
are 0, 1, 1, 2, 3, 5, 8 etc, Except first two terms in sequence every other term is the sum of two
previous terms, For example 8 = 3 + 5 (addition of 3, 5). This sequence has many
applications in mathematics and Computer Science.
int main()
{
int n, first = 0, second = 1, next, c;
return 0;
}
31
int Fibonacci(int);
main()
{
int n, i = 0, c;
scanf("%d",&n);
printf("Fibonacci series\n");
return 0;
}
int Fibonacci(int n)
{
if ( n == 0 )
return 0;
else if ( n == 1 )
return 1;
else
return ( Fibonacci(n-1) + Fibonacci(n-2) );
}
C programming code
#include<stdio.h>
#include<conio.h>
int main()
{
int n, i, c, a = 1;
32
printf("Enter the number of rows of Floyd's triangle to print\n");
scanf("%d",&n);
getch();
return 0;
}
#include<stdio.h>
int main()
{
int n, c, k, space = 0;
char ch, temp;
scanf("%d", &n);
ch = 'A'+n-1;
temp = ch;
space++;
printf("\n");
ch--;
temp = ch;
}
33
return 0;
}
#include<stdio.h>
int main()
{
int c, n, k;
char ch = 'A';
printf("\n");
ch++;
}
return 0;
}
C programming code
#include <stdio.h>
int main()
{
34
int array[100], maximum, size, c, location = 1;
maximum = array[0];
C programming code
#include <stdio.h>
int main()
{
int array[100], minimum, size, c, location = 1;
minimum = array[0];
35
{
if ( array[c] < minimum )
{
minimum = array[c];
location = c+1;
}
}
C programming code
#include <stdio.h>
int main()
{
int array[100], position, c, n, value;
array[position-1] = value;
36
for( c = 0 ; c <= n ; c++ )
printf("%d\n", array[c]);
return 0;
}
c programming code
#include <stdio.h>
int main()
{
int array[100], position, c, n;
return 0;
}
37
c program to add two matrix
This c program add two matrices i.e. compute the sum of two matrices and then print it.
Firstly user will be asked to enter the order of matrix ( number of rows and columns ) and
then two matrices. For example if the user entered order as 2, 2 i.e. two rows and two columns
and matrices as
First Matrix :-
12
34
Second matrix :-
45
-1 5
then output of the program ( sum of First and Second matrix ) will be
57
29
C programming code
#include <stdio.h>
int main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10];
38
printf("\n");
}
return 0;
}
Subtract matrices
C code to subtract matrices of any order. This program finds difference between
corresponding elements of two matrices and then print the resultant matrix.
C code
#include<stdio.h>
#include<conio.h>
int main()
{
int m, n, c, d, first[10][10], second[10][10], difference[10][10];
printf("\n");
}
getch();
return 0;
39
}
C programming code
#include<stdio.h>
int main()
{
int m, n, c, d, matrix[10][10], transpose[10][10];
40
{
printf("%d\t",transpose[c][d]);
}
printf("\n");
}
return 0;
}
Matrix multiplication in c
Matrix multiplication in c language: c program to multiply matrices (two dimensional
array), this program multiplies two matrices which will be entered by the user. Firstly user
will enter the order of a matrix. If the entered orders of two matrix is such that they can't be
multiplied then an error message is displayed on the screen. You have already studied the
logic to multiply them in Mathematics. Matrices are frequently used while doing
programming and are used to represent graph data structure, in solving system of linear
equations and many more.
int main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[10][10], second[10][10], multiply[10][10];
if ( n != p )
printf("Matrices with entered orders can't be multiplied with each
other.\n");
else
{
printf("Enter the elements of second matrix\n");
41
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < q ; d++ )
{
for ( k = 0 ; k < p ; k++ )
{
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum;
sum = 0;
}
}
printf("\n");
}
}
return 0;
}
C programming code
#include <stdio.h>
int main()
{
char array[20] = "Hello World";
printf("%s\n",array);
return 0;
}
String length
42
This program prints length of string, for example consider the string "c programming" it's
length is 13. Null character is not counted when calculating string length. To find string
length we use strlen function of string.h.
int main()
{
char a[100];
int length;
length = strlen(a);
return 0;
}
void reverse(char*,int,int);
int main()
{
char a[100];
gets(a);
reverse(a, 0, strlen(a)-1);
printf("%s\n",a);
return 0;
}
43
c = *(x+beg);
*(x+beg) = *(x+end);
*(x+end) = c;
#include<stdio.h>
int string_length(char*);
void reverse(char*);
int main()
{
char string[100];
printf("Enter a string\n");
gets(string);
reverse(string);
return 0;
}
length = string_length(string);
begin = string;
end = string;
begin++;
end--;
}
44
}
return c;
}
int main()
{
char a[100], b[100];
strcpy(b,a);
strrev(b);
if( strcmp(a,b) == 0 )
printf("Entered string is a palindrome.\n");
else
printf("Entered string is not a palindrome.\n");
return 0;
}
45
Palindrome number in c
#include <stdio.h>
int main()
{
int n, reverse = 0, temp;
temp = n;
while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}
if ( n == reverse )
printf("%d is a palindrome number.\n", n);
else
printf("%d is not a palindrome number.\n", n);
return 0;
}
int main()
{
char text[100];
int begin, middle, end, length = 0;
gets(text);
end = length - 1;
middle = length/2;
46
{
printf("Not a palindrome.\n");
break;
}
end--;
}
if( begin == middle )
printf("Palindrome.\n");
return 0;
}
C programming code
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define TRUE 1
#define FALSE 0
int check_vowel(char);
int main()
{
char string[100], *temp, *pointer, ch, *start;
printf("Enter a string\n");
gets(string);
temp = string;
pointer = (char*)malloc(100);
start = pointer;
while(*temp)
{
47
ch = *temp;
if ( !check_vowel(ch) )
{
*pointer = ch;
pointer++;
}
temp++;
}
*pointer = '\0';
pointer = start;
strcpy(string, pointer); /* If you wish to convert original string */
free(pointer);
return 0;
}
int check_vowel(char a)
{
if ( a >= 'A' && a <= 'Z' )
a = a + 'a' - 'A';
return FALSE;
}
C substring code
#include<stdio.h>
#include<malloc.h>
int main()
{
char string[100], *pointer;
int position, length;
printf("Enter a string\n");
gets(string);
48
free(pointer);
return 0;
}
pointer = malloc(length+1);
*(pointer+c) = '\0';
return pointer;
}
int main()
{
char string[100], *pointer;
int position = 1, length = 1, temp, string_length;
printf("Enter a string\n");
gets(string);
49
printf("Substring of \"%s\" are\n", string);
return 0;
}
C programming code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void sort_string(char*);
int main()
{
char string[100];
sort_string(string);
printf("%s\n", string);
return 0;
}
50
length = strlen(s);
result = (char*)malloc(length+1);
pointer = s;
strcpy(s, result);
free(result);
}
"c programming"
there are two spaces in this string, so our program will print a string "c programming". It will
remove spaces when they occur more than one time consecutively in string anywhere.
C programming code
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SPACE ' '
int main()
{
char string[100], *blank, *start;
int length, c = 0, d = 0;
printf("Enter a string\n");
gets(string);
51
length = strlen(string);
blank = string;
start = (char*)malloc(length+1);
if ( start == NULL )
exit(EXIT_FAILURE);
while(*(blank+c))
{
if ( *(blank+c) == SPACE && *(blank+c+1) == SPACE )
{}
else
{
*(start+d) = *(blank+c);
d++;
}
c++;
}
*(start+d)='\0';
printf("%s\n", start);
free(start);
return 0;
}
strlwr, strupr in c
Here we will change string case with and without strlwr, strupr functions.
strlwr in c
#include<stdio.h>
#include<string.h>
int main()
{
char string[] = "Strlwr in C";
printf("%s\n",strlwr(string));
return 0;
}
strupr in c
#include<stdio.h>
52
#include<string.h>
int main()
{
char string[] = "strupr in c";
printf("%s\n",strupr(string));
return 0;
}
void upper_string(char*);
int main()
{
char string[100];
upper_string(string);
return 0;
}
void lower_string(char*);
int main()
{
char string[100];
53
gets(string);
lower_string(string);
return 0;
}
C programming code
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include<conio.h>
int main()
{
char first[100], second[100], *temp;
printf("\nBefore Swapping\n");
printf("First string: %s\n",first);
printf("Second string: %s\n\n",second);
temp = (char*)malloc(100);
strcpy(temp,first);
strcpy(first,second);
strcpy(second,temp);
54
printf("After Swapping\n");
printf("First string: %s\n",first);
printf("Second string: %s\n",second);
getch();
return 0;
}
C programming code
#include<stdio.h>
#include<string.h>
int main()
{
char string[100], ch;
int c = 0, count[26] = {0};
printf("Enter a string\n");
gets(string);
c++;
}
return 0;
}
55
Anagram in c
c program to check whether two strings are anagrams or not, string is assumed to consist of
alphabets only. Two words are said to be anagrams of each other if the letters from one word
can be rearranged to form the other word. From the above definition it is clear that two strings
are anagrams if all characters in both strings occur same number of times. For example "abc"
and "cab" are anagram strings, here every character 'a', 'b' and 'c' occur only one time in both
strings. Our algorithm tries to find how many times characters appears in the strings and
then comparing their corresponding counts.
int main()
{
char a[100], b[100];
int flag;
if ( flag == 1 )
printf("\"%s\" and \"%s\" are anagrams.\n", a, b);
else
printf("\"%s\" and \"%s\" are not anagrams.\n", a, b);
return 0;
}
c = 0;
56
{
second[b[c]-'a']++;
c++;
}
return 1;
}
C programming code
#include<stdio.h>
#include<conio.h>
#include<dos.h>
int main()
{
struct date d;
getdate(&d);
57
If you are using Turbo C Compiler then execute your file from folder. Press F9 to build your
executable file from source program. When you run from within the compiler by pressing
Ctrl+F9 it may not work.
int main()
{
char ch;
return 0;
}
int main()
{
char ch;
return 0;
}
source code
#include<stdio.h>
#include<conio.h>
58
int main()
{
int a=8;
int b=1;
while(b<=10){
printf("%d X %d = %d\n\n",a,b,a*b);
b=b+1;
}
getch();
return 0;
C program code
Even Numbers:
#include<stdio.h>
int main()
{
int n;
int sum=0;
int i=1;
printf("Please input your number\n");
scanf("%d",&n);
while(i<=n){
if(i%2==0){
printf("\t\t%d\n",i);
sum=sum+i;
}
i++;
}
printf("_________________________\n");
printf("sumation is = %d\n",sum);
return 0;
}
59
Odd Numbers:
#include<stdio.h>
int main()
{
int n;
int sum=0;
int i=1;
printf("Please input your number\n");
scanf("%d",&n);
while(i<=n){
if(i%2!=0){
printf("\t\t%d\n",i);
sum=sum+i;
}
i++;
}
printf("___________________________\n");
printf("sumation is = %d\n",sum);
getch();
return 0;
}
Project-1:Simple Calculator
This is a simple calculator project by me. It is use for two numbers
type this code & run in code blocks or other IDE
60
Code
#include<stdio.h>
#include<stdlib.h>
int clearScreen()
{
int s;
printf("If you want to Clear This screen plese input 5 or any number\n");
scanf("%d",&s);
if(s==5)
system("cls");
return 0;
}
int adding()
{
float x,y;
printf("Please Input Two Numbers\n");
printf("Your First Number :\n");
scanf("%f",&x);
printf("Your Second Number :\n");
scanf("%f",&y);
printf("Your Result is :%0.3f + %0.3f = %0.3f\n",x,y,x+y);
return 0;
}
int substruct()
{
float x,y;
printf("Please Input Two Numbers\n");
printf("Your First Number :\n");
scanf("%f",&x);
printf("Your Second Number :\n");
scanf("%f",&y);
printf("Your Result is :%0.3f - %0.3f = %0.3f\n",x,y,x-y);
return 0;
}
int multiply()
{
61
float x,y;
printf("Please Input Two Numbers\n");
printf("Your First Number :\n");
scanf("%f",&x);
printf("Your Second Number :\n");
scanf("%f",&y);
printf("Your Result is :%0.3f * %0.3f = %0.3f\n",x,y,x*y);
return 0;
}
int divide()
{
float x,y;
printf("Please Input Two Numbers\n");
printf("Your First Number :\n");
scanf("%f",&x);
printf("Your Second Number :\n");
scanf("%f",&y);
printf("Your Result is :%0.3f / %0.3f = %0.3f\n",x,y,x/y);
return 0;
}
int main()
{
double x,y;
int choice;
while(1)
62
case 2:
substruct();
break;
case 3:
multiply();
break;
case 4:
divide();
break;
case 5:
system("cls");
break;
case 0:
return 0;
break;
}
return 0;
Source Code
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d,e,f,result;
puts("\n\t\t\tWELCOME TO THE GUSSING GAME\n");
puts("\t\t\t!!!!Play Game & Surprise !!!!");
puts("\t\t|===============================================");
63
puts("\t\t===============================================|");
puts("**************************************************************
*********\n");
puts("\t\t\t****INSTRUCTION****\n**1.Je sonka golo type korte bola hobe ta
obossoi type korte hobe.\n**2.onno number type korle game ti wrong answer
dibe.\n");
puts("**************************************************************
*********\n");
puts("\n\t\t\t*****Start Game Enter 1 *****\n\n\t\t\t*****Exit Game Enter 2
*****");
scanf("%d",&f);
if(f==2){
return puts("\n\t\t\t\t**GOOD BYE**\n\n \t\t This Game is Created by
Noor Md. Anik\n");
else{
puts("\t\t****** YOUR GAME IS START NOW ********");
puts("\======================================================
=====");
printf("\n\n\tFriend, Tomi mone mone 1ti sonka doro & 10 type koro\n\n");
scanf("%d",&a);
printf("\n\tTomi je sonkati mone mone dorco take 2 dara gon koro & 20 type
koro\n\n");
scanf("%d",&b);
64
scanf("%d",&e);
result=(a+b+c+d+e)/10;
puts("=======================================================
========================");
printf("\n\n\t **** Tomar mone mone dora sonkati = %d ****\n\n ",result);
puts("\n\n\t ***** THANKS FOR PLAY THE GAME ******\n\n \tThis Game
is Created by Noor Md. Anik\n\n");
}
getch();
return 0;
This game project written by me. In this game I am use graphics or colour in code
blocks
Source Code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int a,b,c,result1,result2;
system("color 1a");
puts("\n\t\t\tWELCOME TO THE FRIENDsGUSSING GAME\n");
puts("\t\t\t!!!!Play Game & Surprise !!!!");
puts("\t\t|===============================================");
puts("\t\t===============================================|");
puts("**************************************************************
*********\n");
65
puts("\t\t\t****INSTRUCTION****\n**1.Mone mone tomake 2 ti sonka dorte
hobe.\n**2.Tarpor sonka 2 tir Jogfol & Bioyogfol input dite hobe.\n");
puts("**************************************************************
*********\n");
puts("\n\t\t\t*****Start Game Enter 1 *****\n\n\t\t\t*****Exit Game Enter 2
*****");
scanf("%d",&c);
if(c==2){
puts("\n\t\t\t\t**GOOD BYE**\n\n \t\t This Game is Created by Noor Md.
Anik\n");
getch();
return 0;
else{
puts("\t\t****** YOUR GAME IS START NOW ********");
puts("\======================================================
=====");
printf("\n\n\tFriend, Tomi mone mone 2 ti sonka doro & sonka 2 tir jogfol type
koro\n\n");
scanf("%d",&a);
printf("\n\tAkon sonka 2 tir bioyogfol type koro & Enter dao\n\n");
scanf("%d",&b);
result1=(a+b)/2;
result2=(a-b)/2;
puts("=======================================================
========================");
printf("\n\n\t **** Tomar mone mone dora 1st sonkati = %d****\n\n ",result1);
printf("\n\n\t **** Tomar mone mone dora 2nd sonkati = %d****\n\n
",result2);
66
puts("\n\n\t ***** THANKS FOR PLAY THE GAME ******\n\n \tThis Game
is Created by Noor Md. Anik\n\n");
}
getch();
return 0;
67
68