Beruflich Dokumente
Kultur Dokumente
} getch(); } 3. To check whether the given number is palindrome or not. 4. To check whether the given number is of one digited or two digited or three digited or more than three digited. #include<stdio.h> #include<conio.h> void main() { int num; clrscr(); printf("Enter the number >> "); scanf("%d",&num); if(num<10) { printf("\nIt is One digit number"); } else if(num<100) { printf("\nIt is Two digit number"); } else if(num<1000) { printf("\nIt is Three digit number"); } else if(num>1000) { printf("\nMore than three digit are there"); } getch(); } 5. To check whether the given number is a perfect square or not. 6. To check whether the given character is an uppercase letter or lowercase letter or a digit or a special character. #include<stdio.h> #include<conio.h>
void main() { int num; clrscr(); printf("Enter the number >> "); scanf("%d",&num); if(num>=48 & num<=57) { printf("\nIt is %c digit",num); } else if(num>=65 && num<=90) { printf("\nIt is Uppercase letter"); } else if(num>=97 && num<=122) { printf("\nIt is Lowercase Letter"); } else { printf("\nIt is Sepecial Symbol"); } getch(); } 7. To determine whether the given year is a leap year or not. #include<stdio.h> #include<conio.h> void main() { int yr; clrscr(); printf("Enter the year >> "); scanf("%d",&yr); if(yr%4==0) { printf("\nIt is Leap Year"); } else { printf("\nIt is not a Leap year"); }
getch(); } 8. To check whether the given number is divisible by 5 or not. #include<stdio.h> #include<conio.h> void main() { int num; clrscr(); printf("Enter the year >> "); scanf("%d",&num); if(yr%5==0) { printf("\nIt is divisible by 5"); } else { printf("\nIt is not Divisible by 5"); } getch(); } 9. To find maximum number out of given three numbers. 10. An electronic component vendor supplies three products: transistors, resistors and capacitors. The vendor gives a discount of 10% on orders for transistors is the order is for more than Rs. 1000. On orders of more than Rs. 100 for resistors, a discount of 5% is given, and a discount of 10% is given on orders for capacitors of value more than Rs. 500. Assume that the numeric codes 1, 2 and 3 are used for transistors, capacitors and resistors respectively. Write a program that reads the product code and the order amount and prints out the net amount that customer is required to pay after discount.
#include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); printf("\n****************************************************************** **************"); printf("\n\t\t\t\t\tTables"); printf("\n****************************************************************** **************\n"); for(i=1;i<=10;i++) { for(j=1;j<=10;j++) { printf("%d*%d=%d\t",j,i,j*i); } printf("\n"); } getch(); }
3. To read any five real numbers and print the average value.
#include<stdio.h> #include<conio.h> void main() { int i; float rl,avg,sum=0; clrscr(); for(i=1;i<=5;i++) { printf("Enter the Real number >> "); scanf("%f",&rl); sum=sum+rl; } avg=sum/5; printf("\nAverage of 5 real no is %.2f",avg); getch(); }
getch(); }
2.
22 333 4444
#include<stdio.h> #include<conio.h> void main() { int i,j; float avg; clrscr(); for(i=1;i<=5;i++) { for(j=1;j<=i;j++) { printf("%d",i); } printf("\n"); } getch(); } 3.
1 22 333 4444
#include<stdio.h> #include<conio.h> void main() { int i,j,k; clrscr(); for(i=1;i<=5;i++) { for(k=5;k>=i;k--) { printf(" "); } for(j=1;j<=i;j++)
4.
1 21 321 4321
#include<stdio.h> #include<conio.h> void main() { int i,j,k; clrscr(); for(i=1;i<=5;i++) { for(k=5;k>=i;k--) { printf(" "); } for(j=i;j>=1;j--) { printf("%d",j); } printf("\n"); } getch(); }
Write a program to do the following task: 1. To print ASCII value of all characters.
#include<stdio.h> #include<conio.h>
void main() { int str,stp,i; clrscr(); printf("Enter the start value >> "); scanf("%d",&str); printf("Enter the stop value >> "); scanf("%d",&stp); printf("\nAscii\tsymbol"); for(i=str;i<=stp;i++) { printf("\n%d\t%c",i,i); } getch(); }
{ int n,i,sr; clrscr(); printf("Enter the number >> "); scanf("%d",&n); printf("\n"); for(i=1;i<=n;i++) { sr=(i*i*i)+i; printf("%d ",sr); } getch(); }