Posts

Write a program to find palindrom number.

Write a program to find palindrom number.   #include<stdio.h> #include<conio.h> void main() { clrscr(); int n1,n,rem,rev=0; printf("enter a number=\n"); scanf("%d",&n); n1=n; while(n!=0) { rem=n%10; rev=rev*10+rem; n=n/10; } if(n1==rev) { printf("%d is a palindrom   number",n1); } else { printf("%d is not a palindrom   number",n1); } getch(); }   ===========================================   Output:   enter a number=121 121 is a palindrom   number

Write a program to check the entered number is armstrong or not.

Write a program to check the entered number is armstrong or not.   #include<stdio.h> #include<conio.h> void main() { clrscr(); int rem,res=0,n1,n;   printf("enter a number:\n"); scanf("%d",&n); n1=n; while(n!=0) { rem=n%10; res=res+(rem*rem*rem); n=n/10; } if(res==n1) { printf("%d is armstrong number",n1); } else { printf("%d is not armstrong number",n1); } getch(); } ===============================================   Output:   Enter a number:153 153 is armstrong number  

Write a program of function with no argument and no return type.

Write a program of function with no argument and no return type.   #include<stdio.h> #include<conio.h> void abc(); void main() {   clrscr(); printf("abc\n"); abc(); getch(); } void abc() { printf("xyz"); } ================================================     Output:   abc xyz

Write a program for reverse number.

Write a program for reverse number.   #include<stdio.h> #include<conio.h> void main() { clrscr(); int n1,n,rem,rev=0; printf("enter a number="); scanf("%d",&n); n1=n; while(n!=0) { rem=n%10; rev=rev*10+rem; n=n/10; }   printf("reverse of %d is %d",n1,rev); getch(); }   =================================================   Output:   Enter a number=234 Reverse of 234 is 432  

Write a program for swapping of a number

Write a program for swapping of a number   #include<stdio.h> #include<conio.h> void main() { Int a=10, b=20,c; Printf(“Before Swaping “); Printf(“a=%d,b=%d”,a,b); c=a; a=b; b=c; Printf(“After Swaping”); Printf(“a=%d,b=%d”,a,b”); }   =============================================== Output:   Before Swaping a=10,b=20 After Swaping a=20,b=10

Write a program to find weather the entered number is positive negative or zero.

Write a program to find weather the entered number is positive negative or zero.   #include<stdio.h> #include<conio.h> { clrscr(); int a; printf(”Enter a number:“); scanf(“%d”, &a); if(a>0) { printf(“%d   is positive number”, a); } elseif (a<0) { printf(“%d is negative number”, a); } else { printf(“you entered zero”); } getch(); }   Output:   Enter a number:0 you entered zero

Write a program to find greatest of three number .

Write a program to find greatest of three number .   #include <stdio.h> #include   <conio.h> void main() { int   a,b,c; clrscr(); printf (“Enter three number”); scanf (“%d %d %d”,&a,&b,&c); if (a>b) { if (a>c) { printf(“%d is greatest”,a); } else { printf(“%d is greatest”,b); } } elseif(b>c) { printf(“%d is greatest ”, b); } else { printf(“%d is greatest”,c); } getch(); }   Output: Enter three number:3 5 8 8 is greatest

Write a program to find function with argument and return type.

Write a program to find function with argument and return type.   #include<stdio.h> #include<conio.h> void main() { clrscr(); int x=10,y=20,z; int abc(int x,int y); z=abc (x,y); printf("value of z=%d",z); getch(); } abc (int a,int b) { int c; c=a+b; return c; }   Output:   Value of z=30

Write a program for factorial of a number.

Write a program for factorial of a number.     #include<stdio.h> #include<conio.h> void main() { clrscr(); int   fact=1,i,n; printf(“Enter a number:”); scanf(“%d”,&n); for(i=1;i<=n;i++) {   fact=fact*i; } printf(“Factorial of %d is:”,fact); getch(); }     Output:   Enter a number:4 Factorial of 4 is :24  

Write a program to check the entered number is even or odd.

Write a program to check the entered number is even or odd.   #include <stdio.h> #include<conio.h> void main() { clrscr(); int a; printf (“Enter a number:”) scanf (“%d”,&a); if (a%2==0) {   printf(“%d is even number”,a); } else { printf(“%d is odd number”,a); } getch(); }       Output:   Enter a number:8 8 is even number      

Write a program for call by value.

Write a program for call by value.   #include<stdio.h> #include<conio.h> void abc(int x) { x=100; printf("x=%d",x); printf("\n"); } void main() { int a=30; clrscr(); printf("a=%d",a); printf("\n"); abc(a); printf("a=%d",a); getch(); } =======================================================   OUTPUT:   a=30 x=100 a=30      

Write a program for call by reference.

Write a program for call by reference.   #include<stdio.h> #include<conio.h> void abc(int &x) { x=100; printf("x=%d",x); printf("\n"); } void main() { int a=30; clrscr(); printf("a=%d",a); printf("\n"); abc(a); printf("a=%d",a); getch(); }     Output: a=30 x=100 a=100        

Write a program to find area of circle.

Write a program to find area of circle.   #include<stdio.h> #include<conio.h> void main() { clrscr(); int area,r; printf(“Enter radius:”); scanf(“%d”,&r); area=3.14*r*r; printf(“Area of circle:”,area); getch(); }     Output: Enter radius:3 Area of circle:28.26

Write VB program to swap the contents of variables using Pass by reference.

Image
Write VB program to swap the contents of variables using Pass by reference. Private Sub Command1_Click() Dim A As Integer Dim B As Integer A = InputBox("Enter 1st Number") B = InputBox("Enter 2nd Number") Print "Before Swap A = " & A &"   B = " & B Call Swap(A, B) Print "After Swap A = " & A &"   B = " & B End Sub Sub Swap(ByRef X As Integer, ByRef Y As Integer) Dim Temp As Integer Temp = X X = Y Y = Temp End Sub

Write VB program to find octal , hexadecimal , binary of given decimal number.

Image
Write VB program to find octal , hexadecimal , binary of given decimal number. Private Sub OptBin_Click() Dim N As Single Text2.Text = "" N = Text1.Text While N > 0 R = N Mod 2 Text2.Text = Text2.Text & R N = Int(N / 2) Wend Text2.Text = StrReverse(Text2) End Sub Private Sub Form_Load() Text1 = "" End Sub Private Sub OptHexa_Click() Text2.Text = Hex(Text1.Text) End Sub Private Sub OptOctal_Click() Text2.Text = Oct(Text1.Text) End Sub

Write VB program to find multiplication table using dynamic array

Image
Write VB program to find multiplication table using dynamic array Private Sub Command1_Click() Dim A() As Integer Dim N As Integer Dim K As Integer N = InputBox("Enter a Number") K = InputBox("Enter Upto What Print") ReDimA(K) For I = 1 To K A(I) = N * I Next I For I = 1 To K     Print N & " * " & I & " = " &A(I) Next I End Sub

Write VB program to find multiplication table using dynamic array & Preserve keyword.

Image
Write VB program to find multiplication table using dynamic array & Preserve keyword. Private Sub Command1_Click() Dim A() As Integer 'Empty array Dim I As Integer Dim N As Integer Dim K As Integer ReDimA(5) N = InputBox("Enter a Number") For I = 1 To 5 A(I) = N * I Next I K = InputBox("Enter Upto What Print") ReDim Preserve A(K) For I = 6 To K A(I) = N * I Next I For I = 1 To K     Print N & " * " & I & " = " &A(I) Next I End Sub

Write VB program to convert entered text in bold , italic , underline.

Image
Write VB program to convert entered text in bold , italic , underline. Private Sub ChkBold_Click() If ChkBold.Value = 1 Then     Text1.FontBold = True Else     Text1.FontBold = False End If End Sub   Private Sub ChkItalic_Click() If ChkItalic.Value = 1 Then     Text1.FontItalic = True Else     Text1.FontItalic = False End If End Sub   Private Sub ChkUnderline_Click() If ChkUnderline.Value = 1 Then     Text1.FontUnderline = True Else     Text1.FontUnderline = False End If End Sub

Write VB program to convert give number into word format.

Image
Write VB program to convert   give number into word format. Private Sub Command1_Click() Dim Word(10) As String * 6 Dim L As Integer Dim I As Integer Dim N As Integer Word(0) = "Zero" Word(1) = "One" Word(2) = "Two" Word(3) = "Three" Word(4) = "Four" Word(5) = "Five" Word(6) = "Six" Word(7) = "Seven" Word(8) = "Eight" Word(9) = "Nine" L = Len(Text1) For I = 1 To L     N = Val(Mid(Text1, I, 1))     Label3 = Label3 &Word(N) Next I End Sub