1. Write a program in C to check whether given number is even or odd
number?
2. Write a program in C to check whether given number is
postive,negative or zero?
3. Write a program in C to check whether given year is leap or not?
4. Write a program in C to check whether upper, lower, number or
not?
5. Write a program in C to convert upper to lower case letters?
6. Write a program in C to convert lower to upper letters ?
7. Write a program in C to print a word form of given number between
0 to 9?
8. Write a program in C to print a word form of given number between
0 to 99?
9. Write a program in C to perform relational operations of two integer
numbers?
10. Write a program in C to perform relational operations of two float
numbers?
11. Write a program in C to print the grade of given mark ?
12. Write a program in C to find out biggest of two numbers?
click here for Answer!!!
Answer:
/* program no : 1 */
/* purpose : check whether given number is even or odd number */
#include
int main()
{
int number;
scanf("%d", &number);
if ( number % 2 ==1)
printf("odd");
else
printf("even");
}
/* program no : 2 */
/* purpose : check whether given number is postive , negative or zero */
#include
int main()
{
int number;
scanf("%d", &number);
if ( number >0)
printf("postive");
else
{
if (number<0)
printf("negative");
else
printf("zero");
}
}
/* program no : 3 */
/* purpose : check whether given year is leap or not*/
#include
int main()
{
int year;
scanf("%d", &year);
if ( year % 4 ==0)
printf("leap year");
else
printf("not a leap");
}
/* program no : 4 */
/* purpose : check whether upper, lower, number or not */
#include
int main()
{
char any;
scanf("%c", &any);
if(any>='A' && any <='Z')
printf("upper case");
else
if(any>='a' && any <='z')
printf("lower case");
else
if(any>='0' && any <='9') printf("number");
else
printf("not ");
}
/* program no : 5 */
/* purpose : convert upper to lower case letters */
#include
int main()
{
char any;
scanf("%c", &any);
if(any>='A' && any <='Z')
printf("%c",any+32);
else
printf("%c",any);
}
/* program no : 6 */
/* purpose : convert lower to upper letters */
#include
int main()
{
char any;
scanf("%c", &any);
if(any>='a' && any <='z')
printf("%c",any-32);
else
printf("%c",any);
}
/* program no : 7 */
/* purpose : print a word form of given number between 0 to 9 */
#include
int main()
{
int number;
scanf("%d", &number);
if ( number==0)
printf("Zero");
else
if ( number==1)
printf("One");
else
if ( number==2)
printf("Two");
else
if ( number==3)
printf("Three");
else
if ( number==4)
printf("Four");
else
if ( number==5)
printf("Five");
else
if ( number==6)
printf("Six");
else
if ( number==7)
printf("Seven");
else
if ( number==8)
printf("eight");
else
if( number==9)
printf("Nine");
else
printf("others");
}
/* program no : 8 */
/* purpose : print a word form of given number between 0 to 99 */
#include
int main()
{
int number;
scanf("%d", &number);
if ( number==10)
printf("Ten");
else
if ( number==20)
printf("Twenty");
else
if ( number==30)
printf("Thirty");
else
if ( number==40)
printf("Fourty");
else
if ( number==50)
printf("Fifty");
else
if ( number==60)
printf("Sixty");
else
if ( number==70)
printf("Seventy");
else
if ( number==80)
printf("eighty");
else
if( number==90)
printf("Ninty");
else
printf("others");
}
/* program no : 9 */
/* purpose : relational operations of two integer numbers */
#include
int main()
{
int one, two;
scanf("%d%d",&one ,&two);
if ( one==two)
printf("first is equal to second");
else
{
if ( one > two)
printf("first is greater than second");
else
printf("first is less than second");
}
}
/* program no : 10*/
/* purpose : relational operations of two float numbers */
#include
int main()
{
float one, two;
scanf("%f%f",&one ,&two);
if ( one==two)
printf("first is equal to second");
else
{
if ( one > two)
printf("first is greater than second");
else
printf("first is less than second");
}
}
/* program no : 11 */
/* purpose : print the grade of given mark */
#include
int main()
{
int mark;
scanf("%d",&mark);
if ( mark>=80)
printf("distinction");
else
if ( mark>=60)
printf("first class");
else
if( mark>=50)
printf("second class");
else
if(mark>=40)
printf("third class");
else
printf("fail");
}
/* program no : 12 */
/* purpose : biggest of two numbers */
#include
int main()
{
int one,two;
scanf("%d%d",&one,&two);
if ( one>two)
printf("%d",one);
else
printf("%d",two);
}
No comments:
Post a Comment