Understanding for loop. Learn syntax for For-Loop and different programs on Loop Control Structures.
- 032. Write a program to print table of a given number n in C language
#include<stdio.h> #include<conio.h> main() { int i,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=1;i<=10;i++) printf("%d X %d = %d\n",n,i,n*i); getch(); }
- 033. Write a program to print sum of given first n numbers in C language
#include<stdio.h> #include<conio.h> main() { int n,newn,i,sum=0; clrscr(); printf("Enter number : "); scanf("%d",&n); printf("Numbers entered....\n"); for(i=1;i<=n;i++) { scanf("%d",&newn); sum=sum+newn; } printf("Sum of given n digits is... %d",sum); }