Raghu Institute of Technology
Raghu Institute of Technology
R13 Syllabus
FLOWCHART:
Start
Declare i, and n
Read n
true
false
false
true
Display
table
Stop
PROGRAM:
PROGRAM
/* C Program to display multiplication table */
Program name:
// wk4a.c
/* Done By : C-Faculty
#include<stdio.h>
#include<curses.h>
int main()
{
int i,j,n;
clear();
printf(enter n);
scanf(%d,&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=10;j++)
{
printf(%d*%d=%d,i,j,i*j);
}
}
return(0);
}
Dated: 15/10/2013*/
ORIGINAL OUTPUT :
Output (1): enter n 1
1*1=1
1*2=2
1*3=3
1*4=4
1*5=5
1*6=6
1*7=7
1*8=8
1*9=9
1*10=10
SPECIFICATION:
(4)(b). Write a c program to enter a decimal number, and calculate and display the binary
equivalent of that number.
ALGORITHM:
Step1: Start
Step2: Declare d, i, j, rem[100]
Step3: Read d
Step4: i is initialized as 0 and condition d>0 is checked and incremented until loop
fails.
Step6: j is initialized as i-1 and condition j=0 is checked and j is decremented until loop fails.
Step6: Display rem[i]
Step7: Stop
FLOWCHART:
START
Declare d, i, j, reminder[100]
Read d
False
true
true
Display rem[i]
STOP
false
PROGRAM
/*C Program to convert decimal to binary */
Program name:
// wk4a.c
/* Done By : C-Faculty
#include<stdio.h>
#include<curses.h>
int main()
{
int d,i,j,rem[100];
clear();
printf("enter your decimal number:\n");
scanf("%d",&d);
for(i=0;d>0;i++)
{
rem[i]=d/2;
d=d/2;
i++;
}
printf("binary number is:\n\n");
for( j=i-1;j=0 ;j--)
{
printf("%d",rem[i]);
}
return(0);
Department of Computer Science & Engg
Dated: 15/10/2013*/
--xXx--
SPECIFICATION:
(4). Write a C program to check whether the number is Armstrong number or not.
ALGORITHM:
Step1: Start
Step2: Declare n, temp, sum0 and r
Step 3: Read n
Step4: Compute tempn
Step5: While(n!=0)
Do
5.1: rn%10
5.2: sumsum+(r*r*r)
5.3: nn/10
Done
Step6: Check sum==temp
Step6.1: Display it is an Armstrong number
Step7: Else display it is not an Armstrong number
Step8: Stop
FLOWCHART:
Start
Read n
While(n!=0)
rn%10
sumsum+(r*r*r)
nn/10
false
true
Check
sum==temp
It is an Armstrong
number
Display it is not an
Armstrong number
Stop
PROGRAM
/* C Program to Check whether the given number is Armstrong or not */
Program name:
// wk4c.c
/* Done By : C-Faculty
Dated: 15/10/2013*/
#include<stdio.h>
#include<curses.h>
int main()
{
int n,temp,sum=0,r;
printf(enter n);
scanf(%d,&n);
temp=n;
while(n!=0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(sum==temp)
printf(%d is an Armstrong number,temp);
else
printf(%d is not an Armstrong number,temp);
return(0);
}