Vous êtes sur la page 1sur 6

Program:13 Date:02-03-2013 AIM:WAP to check wheather a given number is palindrome or not. #include<conio.

h> //for console input and output #include<stdio.h> //for standard input and output void main()//no value return { int n,p,r,q=0; clrscr(); //clear the output window printf("enter the number"); scanf("%d",&n); p=n; while(n>0) //condition { r=n%10; q=q*10+r; n=n/10; } if(p==q) printf("the number is palindrome"); else printf("number is not palindrome "); getch(); // to hold output screen } O/P: enter the number535 the number is palindrome

Gyanendra Munda

PAGE NO:14

Program:14 Date:02-03-2013 AIM:WAP to display first 20 natural number. #include<conio.h> // for console input and output #include<stdio.h> // for stndard input and output void main() // returning no value { int i; clrscr(); // to clear the screen printf("the first 20 natural number are:"); for(i=1;i<=20;i++) { printf("%d ",i); } getch(); // to hold output screen } O/P:the first 20 natural number are:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Gyanendra Munda

PAGE NO:15

Program:15 Date:02-03-2013 AIM:WAP to factorial of given number. #include<conio.h> // for console input and output #include<stdio.h> // for stndard input and output void main() // returning no value { int n,i; int fact=1; clrscr(); // to clear the screen printf("enter the number:"); scanf("%d",&n); for(i=1;i<=n;i++) //loop { fact=fact*i; } printf("the factorial of %d is %d",n,fact); getch(); // to hold output screen } O/P: enter the number:5 the factorial of 5 is 120

Gyanendra Munda

PAGE NO:16

Program:16 Date:02-03-2013 AIM:WAP to display the sum of natural number. #include<conio.h> // for console input and output #include<stdio.h> // for stndard input and output void main() // returning no value { int n,r; int sum=0; clrscr(); // to clear the screen printf("enter the number:"); scanf("%d",&n); while(n>0) //loop { r=n%10; sum=sum+r; n=n/10; } printf("the sum of digit is %d",sum); getch(); // to hold output screen } O/p: enter the number:565 the sum of digit is 16

Gyanendra Munda

PAGE NO:17

Program:17 Date:02-03-2013 AIM:wap to display the sum of natural number b/w 100 to 200 & divisible by 11. #include<conio.h> // for console input and output #include<stdio.h> // for stndard input and output void main() // returning no value { int n,i; int sum=0; clrscr(); // to clear the screen for(i=100;i<200;i++) //loop { if (i%11==0) sum=sum+i; } printf("the sum of number frm 100 to 200 & divisible by11 is %d",sum); getch(); // to hold output screen } O/P:the sum of number frm 100 to 200 & divisible by11 is 1386

Gyanendra Munda

PAGE NO:18

Program:18 Date:02-03-2013 AIM:wap to display the grade of student according to marks. #include<conio.h> // for console input and output #include<stdio.h> // for standard input and output void main() // returning no value { int n,i; clrscr(); // to clear the screen printf("enter the marks of student"); scanf("%d",&n); i=n/10; switch(i) { case 10: case 9: case 8: printf("grade is honours"); break; case 7: case 6: printf("grade is first division"); break; case 5: printf("grade is second division"); break; default: printf("grade is fail"); } getch(); } // to hold the output screen O/P:Enter the marks of student78 Grade is first division. Gyanendra Munda PA GE NO:19

Vous aimerez peut-être aussi