HTML Tutorial || Networking Assignment || Computer Full Forms || Ms-Office Shortcut Keys || Ms-Office Notes || Number System Notes || Internet Assignment
JavaScript Tutorial || CSS Tutorial || Operating System Notes || History of Computer Assignment || Netwoking Notes || Computer Fundamentals Notes

C Program to Print Multiplication Table of Any Number Using For Loop


Q:- Write a C Program to Print Multiplication Table of Any Number Using For Loop ?
       Input
         #include<stdio.h>
         #include<conio.h>
         main()
   {
int num,i,t=1;
clrscr();
printf(“Enter a Number to Print Table =”);
scanf(“%d”,&num);
for(i=1;i<=10;i++)
{
t=num*i;
printf(“%d*%d=%d\n”,num,i,t);
}
getch();
   }


Output

Enter a Number to Print Table = 2
2     *     1     =     2
2     *     2     =     4
2     *     3     =     6
2     *     4     =     8
2     *     5     =     10
2     *     6     =     12
2     *     7     =     14
2     *     8     =     16
2     *     9     =     18
2     *     10   =     20

C Program to Find Sum of all Odd Numbers b/w 1 to n Using For Loop


Q:- Write a C Program to Find Sum of all Odd Numbers b/w 1 to n Using For Loop ?
      Input
        #include<stdio.h>
        #include<conio.h>
        main()
  {
int num,i,s=0;
clrscr();
printf(“Enter a Limit of N=”);
scanf(“%d”,&num);
for(i=1;i<=num;i++)
{
s=s+i;
}
printf(“Sum of all Odd Numbers = %d”,s);
getch();
   }


Output

Enter a Limit of N = 8
Sum of all Even Numbers = 16

C Program to Find Sum of all Even Numbers b/w 1 to n Using For Loop


Q:- Write a C Program to Find Sum of all Even Numbers b/w 1 to n Using For Loop ?
     Input
      #include<stdio.h>
      #include<conio.h>
      main()
  {
int num,i,s=0;
clrscr();
printf(“Enter a Limit of N=”);
scanf(“%d”,&num);
for(i=2;i<=num;i++)
{
s=s+i;
}
printf(“Sum of all Even Numbers = %d”,s);
getch();
  }


Output

Enter a Limit of N = 5
Sum of all Even Numbers = 6

C program to Find Sum of all Numbers b/w 1 to n Using For Loop


Q:- Write a C program to Find Sum of all Numbers b/w 1 to n Using For Loop ?
      Input
        #include<stdio.h>
        #include<conio.h>
        main()
   {
int num,i,s=0;
clrscr();
printf(“Enter a Limit of N=”);
scanf(“%d”,&num);
for(i=1;i<=num;i++)
{
s=s+i;
}
printf(“Sum of all Natural Numbers = %d”,s);
getch();   
}


Output

Enter a Limit of N = 5
Sum of all Natural Numbers = 15

C program to Print all Odd Numbers b/w 1 to 10 Using For Loop


Q:- Write a C program to Print all Odd Numbers b/w 1 to 10 Using For Loop ?
      Input
        #include<stdio.h>
        #include<conio.h>
        main()
  {
int i;
clrscr();
printf(“Odd Numbers b/w 1 to 10 are =”);
for(i=1;i<=10;i=i+2)
{
printf(“%d\n”,i);
}
getch();
  }


Output

Odd Numbers b/w 1 to 10 are = 1
3
5
7
9