Brijmohan lal Sahu - Facebook
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Showing posts with label Complete Square. Show all posts
Showing posts with label Complete Square. Show all posts

Thursday, December 4, 2014

Program to print table of any input number along with sum of all values using do while loop in C.



table sum



Code Box
---------------------------------------------
/*Program to print table of any input number along with sum of all values */

#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,sum,mul;
sum=0;
i=1;
clrscr();

printf("\nEnter any number:");
scanf("%d",&num);

clrscr();  //for clear screen

printf("\n-------------------------------");
printf("\nNumber entered is: %d",num);
printf("\n-------------------------------");
printf("\nTable of %d is",num);
printf("\n---------------------------------------\n");

do
{
if(num==0)
{
printf("\nZero entered");
break;
}
mul=num*i;
printf("| %d ",mul);
sum=sum+mul;
i++;
}while(i<=10);

printf("\n--------------------------------------");

printf("\nSum of table is : %d",sum);

getch();
} 

Thursday, November 6, 2014

Program to check a number is complete square or not in C.



Complete Square




Code Box
-----------------------------------------

/* program to check a number is complete square or not */

#include<stdio.h>
#include<conio.h>
void main()
{
int a,sq,c,i;
clrscr(); 
a=0;
printf("\nEnter a number:");
scanf("%d",&sq);
c=sq/2;

printf("\n------------------------------------------");

for(i=2;i<=c;i++)
{
if(sq==(i*i))
{
printf("\nNumber %d is Square of: %d",sq,i);
a=1;
}
}

if(a==0)
{
printf("\nNot complete square");
}
printf("\n------------------------------------------");

getch();
}