C Programming
10 programs with Solution & Output
Rejaul Hoque Sarkar
Cont. No.- 9749189618 ; Email ID- srejaulhoque@gmail.com
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
1/ Write a C program to
print Hello World.
Solution :=:>
#include<stdio.h>
int main();
{
printf(“\n Hello
World”);
return 0;
}
Output :=:>
-------------------------
Hello World
-------------------------
2/ Write a C program to
print integer.
Solution :=:>
#include<stdio.h>
int main();
{
Int a;
printf(“\n Enter an Integer”);
scanf(“%d”, &a);
printf(“Integer that you have entered is %d \n”, a);
return 0;
}
Output :=:>
---------------------------
Integer that you have
entered is a
---------------------------
3/ Write a C program to add
two numbers.
Solution :=:>
#include<stdio.h>
int main();
{
int
a, b, c;
printf(“\n
Enter two numbers to add : \n”);
scanf(“%d
%d”, &a, &b);
c =
a + b;
printf(“Sum
of entered numbers = %d \n”,c);
return
0;
}
Output :=:>
---------------------------------
Enter two numbers to add :
4 5
Sum of entered numbers : 9
---------------------------------
4/ Write a C program to
check whether odd or even.
Solution :=:>
#include<stdio.h>
#include<conio.h>
int main()
{
int
n;
printf(“\n Enter an
Integer : \n”);
scanf(“%d”,
&n);
if(n
& 1 == 1)
printf(“\n odd \n”);
else
printf(“\n even \n”);
return 0;
}
Output :=:>
-----------------------------------
Enter an Integer :
1
even
-----------------------------------
5/ Write a C program to
perform addition, subtraction, multiplication and division.
Solution :=:>
#include<stdio.h>
#include<conio.h>
int main()
{
int first,
second, add, subtract, multiply;
float
divide;
printf(“\n
Enter two integers : \n”);
scanf(“%d
%d”, &first, &second);
add
= first + second;
subtract
= first – second;
multiply
= first * second;
divide
= first/(float)second;
printf(“sum
= %d \n”, add);
printf(“difference
= %d”, subtract);
printf(“multiplication
= %d”, multiply);
printf(“division
= %d”, divide);
return
0;
}
Output :=:>
-----------------------------------
Enter two integers : 7 3
sum = 10
difference = 4
multiplication = 21
division = 2.33
-----------------------------------
6/ Write a C program to
check vowel.
Solution :=:>
#include<stdio.h>
#include<conio.h>
int main()
{
char
ch;
printf(“Enter
a character : ”);
scanf(“%d”,
&ch);
if(ch==’a’
|| ch==’A’ || ch==’e’ || ch==’E’ || ch==’i’ || ch==’I’ || ch==’o’ || ch==’O’
|| ch==‘u’ || ch==’U’)
printf(“\n %c is a VOWEL”, ch);
else
printf(“%c Is not a VOWEL”, ch);
return 0;
}
Output :=:>
-----------------------------------
Enter a character : e
e is a vowel
-----------------------------------
7/ Write a C program to
check leap year.
Solution :=:>
#include<stdio,h>
#include<conio.h>
int main()
{
int year;
printf(“\n
Enter a year to check if it is a leap year:”);
scanf(“%d”,
&year);
if(year%400
== 0)
printf(“\n
%d is a leap year J”);
else
if(year%100 == 0)
printf(“\n
%d is not a leap year L ”);
else
if(year%4 == 0)
printf(“\n
%d is a leap year J”);
else
printf(“\n
%d is not a leap year L”);
retutn
0;
}
Output :=:>
-----------------------------------
Enter a year to check if it is a leap year:2012
2012 is a leap year
-----------------------------------
8/ Write a C program to add
digits of numbers.
Solution
:=:>
COMING SOON …
Output
:=:>
COMING SOON …
9/ Write a C program to
shutdown the window operating system.
Solution
:=:>
COMING SOON …
Output
:=:>
COMING SOON …
10/ Write a C program to jam
computer hard disk drive.
Solution
:=:>
COMING SOON …
Output
:=:>
COMING SOON …
_______________________________________________________________________
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Thank You,
Like us on Facebook : FB
Follow us on Twitter : TW
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
See Our Videos ==>> CLICK HERE
See Our Videos ==>> CLICK HERE
-----------------------------------------------------------------------------
See Our Videos ==>> CLICK HERE
See Our Videos ==>> CLICK HERE
-----------------------------------------------------------------------------
0 comments:
Post a Comment