Student
Name:
Shinde Sachin Dadarao. Roll No:149
Program
Name: Write a program to check given year is
leap or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int year;
clrscr();
printf("\n enter the value of
year-");
scanf("\n %d",&year);
if(year%4==0||year%400==0)
{
printf("\n given year is
leap");
}
else
{
printf("\n given number is not
leap");
}
getch();
}
/*
output
Enter the value of year-2012
Given year is leap
Enter the value of year-2013
Given year is not leap */
Student Name: Shinde Sachin
Dadarao. Roll
No:149
Program Name: Wap to check
given number is positive or negative if positive then check it is odd or even.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
num;
clrscr();
printf("\n
enter the number");
scanf("\n
%d",&num);
if(num>0)
{
if(num%2==0)
{
printf("\n number is positive and
even");
}
else
{
printf("\n number is positive and
odd");
}
}
else
{
printf("\n
number is negative");
}
getch();
}
/* output
Enter the number-10
Number is positive and even
Enter the number-15
Number is positive and odd
Enter the number- -1
Number is negative */
Student
name:
Shinde Sachin Dadarao. Roll No:149
Program
Name: Wap to check given character is
uppercase, lowercase or digit.
#include<stdio.h>
#include<conio.h>
void
main()
{
char
ch;
clrscr();
printf("\n
enter the character");
scanf("\n
%c",&ch);
if(ch>=65
&& ch<=97)
{
printf("\n character is
uppercase");
}
if(ch>=97
&& ch<=122)
{
printf("\n character is
lowercase");
}
if(ch>=48
&& ch<=57)
{
printf("\n character is digit");
}
getch();
}
/* output
Enter the character-S
Character is uppercase
Enter the character-p
Character is lowercase
Enter the character-48
Character is digit */
Student
Name:
Shinde Sachin Dadarao. Roll No:149
Program
Name: Write a program to convert given uppercase character
into lowercase and
Vice-versa
#include<stdio.h>
#include<conio.h>
void
main()
{
char
ch,ans;
clrscr();
printf("\n
enter the character");
scanf("\n
%c",&ch);
if(ch>=65
&& ch<=90)
{
ans=ch+32;
printf("\n lowercase character is
%c",ans);
}
if(ch>=97 && ch<=122)
{
ans=ch-32;
printf("\n uppercase character is
%c",ans);
}
getch();
}
/* output
Enter the character-s
Uppercase character is S
Enter the character-P
Lowercase character is p */
Student
Name:
Shinde Sachin Dadarao. Roll No:149
Program
name: Write a program to check given character
is vowel or not.
#include<stdio.h>
#include<conio.h>
void
main()
{
char
ch;
clrscr();
printf("\n
enter the character-");
scanf("\n
%c",&ch);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
printf("\n
given character is vowel");
}
else
{
printf("\n
given character is not vowel");
}
getch();
}
/*
output
Enter
the character-a
Given character is vowel
Enter the character-s
Given character is not vowel */
Student
Name:
Shinde Sachin Dadarao. Roll
No:149
Program
name: w
a p to add,sub,multiply and division of two number using switch
#include<stdio.h>
#include<conio.h>
void
main()
{
int
a,b,c,ch;
clrscr();
printf("\n1.Addition\n\n2.Substraction\n\n3.Multiplication\n\n4.Division");
printf("\n\n
Enter your choice-");
scanf("%d",&ch);
printf("\n
enter the value of a-");
scanf("\n
%d",&a);
printf("\n
enter the value of b-");
scanf("\n
%d",&b);
switch(ch)
{
case 1:
c=a+b;
printf("\n the
addition is %d",c);
break;
case 2:
c=a-b;
printf("\n the
substraction is %d",c);
break;
case 3:
c=a*b;
printf("\n the
multiplication is %d",c);
break;
case 4:
c=a/b;
printf("\n the
division is %d",c);
break;
default:
printf("\n your
option is wrong");
break;
}
getch();
}
/*
Output
1. Addition
2. Subtraction
3.
Multiplication
4. Division
Enter your choice-3
Enter the value of a-12
Enter the value of b-4
The multiplication is 48 */
Student
Name:
Shinde Sachin Dadarao. Roll No:149
Program
name: Write a program to input an integer
number and display its sum of digits.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
num,rem,sum=0;
clrscr();
printf("\n
enter the number");
scanf("\n
%d",&num);
while(num>0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
printf("\n
sum is %d",sum);
getch();
}
/* output
Enter the number-165
Sum is 12
*/
Student
Name:
Shinde Sachin Dadarao. Roll
No:149
Program
name: Write a program to input an integer
number and check whether it is Armstrong or not.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
num,temp,rem,sum=0;
clrscr();
printf("\n
enter the number");
scanf("\n
%d",&num);
temp=num;
while(num>0)
{
rem=num%10;
sum=sum+(rem*rem*rem);
num=num/10;
}
if(temp==sum)
{
printf("\n number is armstrong");
}
else
{
printf("\n number is not
armstrong");
}
getch();
}
/* output
Enter the number-370
Number is Armstrong
Enter the number-122
Number is not Armstrong */
Student Name: Shinde Sachin Dadarao. Roll
No:149
Program
name:Write
a program to input an integer number and check whether it is palindrome or not.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
num,temp,rem,sum=0;
clrscr();
printf("\n
enter the number-");
scanf("\n
%d",&num);
temp=num;
while(num>0)
{
rem=num%10;
sum=rem+(sum*10);
num=num/10;
}
if(temp==sum)
{
printf("\n number is palindrome");
}
else
{
printf("\n number is not
palindrome");
}
getch();
}
/* output
Enter the number-121
Number is palindrome
Enter the number-153
Number is not palindrome */
Student
Name: Shinde
Sachin Dadarao. Roll
No:149
Program
Name: Write a program to input an integer
number and check whether it is
perfect or not.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
num,i,sum=0;
clrscr();
printf("\n
enter the number-");
scanf("\n
%d",&num);
for(i=1;i<num;i++)
{
if(num%i==0)
{
sum=sum+i;
}
}
if(num==sum)
{
printf("\n number is perfect");
}
else
{
printf("\n number is not perfect");
}
getch();
}
/* output
Enter the number-6
Number is perfect
Enter the number-48
Number is not perfect */
Student
Name:
Shinde Sachin Dadarao. Roll No:149
Program
Name: Write a program to input an integer
number and find its factorial.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
num,fact=1, i ;
clrscr();
printf("\n
enter the number-");
scanf("\n
%d",&num);
for(i=1;i<=num;i++)
{
fact=fact*i;
}
printf("\n
factorial is %d",fact);
getch();
}
/* output
Enter the number-7
Factorial is 5040 */
Student
Name:
Shinde Sachin Dadarao. Roll No:149
Program
Name:write
a program to display fibonacci series.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
n,i,a=0,b=1,c;
clrscr();
printf("\n
enter how any terms u wants-");
scanf("\n
%d", &n);
printf("\n
initialize value of a is %d",a);
printf("\n
initialize value of b is %d",b);
for(i=1;i<=5;i++)
{
c=a+b;
printf("\n %d",c);
a=b;
b=c;
}
getch();
}
/*
Output
Enter how any
terms u wants-5
Initialize value
of a is 0
Initialize
value of b is 1
1
2
3
5
8 */
Student
Name:
Shinde Sachin Dadarao. Roll No:149
Program
name: Write a program to print following
pattern
1
2 3
4 5 6
7 8
9 10.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
i,j,temp=1;
clrscr();
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
printf(" %d",temp);
temp=temp+1;
}
printf("\n");
}
getch();
}
/* output
1
2 3
4 5 6
7 8 9 10 */
Student
Name:
Shinde Sachin Dadarao. Roll
No:149
Program
name:
Write a program to following pattern
a
b c
d e
f
#include<stdio.h>
#include<conio.h>
void main()
{
char temp=97;
int i,j;
clrscr();
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
printf(" %c",temp);
temp++;
}
printf("\n");
}
getch();
}
/*
Output
a
b c
d e f */