Showing posts with label integer. Show all posts
Showing posts with label integer. Show all posts

Saturday, March 10, 2012

Write a C program to find the sum of first n natural numbers.

#include  
#include
void main()
{
 int i, n, sum = 0;
clrscr();
printf(“Enter an integer number\n”);
scanf (“%d”, &n);
for (i=1; i <= n; i++)
{
 sum = sum + i;
}
printf (“Sum of first %d natural numbers = %d\n”, n, sum);

getch();
}

Tuesday, February 22, 2011

Write a Visual Basic program in which integer number is entered by the user and its table is printed on form

WAP in which integer number is entered by the user and its table is printed on form.
___________________________________________________________
Private Sub Command1_Click()
Dim a, i, j, k
a = Val(Text1.Text)
If a > 0 Then
For i = 0 To 9
For j = a To a
k = Str(j) & " * " & Str(i) & " = " & i * j
Print k
Next j
Next i
Else
MsgBox ("Number is less then or equal to zero")
End If
End Sub

Private Sub Command2_Click()
Text1.Text = ""
table.Cls
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()

End Sub
___________________________________________________
OUTPUT
___________________________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image